Skip to content

Commit

Permalink
Updated modules to handle only TQM ( #565 )
Browse files Browse the repository at this point in the history
Updated modules to handle only TQM
  • Loading branch information
anilsingha-eGov authored May 16, 2024
2 parents b51a795 + 72e36b8 commit 1f5a7a4
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 67 deletions.
107 changes: 63 additions & 44 deletions frontend/micro-ui/web/micro-ui-internals/example/src/index.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,74 @@
import React from "react";
import ReactDOM from "react-dom";

import { initLibraries } from "@egovernments/digit-ui-libraries";
import { initFSMLibraries } from "@egovernments/digit-ui-fsm-libraries";
import { PaymentModule, PaymentLinks, paymentConfigs } from "@egovernments/digit-ui-module-common";
import { initDSSComponents } from "@egovernments/digit-ui-module-dss";
import { initFSMComponents } from "@egovernments/digit-ui-module-fsm";
import { initEngagementComponents } from "@egovernments/digit-ui-module-engagement";
import { DigitUI,initCoreComponents } from "@egovernments/digit-ui-module-core";
import { HRMSModule, initHRMSComponents } from "@egovernments/digit-ui-module-hrms";
import { initUtilitiesComponents } from "@egovernments/digit-ui-module-utilities";
import { initTQMComponents } from '@egovernments/digit-ui-module-tqm'
import { UICustomizations } from "./UICustomizations";
import "@egovernments/digit-ui-fsm-css/example/index.css";
import React from 'react';
import ReactDOM from 'react-dom';

import { initLibraries } from '@egovernments/digit-ui-libraries';
import { initFSMLibraries } from '@egovernments/digit-ui-fsm-libraries';
import {
PaymentModule,
PaymentLinks,
paymentConfigs,
} from '@egovernments/digit-ui-module-common';
import { initDSSComponents } from '@egovernments/digit-ui-module-dss';
import { initFSMComponents } from '@egovernments/digit-ui-module-fsm';
import { initEngagementComponents } from '@egovernments/digit-ui-module-engagement';
import {
DigitUI,
initCoreComponents,
} from '@egovernments/digit-ui-module-core';
import {
HRMSModule,
initHRMSComponents,
} from '@egovernments/digit-ui-module-hrms';
import { initUtilitiesComponents } from '@egovernments/digit-ui-module-utilities';
import { initTQMComponents } from '@egovernments/digit-ui-module-tqm';
import { UICustomizations } from './UICustomizations';
import '@egovernments/digit-ui-fsm-css/example/index.css';

var Digit = window.Digit || {};

const enabledModules = [
// "DSS",
// "Works",
// "HRMS",
// "Payment",
// "FSM",
// "Utilities",
"Tqm",
// "Engagement"
];
const enabledModules = ['Tqm'];

const initTokens = (stateCode) => {
const userType = window.sessionStorage.getItem("userType") || process.env.REACT_APP_USER_TYPE || "CITIZEN";
const userType =
window.sessionStorage.getItem('userType') ||
process.env.REACT_APP_USER_TYPE ||
'CITIZEN';

const token = window.localStorage.getItem("token") || process.env[`REACT_APP_${userType}_TOKEN`];
const token =
window.localStorage.getItem('token') ||
process.env[`REACT_APP_${userType}_TOKEN`];

const citizenInfo = window.localStorage.getItem("Citizen.user-info");
const citizenInfo = window.localStorage.getItem('Citizen.user-info');

const citizenTenantId = window.localStorage.getItem("Citizen.tenant-id") || stateCode;
const citizenTenantId =
window.localStorage.getItem('Citizen.tenant-id') || stateCode;

const employeeInfo = window.localStorage.getItem("Employee.user-info");
const employeeTenantId = window.localStorage.getItem("Employee.tenant-id");
const employeeInfo = window.localStorage.getItem('Employee.user-info');
const employeeTenantId = window.localStorage.getItem('Employee.tenant-id');

const userTypeInfo = userType === "CITIZEN" || userType === "QACT" ? "citizen" : "employee";
window.Digit.SessionStorage.set("user_type", userTypeInfo);
window.Digit.SessionStorage.set("userType", userTypeInfo);
const userTypeInfo =
userType === 'CITIZEN' || userType === 'QACT' ? 'citizen' : 'employee';
window.Digit.SessionStorage.set('user_type', userTypeInfo);
window.Digit.SessionStorage.set('userType', userTypeInfo);

if (userType !== "CITIZEN") {
window.Digit.SessionStorage.set("User", {
if (userType !== 'CITIZEN') {
window.Digit.SessionStorage.set('User', {
access_token: token,
info: userType !== "CITIZEN" ? JSON.parse(employeeInfo) : citizenInfo,
info: userType !== 'CITIZEN' ? JSON.parse(employeeInfo) : citizenInfo,
});
} else {
// if (!window.Digit.SessionStorage.get("User")?.extraRoleInfo) window.Digit.SessionStorage.set("User", { access_token: token, info: citizenInfo });
}

window.Digit.SessionStorage.set("Citizen.tenantId", citizenTenantId);
window.Digit.SessionStorage.set('Citizen.tenantId', citizenTenantId);

if (employeeTenantId && employeeTenantId.length) window.Digit.SessionStorage.set("Employee.tenantId", employeeTenantId);
if (employeeTenantId && employeeTenantId.length)
window.Digit.SessionStorage.set('Employee.tenantId', employeeTenantId);
};

const initDigitUI = () => {
window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH") || "sanitation-ui";
window.contextPath =
window?.globalConfigs?.getConfig('CONTEXT_PATH') || 'sanitation-ui';

window.Digit.ComponentRegistryService.setupRegistry({
...paymentConfigs,
Expand All @@ -74,12 +84,13 @@ const initDigitUI = () => {
initHRMSComponents();
initFSMComponents();
initUtilitiesComponents();

const moduleReducers = (initData) => initData;
window.Digit.Customizations = {
TL: {
customiseCreateFormData: (formData, licenceObject) => licenceObject,
customiseRenewalCreateFormData: (formData, licenceObject) => licenceObject,
customiseRenewalCreateFormData: (formData, licenceObject) =>
licenceObject,
customiseSendbackFormData: (formData, licenceObject) => licenceObject,
},
commonUiConfig: UICustomizations,
Expand All @@ -88,11 +99,19 @@ const initDigitUI = () => {
//calling it here so that UICustomizations inside tqm gets added after the common Customizations are added
initTQMComponents();

const stateCode = window?.globalConfigs?.getConfig("STATE_LEVEL_TENANT_ID") || "pb";
const stateCode =
window?.globalConfigs?.getConfig('STATE_LEVEL_TENANT_ID') || 'pb';
initTokens(stateCode);

const registry = window?.Digit.ComponentRegistryService.getRegistry();
ReactDOM.render(<DigitUI stateCode={stateCode} enabledModules={enabledModules} moduleReducers={moduleReducers} />, document.getElementById("root"));
ReactDOM.render(
<DigitUI
stateCode={stateCode}
enabledModules={enabledModules}
moduleReducers={moduleReducers}
/>,
document.getElementById('root')
);
};

initLibraries().then(() => {
Expand Down
59 changes: 36 additions & 23 deletions frontend/micro-ui/web/src/App.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
import React from "react";

import { initDSSComponents } from "@egovernments/digit-ui-module-dss";
import { DigitUI,initCoreComponents } from "@egovernments/digit-ui-module-core";
import { initLibraries } from "@egovernments/digit-ui-libraries";
import { initEngagementComponents } from "@egovernments/digit-ui-module-engagement";
import { initFSMLibraries } from "@egovernments/digit-ui-fsm-libraries";

import { initFSMComponents } from "@egovernments/digit-ui-module-fsm";
import { initTQMComponents } from "@egovernments/digit-ui-module-tqm";
import { initHRMSComponents } from "@egovernments/digit-ui-module-hrms";
import { PaymentModule, PaymentLinks, paymentConfigs } from "@egovernments/digit-ui-module-common";
import { initUtilitiesComponents } from "@egovernments/digit-ui-module-utilities";
import { UICustomizations } from "./Customisations/UICustomizations";

window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH");
import React from 'react';

import { initDSSComponents } from '@egovernments/digit-ui-module-dss';
import {
DigitUI,
initCoreComponents,
} from '@egovernments/digit-ui-module-core';
import { initLibraries } from '@egovernments/digit-ui-libraries';
import { initEngagementComponents } from '@egovernments/digit-ui-module-engagement';
import { initFSMLibraries } from '@egovernments/digit-ui-fsm-libraries';

import { initFSMComponents } from '@egovernments/digit-ui-module-fsm';
import { initTQMComponents } from '@egovernments/digit-ui-module-tqm';
import { initHRMSComponents } from '@egovernments/digit-ui-module-hrms';
import {
PaymentModule,
PaymentLinks,
paymentConfigs,
} from '@egovernments/digit-ui-module-common';
import { initUtilitiesComponents } from '@egovernments/digit-ui-module-utilities';
import { UICustomizations } from './Customisations/UICustomizations';

window.contextPath = window?.globalConfigs?.getConfig('CONTEXT_PATH');
window.Digit.Customizations = {
commonUiConfig: UICustomizations
commonUiConfig: UICustomizations,
};

initLibraries();
initFSMLibraries();

const enabledModules = ["Payment", "DSS", "Engagement", "HRMS","Tqm","Utilities"];
const enabledModules = ['Tqm'];
window.Digit.ComponentRegistryService.setupRegistry({
...paymentConfigs,
PaymentModule,
Expand All @@ -34,21 +41,27 @@ initFSMComponents();
initHRMSComponents();
initUtilitiesComponents();


const moduleReducers = (initData) => ({
initData,
});


//calling it here so that UICustomizations inside tqm gets added after the common Customizations are added
initTQMComponents();
function App() {
window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH");
const stateCode = window.globalConfigs?.getConfig("STATE_LEVEL_TENANT_ID") || process.env.REACT_APP_STATE_LEVEL_TENANT_ID;
window.contextPath = window?.globalConfigs?.getConfig('CONTEXT_PATH');
const stateCode =
window.globalConfigs?.getConfig('STATE_LEVEL_TENANT_ID') ||
process.env.REACT_APP_STATE_LEVEL_TENANT_ID;
if (!stateCode) {
return <h1>stateCode is not defined</h1>;
}
return <DigitUI stateCode={stateCode} enabledModules={enabledModules} moduleReducers={moduleReducers} />;
return (
<DigitUI
stateCode={stateCode}
enabledModules={enabledModules}
moduleReducers={moduleReducers}
/>
);
}

export default App;

0 comments on commit 1f5a7a4

Please sign in to comment.