From 2e58a6e7eee0af0a2e160beee25695aaa2fd46ad Mon Sep 17 00:00:00 2001 From: maruthi phanendra Date: Mon, 10 Feb 2025 16:23:35 +0530 Subject: [PATCH 1/4] updated hrms for v2 --- .../libraries/src/services/elements/MDMS.js | 3 +- .../src/services/elements/User/index.js | 1 + .../hrms/src/components/config/config.js | 62 +-- .../components/pageComponents/assignment.js | 363 ++++++++++++++---- .../hrms/src/pages/EditEmployee/EditForm.js | 4 +- .../modules/hrms/src/pages/EmployeeDetails.js | 8 +- .../modules/hrms/src/pages/createEmployee.js | 171 ++++++--- micro-ui/web/package.json | 4 +- 8 files changed, 446 insertions(+), 170 deletions(-) diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js index 23d4e2acb6d..0dbc3d19e8b 100644 --- a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js @@ -50,7 +50,7 @@ const initRequestBody = (tenantId) => ({ moduleDetails: [ { moduleName: "common-masters", - masterDetails: [{ name: "CourtEstablishment" }, { name: "Court_Rooms" },{ name: "Designation" }, { name: "StateInfo" }, { name: "wfSlaConfig" }, { name: "uiHomePage" }], + masterDetails: [{ name: "CourtEstablishment" },{ name: "District" }, { name: "Court_Rooms" },{ name: "Designation" }, { name: "StateInfo" }, { name: "wfSlaConfig" }, { name: "uiHomePage" }], }, { moduleName: "tenant", @@ -727,6 +727,7 @@ const getHrmsEmployeeRolesandDesignations = () => ({ moduleName: "common-masters", masterDetails: [ { name: "CourtEstablishment", filter: "[?(@.active == true)]" }, + { name: "District", filter: "[?(@.active == true)]" }, { name: "Designation", filter: "[?(@.active == true)]" }, { name: "Court_Rooms", filter: "[?(@.active == true)]" }, ], diff --git a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/User/index.js b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/User/index.js index 96438af62b6..53287a089ca 100644 --- a/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/User/index.js +++ b/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/User/index.js @@ -8,6 +8,7 @@ export const UserService = { Object.entries(details).forEach(([key, value]) => data.append(key, value)); data.append("scope", "read"); data.append("grant_type", "password"); + console.log("detailss"); let authResponse = await ServiceRequest({ serviceName: "authenticate", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/config/config.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/config/config.js index bb0b05778fc..2ee3e31a7b6 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/config/config.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/config/config.js @@ -20,12 +20,12 @@ export const newConfig = [ // key: "SelectEmployeeGender", // withoutLabel: true, // }, - { - type: "component", - component: "SelectDateofBirthEmployment", - key: "SelectDateofBirthEmployment", - withoutLabel: true, - }, + // { + // type: "component", + // component: "SelectDateofBirthEmployment", + // key: "SelectDateofBirthEmployment", + // withoutLabel: true, + // }, { type: "component", component: "SelectEmployeeEmailId", @@ -55,37 +55,37 @@ export const newConfig = [ // key: "SelectDateofEmployment", // withoutLabel: true, // }, - // { - // type: "component", - // component: "SelectEmployeeId", - // key: "SelectEmployeeId", - // withoutLabel: true, - // }, + { + type: "component", + component: "SelectEmployeeId", + key: "SelectEmployeeId", + withoutLabel: true, + }, - // { - // type: "component", - // component: "HRBanner", - // key: "Banner1", - // withoutLabel: true, - // texts: { - // headerCaption: "Info", - // header: "HR_EMP_ID_MESSAGE", - // }, - // }, - ], - }, - { - head: "HR_JURISDICTION_DETAILS_HEADER", - body: [ { type: "component", - isMandatory: true, - component: "Jurisdictions", - key: "Jurisdictions", + component: "HRBanner", + key: "Banner1", withoutLabel: true, + texts: { + headerCaption: "Info", + header: "HR_EMP_ID_MESSAGE", + }, }, ], }, + // { + // head: "HR_JURISDICTION_DETAILS_HEADER", + // body: [ + // { + // type: "component", + // isMandatory: true, + // component: "Jurisdictions", + // key: "Jurisdictions", + // withoutLabel: true, + // }, + // ], + // }, { head: "HR_ASSIGN_DET_HEADER", @@ -96,7 +96,7 @@ export const newConfig = [ key: "Banner2", withoutLabel: true, texts: { - nosideText:true, + nosideText: true, headerCaption: "Info", header: "HR_ASSIGN_DET_SUB_HEADER", }, diff --git a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/assignment.js b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/assignment.js index 237c03b1896..397bc9df059 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/assignment.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/assignment.js @@ -1,18 +1,27 @@ -import { CardLabel, CheckBox, DatePicker, Dropdown, LabelFieldPair, Loader } from "@egovernments/digit-ui-react-components"; +import { + CardLabel, + CheckBox, + DatePicker, + Dropdown, + LabelFieldPair, + Loader, + MultiSelectDropdown, + RemoveableTag, +} from "@egovernments/digit-ui-react-components"; import React, { useEffect, useState } from "react"; import cleanup from "../Utils/cleanup"; import { convertEpochToDate } from "../Utils/index"; const makeDefaultValues = (sessionFormData) => { - return sessionFormData?.Assignments?.map((ele,index)=>{ + return sessionFormData?.Assignments?.map((ele, index) => { return { key: index, - fromDate: ele.fromDate ? convertEpochToDate(ele.fromDate): null, - toDate: ele.toDate ? convertEpochToDate(ele.toDate):null, - isCurrentAssignment: ele?.isCurrentAssignment, + fromDate: ele.fromDate ? convertEpochToDate(ele.fromDate) : null, + toDate: ele.toDate ? convertEpochToDate(ele.toDate) : null, + // isCurrentAssignment: ele?.isCurrentAssignment, designation: { code: ele?.designation, - i18key: ele.designation ? "COMMON_MASTERS_DESIGNATION_" + ele.designation:null, + i18key: ele.designation ? "COMMON_MASTERS_DESIGNATION_" + ele.designation : null, }, courtEstablishment: { code: ele?.courtEstablishment, @@ -20,20 +29,25 @@ const makeDefaultValues = (sessionFormData) => { }, courtroom: { code: ele?.courtroom, - i18key: ele.courtEstablishment ? "COMMON_MASTERS_COURT_ROOM_" + ele.courtroom : null, + i18key: ele.courtroom ? "COMMON_MASTERS_COURT_ROOM_" + ele.courtroom : null, }, - } - }) -} + district: { + code: ele?.district, + i18key: ele.district ? "COMMON_MASTERS_DISTRICT_" + ele.district : null, + }, + roles: ele?.roles || [], + }; + }); +}; const Assignments = ({ t, config, onSelect, userType, formData }) => { const tenantId = Digit.ULBService.getCurrentTenantId(); const { data: data = {}, isLoading } = Digit.Hooks.hrms.useHrmsMDMS(tenantId, "egov-hrms", "HRMSRolesandDesignation") || {}; - const [currentassignemtDate, setCurrentAssiginmentDate] = useState(null); + // const [currentassignemtDate, setCurrentAssiginmentDate] = useState(null); const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {}); - const [sessionFormData,setSessionFormData, clearSessionFormData] = employeeCreateSession; - const isEdit = window.location.href.includes("hrms/edit") + const [sessionFormData, setSessionFormData, clearSessionFormData] = employeeCreateSession; + const isEdit = window.location.href.includes("hrms/edit"); const [assignments, setassignments] = useState( !isEdit && sessionFormData?.Assignments @@ -43,13 +57,38 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { key: 1, fromDate: undefined, toDate: undefined, - isCurrentAssignment: false, + // isCurrentAssignment: false, courtEstablishment: null, designation: null, + district: null, courtroom: null, + roles: [], }, ] ); + + useEffect(() => { + console.log("checking"); + + // setassignments( + // makeDefaultValues(sessionFormData) || + // formData?.Assignments || [ + // { + // key: 1, + // fromDate: undefined, + // toDate: undefined, + // // isCurrentAssignment: false, + // courtEstablishment: null, + // designation: null, + // district: null, + // courtroom: null, + // roles: [], + // }, + // ] + // ); + }, [sessionFormData]); + + // console.log(assignments, sessionFormData, "assignments"); const reviseIndexKeys = () => { setassignments((prev) => prev.map((unit, index) => ({ ...unit, key: index }))); }; @@ -61,10 +100,12 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { key: prev.length + 1, fromDate: undefined, toDate: undefined, - isCurrentAssignment: false, + // isCurrentAssignment: false, courtEstablishment: null, + district: null, designation: null, courtroom: null, + roles: [], }, ]); }; @@ -79,7 +120,7 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { useEffect(() => { var promises = assignments?.map((assignment) => { - return assignment + let res = assignment ? cleanup({ id: assignment?.id, position: assignment?.position, @@ -88,12 +129,20 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { auditDetails: assignment?.auditDetails, fromDate: assignment?.fromDate ? new Date(assignment?.fromDate).getTime() : undefined, toDate: assignment?.toDate ? new Date(assignment?.toDate).getTime() : undefined, - isCurrentAssignment: assignment?.isCurrentAssignment, + // isCurrentAssignment: true, courtEstablishment: assignment?.courtEstablishment?.code, + district: assignment?.district?.code, designation: assignment?.designation?.code, courtroom: assignment?.courtroom?.code, }) : []; + if (assignment?.roles) { + res["roles"] = assignment?.roles.map((ele) => { + delete ele.description; + return ele; + }); + } + return res; }); Promise.all(promises).then(function (results) { @@ -103,16 +152,17 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { ); }); - assignments.map((ele) => { - if (ele.isCurrentAssignment) { - setCurrentAssiginmentDate(ele.fromDate); - } - }); + // assignments.map((ele) => { + // if (ele.isCurrentAssignment) { + // setCurrentAssiginmentDate(ele.fromDate); + // } + // }); }, [assignments]); let courtEstablishment = []; let designation = []; let courtroom = []; + let district = []; const [focusIndex, setFocusIndex] = useState(-1); function getCourtEstablishment() { @@ -125,6 +175,16 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { return keyA.localeCompare(keyB); }); } + function getDistrict() { + return data?.MdmsRes?.["common-masters"]?.District?.map((ele) => { + ele["i18key"] = t("COMMON_MASTERS_DISTRICT_" + ele.code); + return ele; + }).sort((a, b) => { + const keyA = a?.i18key || ""; + const keyB = b?.i18key || ""; + return keyA.localeCompare(keyB); + }); + } function getdesignationdata() { return data?.MdmsRes?.["common-masters"]?.Designation.map((ele) => { @@ -146,6 +206,17 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { return keyA.localeCompare(keyB); }); } + function getroledata() { + return data?.MdmsRes?.["ACCESSCONTROL-ROLES"].roles + .map((role) => { + return { code: role.code, name: role?.name ? role?.name : " ", labelKey: "ACCESSCONTROL_ROLES_ROLES_" + role.code }; + }) + .sort((a, b) => { + const labelKeyA = t(a?.labelKey) || ""; + const labelKeyB = t(b?.labelKey) || ""; + return labelKeyA.localeCompare(labelKeyB); + }); + } if (isLoading) { return ; } @@ -154,7 +225,7 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { {assignments?.map((assignment, index) => ( { focusIndex={focusIndex} setFocusIndex={setFocusIndex} getCourtEstablishment={getCourtEstablishment} + getDistrict={getDistrict} courtEstablishment={courtEstablishment} designation={designation} courtroom={courtroom} @@ -170,8 +242,9 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => { getcourtroomdata={getcourtroomdata} assignments={assignments} handleRemoveUnit={handleRemoveUnit} - setCurrentAssiginmentDate={setCurrentAssiginmentDate} - currentassignemtDate={currentassignemtDate} + // setCurrentAssiginmentDate={setCurrentAssiginmentDate} + // currentassignemtDate={currentassignemtDate} + getroledata={getroledata} /> ))}