Skip to content

Commit

Permalink
Merge pull request #829 from egovernments/HRMS-Chnages-Prebuiild
Browse files Browse the repository at this point in the history
Hrms chnages prebuiild
  • Loading branch information
pradeepkumarcm-egov authored Jun 28, 2024
2 parents f902866 + 8592c65 commit 1120c40
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ const MultiSelectDropdown = ({

useEffect(()=>{
if (alreadyQueuedSelectedState?.length === filteredOptions?.length){
if(alreadyQueuedSelectedState?.length != 0 && filteredOptions?.length != 0){
setIsSelected(true)
}
}else{
setIsSelected(false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -132,6 +151,7 @@ const EditForm = ({ tenantId, data }) => {
}
}
}

if (
formData?.SelectEmployeeGender?.gender.code &&
formData?.SelectEmployeeName?.employeeName &&
Expand All @@ -142,7 +162,8 @@ const EditForm = ({ tenantId, data }) => {
&&
checkfield &&
phonecheck &&
checkMailNameNum(formData)
checkMailNameNum(formData)&&
hasUniqueTenantIds(formData?.Jurisdictions)
) {
setSubmitValve(true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -120,7 +138,8 @@ const CreateEmployee = () => {
&&
checkfield &&
phonecheck &&
checkMailNameNum(formData)
checkMailNameNum(formData) &&
hasUniqueTenantIds(formData?.Jurisdictions)
) {
setSubmitValve(true);
} else {
Expand Down

0 comments on commit 1120c40

Please sign in to comment.