From b9d64fbff63ba1bfdff03034e73122bc1d6dfae4 Mon Sep 17 00:00:00 2001 From: mithun-hegde-egov Date: Thu, 24 Oct 2024 12:00:44 +0530 Subject: [PATCH 1/2] hrms edit and deactivate bug fixes --- .../hrms/src/pages/EditEmployee/EditForm.js | 15 ++++++++++----- .../modules/hrms/src/pages/EmployeeDetails.js | 7 ++++++- .../modules/hrms/src/pages/createEmployee.js | 3 +-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EditEmployee/EditForm.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EditEmployee/EditForm.js index 5c5e680c326..386e1d5bdd5 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EditEmployee/EditForm.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EditEmployee/EditForm.js @@ -14,6 +14,8 @@ const EditForm = ({ tenantId, data }) => { const [phonecheck, setPhonecheck] = useState(false); const [checkfield, setcheck] = useState(false); const mutationUpdate = Digit.Hooks.hrms.useHRMSUpdate(tenantId); + const isMultiRootTenant = Digit.Utils.getMultiRootTenant(); + const { data: mdmsData, isLoading } = Digit.Hooks.useCommonMDMS(Digit.ULBService.getStateId(), "egov-hrms", ["CommonFieldsConfig"], { select: (data) => { return { @@ -80,8 +82,8 @@ const EditForm = ({ tenantId, data }) => { name: ele.hierarchy, }, boundaryType: { label: ele.boundaryType, i18text: `EGOV_LOCATION_BOUNDARYTYPE_${ele.boundaryType.toUpperCase()}` }, - boundary: Digit.Utils.getMultiRootTenant()?{ code: tenantId }:{ code: ele.boundary }, - roles: data?.user?.roles.filter((item) => item.tenantId == ele.boundary), + boundary: { code: ele.boundary }, + roles: isMultiRootTenant?data?.user?.roles:data?.user?.roles.filter((item) => item.tenantId == ele.boundary), }); }), Assignments: data?.assignments.map((ele, index) => { @@ -171,11 +173,9 @@ const EditForm = ({ tenantId, data }) => { input.Jurisdictions = input?.Jurisdictions?.map((juris) => { return { ...juris, - boundary: tenantId, tenantId: tenantId, }; }); - if ( !Object.values( input.Jurisdictions.reduce((acc, sum) => { @@ -191,7 +191,12 @@ const EditForm = ({ tenantId, data }) => { } let roles = input?.Jurisdictions?.map((ele) => { return ele.roles?.map((item) => { - item["tenantId"] = ele.boundary; + if(isMultiRootTenant){ + item["tenantId"] = tenantId; + } + else{ + item["tenantId"] = ele.boundary; + } return item; }); }); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EmployeeDetails.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EmployeeDetails.js index d3afb6d71e1..745744674aa 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EmployeeDetails.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EmployeeDetails.js @@ -21,6 +21,7 @@ const Details = () => { const [mutationHappened, setMutationHappened, clear] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_MUTATION_HAPPENED", false); const [successData, setsuccessData, clearSuccessData] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_MUTATION_SUCCESS_DATA", false); const isMobile = window.Digit.Utils.browser.isMobile(); + const isMultiRootTenant = Digit.Utils.getMultiRootTenant(); useEffect(() => { setMutationHappened(false); @@ -62,6 +63,9 @@ const Details = () => { return ; } + console.log(":data of the employee", data); + console.log("role data is", data?.Employees?.[0]?.user.roles.map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code))); + return (
@@ -169,7 +173,8 @@ const Details = () => { ele.tenantId == element?.boundary).map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code))} + text={ + isMultiRootTenant? data?.Employees?.[0]?.user.roles.map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code)):(data?.Employees?.[0]?.user.roles.filter((ele) => ele.tenantId == element?.boundary).map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code)))} /> ); diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js index 2f27bd098e1..0d0036d2fef 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/createEmployee.js @@ -151,11 +151,10 @@ const CreateEmployee = () => { data.Jurisdictions = data?.Jurisdictions?.map((juris) => { return { ...juris, - boundary: selectedCity, tenantId: tenantId }; }); - // If no current assignment, throw an error + if(!canSubmit){ setShowToast({ key: "error", label: "ERR_ALL_MANDATORY_FIELDS" }); return; From d405b79e7ebf4c95701564110a41f6534fd2ccda Mon Sep 17 00:00:00 2001 From: mithun-hegde-egov Date: Thu, 24 Oct 2024 12:05:21 +0530 Subject: [PATCH 2/2] removed console log --- .../packages/modules/hrms/src/pages/EmployeeDetails.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EmployeeDetails.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EmployeeDetails.js index 745744674aa..e6044963ed3 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EmployeeDetails.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/pages/EmployeeDetails.js @@ -63,8 +63,6 @@ const Details = () => { return ; } - console.log(":data of the employee", data); - console.log("role data is", data?.Employees?.[0]?.user.roles.map((ele) => t(`ACCESSCONTROL_ROLES_ROLES_` + ele?.code))); return (