diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/Multiselect.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/Multiselect.js index 7020d3f4a..752bec612 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/Multiselect.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/Multiselect.js @@ -109,7 +109,9 @@ const MultiSelectDropdown = ({ useEffect(()=>{ if (alreadyQueuedSelectedState?.length === filteredOptions?.length){ + if(alreadyQueuedSelectedState?.length != 0 && filteredOptions?.length != 0){ setIsSelected(true) + } }else{ setIsSelected(false) diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EditEmployee/EditForm.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EditEmployee/EditForm.js index b10a5c5c4..ec159e99c 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EditEmployee/EditForm.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EditEmployee/EditForm.js @@ -112,6 +112,25 @@ const EditForm = ({ tenantId, data }) => { return validEmail && name.match(Digit.Utils.getPattern("Name")); }; + + function hasUniqueTenantIds(items) { + // Create a Set to efficiently store unique tenantIds + const uniqueTenantIds = new Set(); + // Iterate through each item + for (const item of items) { + const tenantId = item.tenantId; + // Check if tenantId already exists in the Set + if (uniqueTenantIds.has(tenantId)) { + // Duplicate found, return false + return false; + } + // Add unique tenantId to the Set + uniqueTenantIds.add(tenantId); + } + // No duplicates found, all tenantIds are unique + return true; + } + const onFormValueChange = (setValue = true, formData) => { if (formData?.SelectEmployeePhoneNumber?.mobileNumber) { setMobileNumber(formData?.SelectEmployeePhoneNumber?.mobileNumber); @@ -132,6 +151,7 @@ const EditForm = ({ tenantId, data }) => { } } } + if ( formData?.SelectEmployeeGender?.gender.code && formData?.SelectEmployeeName?.employeeName && @@ -142,7 +162,8 @@ const EditForm = ({ tenantId, data }) => { && checkfield && phonecheck && - checkMailNameNum(formData) + checkMailNameNum(formData)&& + hasUniqueTenantIds(formData?.Jurisdictions) ) { setSubmitValve(true); } else { diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js index 2097d8cd7..411ae2229 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js @@ -85,6 +85,24 @@ const CreateEmployee = () => { const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {}); const [sessionFormData, setSessionFormData, clearSessionFormData] = employeeCreateSession; + function hasUniqueTenantIds(items) { + // Create a Set to efficiently store unique tenantIds + const uniqueTenantIds = new Set(); + // Iterate through each item + for (const item of items) { + const tenantId = item.tenantId; + // Check if tenantId already exists in the Set + if (uniqueTenantIds.has(tenantId)) { + // Duplicate found, return false + return false; + } + // Add unique tenantId to the Set + uniqueTenantIds.add(tenantId); + } + // No duplicates found, all tenantIds are unique + return true; + } + const onFormValueChange = (setValue = true, formData) => { if (!_.isEqual(sessionFormData, formData)) { setSessionFormData({ ...sessionFormData, ...formData }); @@ -120,7 +138,8 @@ const CreateEmployee = () => { && checkfield && phonecheck && - checkMailNameNum(formData) + checkMailNameNum(formData) && + hasUniqueTenantIds(formData?.Jurisdictions) ) { setSubmitValve(true); } else {