Skip to content

Commit

Permalink
sandbox enhancement (#1411)
Browse files Browse the repository at this point in the history
* Added CustomErrorComponent, RoleBasedEmployeeHome, css enhancement

* added new localisation module

* upgrade ui component version

* adding coutn check of master

* adding count check of master

---------

Co-authored-by: NabeelAyubee <[email protected]>
  • Loading branch information
nabeelmd-eGov and NabeelAyubee authored Sep 20, 2024
1 parent ff2e006 commit 78eecd1
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
font-size: 0.8rem;
}


.sandbox-signup-form {
.digit-employee-card.signupCardClassName {
display: flex;
Expand Down Expand Up @@ -293,6 +292,18 @@
color: unset !important;
}
}
.digit-card-component.sandboxSetupMasterInfo {
.h1.headerFlex {
display: flex;
gap: 1rem;
align-items: center;
}
.digit-card-header.subHeader {
font-size: 1.5rem;
font-weight: 700;
color: unset !important;
}
}
.digit-card-header.setupMaster-subheading {
font-size: 1.5rem;
color: unset !important;
Expand Down Expand Up @@ -374,21 +385,21 @@ digit-card-text.center {
text-align: center;
}

.pgr-citizen-wrapper{
.applications-list-container{
.card{
.date-wrap{
.pgr-citizen-wrapper {
.applications-list-container {
.card {
.date-wrap {
align-items: center;
justify-content: flex-start;
}
}
}
}

.pgr-citizen-wrapper{
.applications-list-container{
.card{
.status-highlight{
.pgr-citizen-wrapper {
.applications-list-container {
.card {
.status-highlight {
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -397,7 +408,6 @@ digit-card-text.center {
}
}


.overlay {
position: fixed;
top: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { useIndividualView } from "./useIndividualView";
import utils from "../utils";
import useDefaultMasterHandler from "./useDefaultMasterHandler";
import { useGetMasterDataCount } from "./useGetMasterDataCount";

const sandbox = {
useIndividualView,
useDefaultMasterHandler,
useGetMasterDataCount,
};

const Hooks = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useQuery } from "react-query";
const getMasterDataCountService = async ({ filter, tenantId }) => {
try {
const response = await Digit.CustomService.getResponse({
url: "/mdms-v2/v1/_count",
body: {
MdmsCriteria: {
tenantId: tenantId,
moduleDetails: filter,
},
},
params: {},
});
return response;
} catch (error) {
throw new Error(error?.response?.data?.Errors?.[0].description);
}
};

export const useGetMasterDataCount = ({ filter, tenantId, config = {} }) => {
return useQuery(["GET_MASTER_DATA_COUNT"], () => getMasterDataCountService({ filter, tenantId }), config);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, useMemo, useState } from "react";
import React, { Fragment, useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { Header, Table } from "@egovernments/digit-ui-react-components";
import { Button, Card, CardHeader, CardText, Loader, PopUp, SVG } from "@egovernments/digit-ui-components";
Expand All @@ -15,31 +15,73 @@ const SetupMaster = () => {
const module = searchParams.get("module");
const key = searchParams.get("key");
const [showPopUp, setShowPopUp] = useState(null);
const [filters, setFilters] = useState(null);
const [isUserExist, setIsUserExist] = useState(null);
const config = useMemo(() => {
return setupMasterConfig?.SetupMaster?.filter((item) => item.module === module)?.[0];
}, [module]);
return setupMasterConfig(isUserExist)?.SetupMaster?.filter((item) => item.module === module)?.[0];
}, [module, isUserExist]);

const { isLoading: moduleMasterLoading, data: moduleMasterData } = Digit.Hooks.useCustomMDMS(
tenantId,
"sandbox-ui",
[{ name: "ModuleMasterConfig" }],
{
select: (data) => {
let xx = data?.["sandbox-ui"]?.ModuleMasterConfig?.filter((item) => item?.module === module)?.[0]?.master?.filter(
let respStructure = data?.["sandbox-ui"]?.ModuleMasterConfig?.filter((item) => item?.module === module)?.[0]?.master?.filter(
(item) => item.type === "module" || item.type === "common" || item.type === "boundary"
);
let respData = xx.map((i) => ({
const respData = respStructure.map((i) => ({
masterName: t(i.code),
type: t(i.type),
description: t(`SANDBOX_MASTER_SETUP_DESC_${i.code}`),
}));
return respData;
const moduleMasterPayload = respStructure
?.filter((i) => i.type === "common" || i.type === "module")
?.map((item) => {
return {
moduleName: item?.code?.split(".")?.[0],
masterDetails: [
{
name: item?.code?.split(".")?.[1],
},
],
};
});
return { respData, moduleMasterPayload };
},
enabled: true,
}
// true
);

useEffect(() => {
if (!moduleMasterLoading && moduleMasterData?.moduleMasterPayload) {
setFilters(moduleMasterData?.moduleMasterPayload);
}
}, [moduleMasterData, moduleMasterLoading]);

const { isLoading: masterCountLoading, data: masterCount } = Digit.Hooks.sandbox.useGetMasterDataCount({
tenantId: tenantId,
filter: filters,
config: {
enabled: Boolean(filters),
select: (data) => {
const resp = data?.MdmsRes;
const checkMasterDataCompleteness = Object.values(resp).every((category) =>
Object.values(category).every((items) => items.every((item) => parseInt(item.count) > 0))
);

return checkMasterDataCompleteness;
},
},
});

useEffect(() => {
if (!masterCountLoading) {
setIsUserExist(masterCount);
}
}, [masterCountLoading, masterCount]);

const { mutate: useDefaultMasterHandler } = Digit.Hooks.sandbox.useDefaultMasterHandler(tenantId);

const handleSetupMaster = async () => {
Expand Down Expand Up @@ -82,7 +124,7 @@ const SetupMaster = () => {
);
};

if (moduleMasterLoading) {
if (moduleMasterLoading && masterCountLoading) {
return <Loader />;
}
return (
Expand All @@ -105,7 +147,7 @@ const SetupMaster = () => {
<div className="setupMasterSetupActionBar">
<Button
className="actionButton"
label={t(config.actionText)}
label={isUserExist ? t(`EDIT_MASTER`) : t(config.actionText)}
variation={"secondary"}
icon="ArrowForward"
isSuffix={true}
Expand All @@ -131,7 +173,7 @@ const SetupMaster = () => {
customTableWrapperClassName={"dss-table-wrapper"}
disableSort={true}
autoSort={false}
data={moduleMasterData}
data={moduleMasterData?.respData}
totalRecords={5}
columns={[
{
Expand Down Expand Up @@ -191,14 +233,17 @@ const SetupMaster = () => {
<div className="setupMasterSetupActionBar">
<Button
className="actionButton"
label={t("SETUP_MASTER")}
label={isUserExist ? t("EDIT_MASTER") : t("SETUP_MASTER")}
variation={"secondary"}
icon="ArrowForward"
isSuffix={true}
onClick={(e) => {
e.preventDefault();
handleSetupMaster();
// history.push(`/${window?.contextPath}/employee/sandbox/application-management/module?module=${module}`);
if (isUserExist) {
history.push(`/${window?.contextPath}/employee/sandbox/application-management/module?module=${module}`);
} else {
handleSetupMaster();
}
}}
></Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const setupMasterConfig = {
export const setupMasterConfig = (existingUser = false) => ({
tenantId: "pg",
moduleName: "commonUiConfig",
SetupMaster: [
Expand All @@ -8,7 +8,7 @@ export const setupMasterConfig = {
active: true,
description: "COMPLAINT_MANAGEMENT_DESCRIPTION",
masterDescription: "COMPLAINT_MANAGEMENT_SETUP_MASTER_DESCRIPTION",
actionText: "SETUP_NOW",
actionText: existingUser ? "EDIT_NOW" : "SETUP_NOW",
features: [
{
id: 1,
Expand Down Expand Up @@ -46,7 +46,7 @@ export const setupMasterConfig = {
active: true,
description: "HCM_DESCRIPTION",
masterDescription: "HCM_SETUP_MASTER_DESCRIPTION",
actionText: "SETUP_NOW",
actionText: existingUser ? "EDIT_NOW" : "SETUP_NOW",
features: [
{
id: 1,
Expand All @@ -60,7 +60,7 @@ export const setupMasterConfig = {
active: true,
description: "HRMS_DESCRIPTION",
masterDescription: "HRMS_SETUP_MASTER_DESCRIPTION",
actionText: "SETUP_NOW",
actionText: existingUser ? "EDIT_NOW" : "SETUP_NOW",
features: [
{
id: 1,
Expand All @@ -77,4 +77,4 @@ export const setupMasterConfig = {
],
},
],
};
});

0 comments on commit 78eecd1

Please sign in to comment.