Skip to content

Commit

Permalink
hrms changes (#1367)
Browse files Browse the repository at this point in the history
* hrms changes

* removed console log

* review changes

---------

Co-authored-by: nabeelmd-eGov <[email protected]>
  • Loading branch information
mithunhegde-egov and nabeelmd-eGov authored Sep 6, 2024
1 parent fb46da8 commit 6b93638
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ const Assignments = ({ t, config, onSelect, userType, formData }) => {
const [focusIndex, setFocusIndex] = useState(-1);

function getdepartmentdata() {
return data?.MdmsRes?.["common-masters"]?.Department.map((ele) => {
return data?.MdmsRes?.["common-masters"]?.Department?.map((ele) => {
ele["i18key"] = t("COMMON_MASTERS_DEPARTMENT_" + ele.code);
return ele;
});
}
function getdesignationdata() {
return data?.MdmsRes?.["common-masters"]?.Designation.map((ele) => {
return data?.MdmsRes?.["common-masters"]?.Designation?.map((ele) => {
ele["i18key"] = t("COMMON_MASTERS_DESIGNATION_" + ele.code);
return ele;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { CardLabel, Dropdown, LabelFieldPair, Loader, RemoveableTag ,MultiSelectDropdown} from "@egovernments/digit-ui-react-components";
import { CardLabel, Dropdown, LabelFieldPair, Loader, RemoveableTag, MultiSelectDropdown } from "@egovernments/digit-ui-react-components";
import React, { useEffect, useState } from "react";
import cleanup from "../Utils/cleanup";
// import MultiSelectDropdown from "./Multiselect";

const makeDefaultValues = (sessionFormData) => {
return sessionFormData?.Jurisdictions?.map((ele,index)=>{
return sessionFormData?.Jurisdictions?.map((ele, index) => {
return {
key: index,
hierarchy: {
code: ele?.hierarchy,
name: ele?.hierarchy,
},
boundaryType: { label: ele?.boundaryType, i18text:ele.boundaryType ?`EGOV_LOCATION_BOUNDARYTYPE_${ele.boundaryType?.toUpperCase()}`:null },
boundaryType: { label: ele?.boundaryType, i18text: ele.boundaryType ? `EGOV_LOCATION_BOUNDARYTYPE_${ele.boundaryType?.toUpperCase()}` : null },
boundary: { code: ele?.boundary },
roles: ele?.roles,
}
Expand All @@ -24,10 +24,10 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => {
const { data: data = {}, isLoading } = Digit.Hooks.hrms.useHrmsMDMS(tenantId, "egov-hrms", "HRMSRolesandDesignation") || {};

const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {});
const [sessionFormData,setSessionFormData, clearSessionFormData] = employeeCreateSession;
const [sessionFormData, setSessionFormData, clearSessionFormData] = employeeCreateSession;
const isEdit = window.location.href.includes("hrms/edit")
const [jurisdictions, setjurisdictions] = useState(
!isEdit && sessionFormData?.Jurisdictions?.length>0 ? makeDefaultValues(sessionFormData) : ( formData?.Jurisdictions || [
!isEdit && sessionFormData?.Jurisdictions?.length > 0 ? makeDefaultValues(sessionFormData) : (formData?.Jurisdictions || [
{
id: undefined,
key: 1,
Expand All @@ -51,7 +51,7 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => {
};
res = cleanup(res);
if (jurisdiction?.roles) {
res["roles"] = jurisdiction?.roles.map((ele) => {
res["roles"] = jurisdiction?.roles?.map((ele) => {
delete ele.description;
return ele;
});
Expand Down Expand Up @@ -113,15 +113,15 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => {
const [focusIndex, setFocusIndex] = useState(-1);

function gethierarchylistdata() {
return data?.MdmsRes?.["egov-location"]["TenantBoundary"].map((ele) => ele.hierarchyType);
return data?.MdmsRes?.["egov-location"]["TenantBoundary"]?.map((ele) => ele.hierarchyType);
}

function getboundarydata() {
return [];
}

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 } });
return data?.MdmsRes?.["ACCESSCONTROL-ROLES"]?.roles?.map(role => { return { code: role.code, name: role?.name ? role?.name : " ", labelKey: 'ACCESSCONTROL_ROLES_ROLES_' + role.code } });
}

if (isLoading) {
Expand Down Expand Up @@ -169,8 +169,11 @@ function Jurisdiction({
roleoption,
index,
}) {


const [BoundaryType, selectBoundaryType] = useState([]);
const [Boundary, selectboundary] = useState([]);
const cities = window.globalPath === "sandbox-ui" ? Digit.Hooks.pgr.useTenants() : null;
useEffect(() => {
selectBoundaryType(
data?.MdmsRes?.["egov-location"]["TenantBoundary"]
Expand All @@ -181,10 +184,49 @@ function Jurisdiction({
);
}, [jurisdiction?.hierarchy, data?.MdmsRes]);
const tenant = Digit.ULBService.getCurrentTenantId();
let requestCriteria = null;

requestCriteria = {
url: "/tenant-management/tenant/_search",
params: {
code: Digit.ULBService.getCurrentTenantId(),
includeSubTenants: true
},
body: {
"inbox": {
"limit": 10,
"offset": 0
},
apiOperation: "SEARCH",
},
config: {
select: (data) => {
return data?.Tenants;
},
},
};

// Use the requestCriteria only if it's not null
const { data: subTenants, refetch, isLoading: isLoadingSubTenants } = requestCriteria
? Digit.Hooks.useCustomAPIHook(requestCriteria)
: { data: null, refetch: () => { }, isLoading: false };

// Now you can use subTenants, refetch, and isLoadingSubTenants

const getSubTenants = () => subTenants?.filter((e) => e.code === Digit.ULBService.getCurrentTenantId()) || [];
const subTenantList = getSubTenants();

useEffect(() => {
selectboundary(data?.MdmsRes?.tenant?.tenants.filter(city => city.code != Digit.ULBService.getStateId()).map(city => { return { ...city, i18text: Digit.Utils.locale.getCityLocale(city.code) } }));
if (window.globalPath === 'sandbox-ui') {
selectboundary(subTenantList);
}
else {
selectboundary(data?.MdmsRes?.tenant?.tenants.filter(city => city.code != Digit.ULBService.getStateId()).map(city => { return { ...city, i18text: Digit.Utils.locale.getCityLocale(city.code) } }));
}
}, [jurisdiction?.boundaryType, data?.MdmsRes]);



useEffect(() => {
if (Boundary?.length > 0) {
selectedboundary(Boundary?.filter((ele) => ele.code == jurisdiction?.boundary?.code)[0]);
Expand Down Expand Up @@ -217,7 +259,7 @@ function Jurisdiction({
res.push(ob?.[1]);
});

res?.forEach(resData => {resData.labelKey = 'ACCESSCONTROL_ROLES_ROLES_' + resData.code})
res?.forEach(resData => { resData.labelKey = 'ACCESSCONTROL_ROLES_ROLES_' + resData.code })

setjurisdictions((pre) => pre.map((item) => (item.key === jurisdiction.key ? { ...item, roles: res } : item)));
};
Expand Down Expand Up @@ -283,7 +325,7 @@ function Jurisdiction({
disable={Boundary?.length === 0}
option={Boundary}
select={selectedboundary}
optionKey="i18text"
optionKey={Digit.Utils.getMultiRootTenant() ? "code" : "i18text"}
t={t}
/>
</LabelFieldPair>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ const CreateEmployee = () => {




const onSubmit = (data) => {
if (data.Jurisdictions.filter(juris => juris.tenantId == tenantId).length == 0) {
setShowToast({ key: true, label: "ERR_BASE_TENANT_MANDATORY" });
Expand Down

0 comments on commit 6b93638

Please sign in to comment.