Skip to content

Commit

Permalink
FEATURE/HCMPRE-2208 :: Fixed the default landing for console user
Browse files Browse the repository at this point in the history
  • Loading branch information
jagankumar-egov authored Feb 3, 2025
1 parent 6dfd8c8 commit 00199c6
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 19 deletions.
83 changes: 67 additions & 16 deletions health/micro-ui/web/console/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
*/
import React from "react";
import { initLibraries } from "@egovernments/digit-ui-libraries";
import { Loader } from "@egovernments/digit-ui-components";
import { DigitUI } from "@egovernments/digit-ui-module-core";
// import { initHRMSComponents } from "@egovernments/digit-ui-module-hrms";
import { UICustomizations } from "./Customisations/UICustomizations";
import { initCampaignComponents } from "@egovernments/digit-ui-module-campaign-manager"
import { initWorkbenchComponents } from "@egovernments/digit-ui-module-workbench";
import { initCampaignComponents } from "@egovernments/digit-ui-module-campaign-manager"

window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH");

Expand All @@ -26,41 +26,92 @@ const enabledModules = [
"HCMWORKBENCH",
"Campaign"
];
const HCM_MODULE_NAME = "console";
export const OverrideUICustomizations = {
HCM_MODULE_NAME,
}
const setupLibraries = (Library, service, method) => {
window.Digit = window.Digit || {};
window.Digit[Library] = window.Digit[Library] || {};
window.Digit[Library][service] = method;
};
/* To Overide any existing config/middlewares we need to use similar method */
const updateCustomConfigs = () => {
setupLibraries("Customizations", "commonUiConfig", { ...window?.Digit?.Customizations?.commonUiConfig, ...OverrideUICustomizations });
};


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

const initDigitUI = () => {
window.Digit.ComponentRegistryService.setupRegistry({});
window.Digit.Customizations = {
PGR: {},
commonUiConfig: UICustomizations,
};
// initHRMSComponents();
initWorkbenchComponents();
initCampaignComponents();

try {
window.Digit.ComponentRegistryService.setupRegistry({});
window.Digit.Customizations = {
PGR: {},
commonUiConfig: UICustomizations,
};
// initHRMSComponents();
initWorkbenchComponents();
initCampaignComponents();
updateCustomConfigs();
} catch (error) {
console.error('Failed to initialize DigitUI:', error);
// Consider showing a user-friendly error message
}
};
let initializationError = null;

const handleInitError = (error) => {
console.error('Failed to initialize libraries:', error);
initializationError = error;
};

initLibraries().then(() => {
initDigitUI();
});
}).catch(handleInitError);



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;

const [stateCode, setStateCode] = React.useState(null);

const [isLoading, setIsLoading] = React.useState(true);
React.useEffect(() => {
// Add any necessary initialization checks here
window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH");
const code =
window.globalConfigs?.getConfig("STATE_LEVEL_TENANT_ID") ||
process.env.REACT_APP_STATE_LEVEL_TENANT_ID;
setStateCode(code);
setIsLoading(false);
}, []);

if (isLoading) {
return <Loader page={true} variant={"PageLoader"} />;
}
// Consider adding this to your App component:
if (initializationError) {
return <div>Failed to initialize application. Please refresh the page.</div>;
}
if (!stateCode) {
return <h1>stateCode is not defined</h1>;
return (
<div className="error-container">
<h1>Configuration Error</h1>
<p>State code is not defined. Please check your configuration.</p>
</div>
);
}
return (
<DigitUI
stateCode={stateCode}
enabledModules={enabledModules}
moduleReducers={moduleReducers}
defaultLanding="employee"
allowedUserTypes={["employee"]}
/>
);
}
Expand Down
6 changes: 3 additions & 3 deletions health/micro-ui/web/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"homepage": "/console",
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.9",
"@egovernments/digit-ui-module-core": "1.8.21",
"@egovernments/digit-ui-react-components": "1.8.15",
"@egovernments/digit-ui-module-core": "1.8.22",
"@egovernments/digit-ui-react-components": "1.8.16",
"@egovernments/digit-ui-components":"0.0.2-beta.65",
"@egovernments/digit-ui-svg-components":"1.0.14",
"@egovernments/digit-ui-module-workbench": "1.0.13",
"@egovernments/digit-ui-module-workbench": "1.0.14",
"@egovernments/digit-ui-module-campaign-manager": "0.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down

0 comments on commit 00199c6

Please sign in to comment.