Skip to content

Commit

Permalink
Hrms emp deactivate (#1589)
Browse files Browse the repository at this point in the history
* home screen was breaking due to missing optional chaining

* hrms bugfixes

* Update login.js

* boundary updated for employee create

* hrms employee bug fixes and boundary changes

* url updated

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
  • Loading branch information
mithunhegde-egov and jagankumar-egov authored Oct 21, 2024
1 parent b47f4bb commit 299e6f5
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ const receiptsAccess = () => {
const RECEIPTS_ACCESS = userRoles?.filter((role) => receiptsRoles?.includes(role));
return RECEIPTS_ACCESS?.length > 0;
};
const hrmsRoles = ["HRMS_ADMIN","SUPERUSER"];
const hrmsRoles = ["HRMS_ADMIN","SUPERUSER", "ADMIN"];
const hrmsAccess = () => {
const userInfo = Digit.UserService.getUser();
const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ export const RoleBasedEmployeeHome = ({ modules, additionalComponent }) => {
links: Digit.Utils.getMultiRootTenant() ? getFilteredLinks(moduleData) : moduleData?.links,
centreChildren: [
<div>{t(Digit.Utils.locale.getTransformedLocale(`MODULE_CARD_DESC_${current}`))}</div>,
userManual && (
howItWorks && (
<Button
variation="teritiary"
label={userManual?.label}
icon={userManual?.icon}
label={howItWorks?.label}
icon={howItWorks?.icon}
type="button"
size={"medium"}
onClick={() => window.open(userManual?.link, "_blank")}
onClick={() => window.open(howItWorks?.link, "_blank")}
style={{ padding: "0px" }}
/>
),
Expand All @@ -197,14 +197,14 @@ export const RoleBasedEmployeeHome = ({ modules, additionalComponent }) => {
style={{ padding: "0px" }}
/>
),
howItWorks && (
userManual && (
<Button
variation="teritiary"
label={howItWorks?.label}
icon={howItWorks?.icon}
label={userManual?.label}
icon={userManual?.icon}
type="button"
size={"medium"}
onClick={() => window.open(howItWorks?.link, "_blank")}
onClick={() => window.open(userManual?.link, "_blank")}
style={{ padding: "0px" }}
/>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const sandboxConfig = {
heading: "SANDBOX_HEADING",
url: "https://www.youtube.com/watch?v=1ZLdetJwfeY",
url: "https://www.youtube.com/watch?v=0wcuD67MVt8",
subsections: [
{
title: "SANDBOX_INTRODUCTION_TITLE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Header from "../../../components/Header";

/* set employee details to enable backward compatiable */
const setEmployeeDetail = (userObject, token) => {
if (Digit.Utils.getMultiRootTenant()) {
return;
}
if (Digit.Utils.getMultiRootTenant()) {
return;
}
let locale = JSON.parse(sessionStorage.getItem("Digit.locale"))?.value || Digit.Utils.getDefaultLanguage();
localStorage.setItem("Employee.tenant-id", userObject?.tenantId);
localStorage.setItem("tenant-id", userObject?.tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const EmployeeAction = ({ t, action, tenantId, closeModal, submitAction, applica
const [Reasons, setReasons] = useState([]);
const [selectedReason, selecteReason] = useState("");
const tenant = Digit.ULBService.getStateId() || tenantId?.split(".")?.[0];
const mutationUpdate = Digit.Hooks.hrms.useHRMSUpdate(tenantId);

const { isLoading, isError, errors, data, ...rest } = Digit.Hooks.hrms.useHrmsMDMS(tenant, "egov-hrms", "DeactivationReason");

useEffect(() => {
Expand Down Expand Up @@ -129,6 +131,22 @@ const EmployeeAction = ({ t, action, tenantId, closeModal, submitAction, applica
set(Employees[0], 'deactivationDetails[0].remarks', data?.remarks);

Employees[0].isActive = false;
mutationUpdate.mutate(
{
Employees: Employees,
},
{
onError: (error, variables) => {
setShowToast({
key: "error",
label: error?.response?.data?.Errors?.[0]?.code ? error?.response?.data?.Errors?.[0]?.code : "HRMS_CREATE_ERROR",
});
},
onSuccess: async (data) => {
navigateToAcknowledgement({ id: data?.Employees?.[0]?.code, message: "HRMS_UPDATE_EMPLOYEE_RESPONSE_MESSAGE" });
},
}
);
history.replace( `/${window?.contextPath}/employee/hrms/response`, { Employees, key: "UPDATE", action: "DEACTIVATION" });
} else {
if (file) {
Expand All @@ -146,6 +164,23 @@ const EmployeeAction = ({ t, action, tenantId, closeModal, submitAction, applica
set(Employees[0], 'reactivationDetails[0].remarks', data?.remarks);
Employees[0].isActive = true;

mutationUpdate.mutate(
{
Employees: Employees,
},
{
onError: (error, variables) => {
setShowToast({
key: "error",
label: error?.response?.data?.Errors?.[0]?.code ? error?.response?.data?.Errors?.[0]?.code : "HRMS_CREATE_ERROR",
});
},
onSuccess: async (data) => {
navigateToAcknowledgement({ id: data?.Employees?.[0]?.code, message: "HRMS_UPDATE_EMPLOYEE_RESPONSE_MESSAGE" });
},
}
);

history.replace( `/${window?.contextPath}/employee/hrms/response`, { Employees, key: "UPDATE", action: "ACTIVATION" });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => {
const tenantId = Digit.ULBService.getCurrentTenantId();
const [inactiveJurisdictions, setInactiveJurisdictions] = useState([]);
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 isEdit = window.location.href.includes("hrms/edit")
Expand Down Expand Up @@ -173,7 +172,7 @@ function Jurisdiction({

const [BoundaryType, selectBoundaryType] = useState([]);
const [Boundary, selectboundary] = useState([]);
const cities = Digit.Utils.getMultiRootTenant() ? Digit.Hooks.pgr.useTenants() : null;
const { data: cities, isCityLoading } = Digit.Hooks.useTenants();
useEffect(() => {
selectBoundaryType(
data?.MdmsRes?.["egov-location"]["TenantBoundary"]
Expand All @@ -192,16 +191,17 @@ function Jurisdiction({
enabled: Digit.Utils.getMultiRootTenant()
}
});
const getSubTenants = () => TenantMngmtSearch?.filter((e) => e.code === Digit.ULBService.getCurrentTenantId()) || [];
const subTenantList = getSubTenants();
// const getSubTenants = () => TenantMngmtSearch?.filter((e) => e.code === Digit.ULBService.getCurrentTenantId()) || [];
// const subTenantList = getSubTenants();

useEffect(() => {
if (Digit.Utils.getMultiRootTenant()) {
selectboundary(subTenantList);
selectboundary(cities);
}
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]);
}, [jurisdiction?.boundaryType, data?.MdmsRes, cities]);



Expand Down Expand Up @@ -303,7 +303,7 @@ function Jurisdiction({
disable={Boundary?.length === 0}
option={Boundary}
select={selectedboundary}
optionKey={Digit.Utils.getMultiRootTenant() ? "code" : "i18text"}
optionKey={Digit.Utils.getMultiRootTenant() ? "code" : "i18nkey"}
t={t}
/>
</LabelFieldPair>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const EditForm = ({ tenantId, data }) => {
name: ele.hierarchy,
},
boundaryType: { label: ele.boundaryType, i18text: `EGOV_LOCATION_BOUNDARYTYPE_${ele.boundaryType.toUpperCase()}` },
boundary: { code: ele.boundary },
boundary: Digit.Utils.getMultiRootTenant()?{ code: tenantId }:{ code: ele.boundary },
roles: data?.user?.roles.filter((item) => item.tenantId == ele.boundary),
});
}),
Expand Down Expand Up @@ -164,10 +164,18 @@ const EditForm = ({ tenantId, data }) => {
};

const onSubmit = (input) => {
if (input.Jurisdictions.filter((juris) => juris.tenantId == tenantId && juris.isActive !== false).length == 0) {
setShowToast({ key: true, label: "ERR_BASE_TENANT_MANDATORY" });
return;
}
// if (input.Jurisdictions.filter((juris) => juris.tenantId == tenantId && juris.isActive !== false).length == 0) {
// setShowToast({ key: true, label: "ERR_BASE_TENANT_MANDATORY" });
// return;
// }
input.Jurisdictions = input?.Jurisdictions?.map((juris) => {
return {
...juris,
boundary: tenantId,
tenantId: tenantId,
};
});

if (
!Object.values(
input.Jurisdictions.reduce((acc, sum) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,18 @@ const CreateEmployee = () => {
history.replace(`/${window?.contextPath}/employee/hrms/response?isSuccess=true`, { id, message, showID: true, showChildren: false });
};



const onSubmit = async (data) => {
const hasCurrentAssignment = data?.Assignments?.some(assignment => assignment?.isCurrentAssignment === true);
const hasCurrentAssignment = data?.Assignments?.some(assignment => assignment?.isCurrentAssignment === true);
let selectedCity= data?.Jurisdictions?.boundary;
data.Jurisdictions = data?.Jurisdictions?.map((juris) => {
return {
...juris,
boundary: tenantId,
tenantId: tenantId,
};
});
// If no current assignment, throw an error
if(!canSubmit){
setShowToast({ key: "error", label: "ERR_ALL_MANDATORY_FIELDS" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const CreateComplaint = ({ parentUrl }) => {

const cityData = getCities();


const { isLoading: hierarchyLOading, data: hierarchyType } = Digit.Hooks.useCustomMDMS(
Digit.ULBService.getStateId(),
"sandbox-ui",
Expand Down

0 comments on commit 299e6f5

Please sign in to comment.