@@ -21,7 +21,7 @@ import { updateOrgLeaderDetails, selectOrgLeaderDetails, selectObjectIdEmployeeI
2121import { selectJobOwnerFilterSuggestions } from '../../store/jobs.slice' ;
2222import { manageMembershipIsEditingExistingJob } from '../../store/manageMembership.slice' ;
2323import { fetchDefaultSqlMembershipSourceAttributes } from '../../store/sqlMembershipSources.api' ;
24- import { selectAttributes } from '../../store/sqlMembershipSources.slice' ;
24+ import { selectAttributes , selectSource } from '../../store/sqlMembershipSources.slice' ;
2525import { SqlMembershipAttribute } from '../../models' ;
2626import { IFilterPart } from '../../models/IFilterPart' ;
2727
@@ -61,6 +61,7 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
6161 const [ children , setChildren ] = useState < ChildType [ ] > ( [ ] ) ;
6262 const excludeLeaderQuery = `EmployeeId <> ${ source . manager ?. id } `
6363 const attributes = useSelector ( selectAttributes ) ;
64+ const hrSource = useSelector ( selectSource ) ;
6465 const [ filteredOptions , setFilteredOptions ] = useState < FilteredOptionsState > ( { } ) ;
6566 const [ items , setItems ] = useState < IFilterPart [ ] > ( [ ] ) ;
6667 let options : IComboBoxOption [ ] = [ ] ;
@@ -86,6 +87,11 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
8687 setFilteredOptions ( { } ) ;
8788 } , [ children ] ) ;
8889
90+ useEffect ( ( ) => {
91+ if ( ! includeOrg ) { setErrorMessage ( '' ) ; }
92+ } , [ includeOrg ] ) ;
93+
94+
8995 useEffect ( ( ) => {
9096 if ( children . length > 0 ) {
9197 let newStr = "" ;
@@ -152,18 +158,29 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
152158 }
153159 } , [ orgLeaderDetails . employeeId , orgLeaderDetails . objectId ] ) ;
154160
161+ useEffect ( ( ) => {
162+ if ( orgLeaderDetails . employeeId === 0 && orgLeaderDetails . maxDepth === 0 && includeOrg && partId === orgLeaderDetails . partId ) {
163+ setErrorMessage ( hrSource ?. name && hrSource ?. name !== "" ?
164+ orgLeaderDetails . text + strings . HROnboarding . customOrgLeaderMissingErrorMessage + hrSource ?. name + strings . HROnboarding . source :
165+ orgLeaderDetails . text + strings . HROnboarding . orgLeaderMissingErrorMessage ) ;
166+ }
167+ } , [ orgLeaderDetails ] ) ;
168+
155169 const getPickerSuggestions = async (
156170 filterText : string
157171 ) : Promise < IPersonaProps [ ] > => {
158172 return filterText && ownerPickerSuggestions ? ownerPickerSuggestions : [ ] ;
159173 } ;
160174
161175 const handleOrgLeaderInputChange = ( input : string ) : string => {
176+ setIncludeOrg ( true ) ;
177+ setErrorMessage ( '' ) ;
162178 dispatch ( getJobOwnerFilterSuggestions ( { displayName : input , alias : input } ) )
163179 return input ;
164180 }
165181
166182 const handleOrgLeaderChange = ( items ?: IPersonaProps [ ] | undefined ) => {
183+ setIncludeOrg ( true ) ;
167184 setIsDisabled ( true ) ;
168185 if ( items !== undefined && items . length > 0 ) {
169186 dispatch ( fetchOrgLeaderDetails ( {
@@ -751,6 +768,12 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
751768 </ Stack >
752769 ) }
753770
771+
772+ < div className = { classNames . error } >
773+ { errorMessage }
774+ </ div >
775+ < br />
776+
754777 < Label > { strings . HROnboarding . includeFilter } </ Label >
755778 < ChoiceGroup
756779 selectedKey = { ( includeFilter || source . filter ) ? strings . yes : strings . no }
@@ -789,10 +812,6 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
789812 ) : null
790813 }
791814
792- < div className = { classNames . error } >
793- { errorMessage }
794- </ div >
795-
796815 </ div >
797816 ) ;
798817} ;
0 commit comments