-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathModule.js
80 lines (71 loc) · 2.67 KB
/
Module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { Loader } from "@egovernments/digit-ui-react-components";
import React, { useState } from "react";
import { useRouteMatch } from "react-router-dom";
import { default as EmployeeApp } from "./pages/employee";
import PaymentsCard from "./components/PaymentsCard";
import { overrideHooks, updateCustomConfigs } from "./utils";
import { ProviderContext } from "./utils/context";
import BoundaryComponent from "./components/sample";
import CampaignNameSelection from "./components/campaign_dropdown";
import CustomInboxSearchComposer from "./components/custom_inbox_composer";
import CustomInboxSearchLinks from "./components/custom_comp/link_section";
import CustomSearchComponent from "./components/custom_comp/search_section";
import CustomFilter from "./components/custom_comp/filter_section";
import CustomInboxTable from "./components/custom_comp/table_inbox";
export const PaymentsModule = ({ stateCode, userType, tenants }) => {
const { path, url } = useRouteMatch();
const tenantId = Digit.ULBService.getCurrentTenantId();
const hierarchyType = window?.globalConfigs?.getConfig("HIERARCHY_TYPE") || "ADMIN";
const moduleCode = ["payments", `boundary-${hierarchyType}`];
const modulePrefix = "hcm";
const language = Digit.StoreData.getCurrentLanguage();
const { isLoading, data: store } = Digit.Services.useStore({
stateCode,
moduleCode,
language,
modulePrefix,
});
let user = Digit?.SessionStorage.get("User");
const { isLoading: isPaymentsModuleInitializing } = Digit.Hooks.payments.usePaymentsInitialization({
tenantId: tenantId,
});
const { isLoading: isMDMSLoading, data: mdmsData } = Digit.Hooks.useCustomMDMS(
Digit.ULBService.getCurrentTenantId(),
"HCM",
[{ name: "paymentsConfig" }],
{
cacheTime: Infinity,
},
{ schemaCode: "PAYMENTS_MASTER_DATA" } //mdmsv2
);
const paymentsConfig = mdmsData?.MdmsRes?.HCM?.paymentsConfig?.[0];
Digit.SessionStorage.set("paymentsConfig", paymentsConfig);
if (isLoading ||isPaymentsModuleInitializing || isMDMSLoading) {
return <Loader />;
} else {
return (
<ProviderContext>
<EmployeeApp path={path} stateCode={stateCode} userType={userType} tenants={tenants} />
</ProviderContext>
);
}
};
const componentsToRegister = {
PaymentsModule,
PaymentsCard,
BoundaryComponent,
CampaignNameSelection,
//
CustomInboxSearchComposer,
CustomInboxSearchLinks,
CustomSearchComponent,
CustomFilter,
CustomInboxTable,
};
export const initPaymentComponents = () => {
overrideHooks();
updateCustomConfigs();
Object.entries(componentsToRegister).forEach(([key, value]) => {
Digit.ComponentRegistryService.setComponent(key, value);
});
};