diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/SelectEmployeeType.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/SelectEmployeeType.js index d6c589ea1..9f7cde494 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/SelectEmployeeType.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/SelectEmployeeType.js @@ -15,14 +15,13 @@ const SelectEmployeeType = ({ t, config, onSelect, formData = {}, userType }) => function SelectEmployeeType(value) { setemployeeType(value); } - useEffect(() => { - setEmployeeTypeData(data?.MdmsRes?.["egov-hrms"]?.EmployeeType); + setEmployeeTypeData(data?.MdmsRes?.["egov-hrms"]?.EmployeeType?.filter((x) => x?.code === "PERMANENT")); }, [data, data?.MdmsRes]); useEffect(() => { - onSelect(config.key, employeeType); - }, [employeeType]); + onSelect(config.key, employeeTypeData?.length == 1 ? employeeTypeData[0] : employeeType); + }, [employeeTypeData]); const inputs = [ { label: "HR_EMPLOYMENT_TYPE_LABEL", @@ -48,9 +47,10 @@ const SelectEmployeeType = ({ t, config, onSelect, formData = {}, userType }) => 0 ? employeeTypeData[0] : employeeType} option={employeeTypeData} select={SelectEmployeeType} + disable={true} optionKey="code" defaultValue={undefined} t={t} diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/assignment.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/assignment.js index d3cda039a..92abd194a 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/assignment.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/assignment.js @@ -39,8 +39,8 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { key: 1, fromDate: undefined, toDate: undefined, - isCurrentAssignment: false, - department: null, + isCurrentAssignment: true, + department: "DWSS", designation: null, }, ] @@ -63,6 +63,13 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { } } + function getdepartmentdata() { + return data?.MdmsRes?.["common-masters"]?.Department?.map((ele) => { + ele["i18key"] = t("COMMON_MASTERS_DEPARTMENT_" + ele.code); + return ele; + }); + } + const handleAddUnit = () => { setassignments((prev) => [ ...prev, @@ -97,8 +104,10 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { fromDate: assignment?.fromDate ? new Date(assignment?.fromDate).getTime() : undefined, toDate: assignment?.toDate ? new Date(assignment?.toDate).getTime() : undefined, isCurrentAssignment: assignment?.isCurrentAssignment, - department: assignment?.department?.code, - designation: STATE_ADMIN ? getdesignationdata()?.length > 0 && getdesignationdata()[0]?.code : assignment?.designation?.code, + department: assignment?.department?.code || "DWSS", + designation: STATE_ADMIN + ? getdesignationdata()?.length > 0 && (getdesignationdata()[0]?.code || "DIV_ADMIN") + : assignment?.designation?.code, }) : []; }); @@ -119,13 +128,6 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { let department = []; let designation = []; const [focusIndex, setFocusIndex] = useState(-1); - - function getdepartmentdata() { - return data?.MdmsRes?.["common-masters"]?.Department?.map((ele) => { - ele["i18key"] = t("COMMON_MASTERS_DEPARTMENT_" + ele.code); - return ele; - }); - } if (isLoading) { return ; } @@ -152,9 +154,9 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { currentassignemtDate={currentassignemtDate} /> ))} - */} ); }; @@ -177,7 +179,7 @@ function Assignment({ }) { const STATE_ADMIN = Digit.UserService.hasAccess(["STATE_ADMIN"]); const selectDepartment = (value) => { - setassignments((pre) => pre.map((item) => (item.key === assignment.key ? { ...item, department: value } : item))); + setassignments((pre) => pre.map((item) => (item.key === assignment.key ? { ...item, department: getdepartmentdata(department)[0] } : item))); }; const selectDesignation = (value) => { setassignments((pre) => pre.map((item) => (item.key === assignment.key ? { ...item, designation: value } : item))); @@ -286,8 +288,8 @@ function Assignment({ {`${t("HR_DEPT_LABEL")} * `} { }; finalData.push(obj); }); + finalData?.map((items, index) => { + if (items?.division == undefined && items?.divisionBoundary?.length == 0 && jurisdictionsData[index]?.divisionBoundary?.length > 0) { + finalData[index] = jurisdictionsData[index] !== undefined && jurisdictionsData[index]; + } else if ( + finalData?.length > jurisdictionsData?.length && + jurisdictionsData[index]?.division == undefined && + items?.division != undefined && + jurisdictionsData?.length + 1 == finalData?.length + ) { + finalData = jurisdictionsData; + } + // else if (finalData?.length > jurisdictionsData?.length && jurisdictionsData?.length + 1 !== finalData?.length) { + // finalData.splice(jurisdictionsData?.length, 1); + // } + }); jurisdictionData = finalData; } onSelect( @@ -200,6 +215,7 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => { } setInactiveJurisdictions([...inactiveJurisdictions, res]); } + setJuristictionsData((pre) => pre.filter((el) => el.key !== unit.key)); setjurisdictions((prev) => prev.filter((el) => el.key !== unit.key)); if (FormData.errors?.Jurisdictions?.type == unit.key) { clearErrors("Jurisdictions"); @@ -353,7 +369,7 @@ function Jurisdiction({ return { ...city, i18text: Digit.Utils.locale.getCityLocale(city.code) }; }) ); - }, [jurisdiction?.boundaryType, data?.MdmsRes]); + }, [jurisdiction?.hierarchy, jurisdiction?.boundaryType, data?.MdmsRes]); useEffect(() => { if (Boundary?.length > 0) { @@ -415,7 +431,7 @@ function Jurisdiction({ })); return finalProjects; }; - const selectrole = (e, data) => { + const selectrole = (e) => { let res = []; e && e?.map((ob) => { @@ -425,6 +441,25 @@ function Jurisdiction({ res?.forEach((resData) => { resData.labelKey = "ACCESSCONTROL_ROLES_ROLES_" + resData.code; }); + + if (isEdit && STATE_ADMIN) setJuristictionsData((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, roles: res } : item))); + let data = jurisdictionsData?.map((items, index) => { + let obj = {}; + if (index === jurisdiction?.key) { + obj = { + ...items, + roles: res, + }; + } else { + obj = { ...items }; + } + return obj; + }); + if (isEdit && STATE_ADMIN) + onSelect( + config?.key, + [...data].filter((value) => Object.keys(value).length !== 0) + ); setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, roles: res } : item))); }; @@ -619,4 +654,4 @@ function Jurisdiction({ ); } -export default Jurisdictions; \ No newline at end of file +export default Jurisdictions; \ No newline at end of file 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 427175e9c..55cc566df 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 @@ -122,7 +122,7 @@ const EditForm = ({ tenantId, data }) => { for (let i = 0; i < formData?.Jurisdictions?.length; i++) { let key = formData?.Jurisdictions[i]; - if (!(key?.boundary && key?.boundaryType && key?.hierarchy && key?.roles?.length > 0)) { + if (!((key?.boundary || key?.divisionBoundary) && (key?.boundaryType || key?.division) && key?.hierarchy && key?.roles?.length > 0)) { setcheck(false); break; } else {