diff --git a/micro-ui/web/lerna.json b/micro-ui/web/lerna.json index 58d190662c0..33d53e64d6c 100644 --- a/micro-ui/web/lerna.json +++ b/micro-ui/web/lerna.json @@ -5,6 +5,7 @@ "packages/core", "packages/workbench", "packages/ui-core", + "packages/hrms", "packages/app1" ], "command": { diff --git a/micro-ui/web/packages/core/src/modules/registerRemotes.js b/micro-ui/web/packages/core/src/modules/registerRemotes.js index 4394aa7d7a0..b80f7e5982b 100644 --- a/micro-ui/web/packages/core/src/modules/registerRemotes.js +++ b/micro-ui/web/packages/core/src/modules/registerRemotes.js @@ -6,12 +6,22 @@ import { registerApplication,start } from "single-spa"; export default (queryClient) => { + // registerApplication({ + // name: "Workbench", + // app: () => import("workbench/WorkbenchModule"), + // activeWhen: "/workbench-ui/employee/workbench", + // customProps: { + // title: "Workbench is running on host", + // queryClient, + // }, + // }); + registerApplication({ - name: "Workbench", - app: () => import("workbench/WorkbenchModule"), - activeWhen: "/workbench-ui/employee/workbench", + name: "hrms", + app: () => import("hrms/HrmsModule"), + activeWhen: "/workbench-ui/employee/hrms", customProps: { - title: "Workbench is running on host", + title: "HRMS is running on host", queryClient, }, }); diff --git a/micro-ui/web/packages/core/webpack.dev.js b/micro-ui/web/packages/core/webpack.dev.js index 3a5ffad58e4..befd701a8dd 100644 --- a/micro-ui/web/packages/core/webpack.dev.js +++ b/micro-ui/web/packages/core/webpack.dev.js @@ -43,8 +43,8 @@ module.exports = () => { // auth: "auth@http://localhost:8082/remoteEntry.js", // header: "header@http://localhost:8083/remoteEntry.js", // dashboard: "dashboard@http://localhost:8084/remoteEntry.js", - // hrms: "hrms@https://localhost:8085/remoteEntry.js", - workbench: "workbench@https://localhost:8086/remoteEntry.js", + hrms: "hrms@https://localhost:8085/remoteEntry.js", + // workbench: "workbench@https://localhost:8086/remoteEntry.js", // app1: "app1@https://localhost:8001/remoteEntry.js", // dss: "dss@https://localhost:8087/remoteEntry.js", // measurement : "measurement@https://localhost:8088/remoteEntry.js" diff --git a/micro-ui/web/packages/hrms/package.json b/micro-ui/web/packages/hrms/package.json index 22ccf2f947d..2dfb64a5dd1 100644 --- a/micro-ui/web/packages/hrms/package.json +++ b/micro-ui/web/packages/hrms/package.json @@ -23,12 +23,13 @@ "@babel/preset-env":"7.23.9" }, "dependencies": { + "single-spa-react": "^4.6.1", "react": "17.0.1", "react-dom": "17.0.1", "react-router-dom": "5.2.0", "rxjs": "6.6.3", - "@digit-ui/digit-ui-libraries-mfe": "1.0.7", - "@egovernments/digit-ui-react-components":"1.4.107", + "@digit-ui/digit-ui-libraries-mfe": "1.0.6", + "@egovernments/digit-ui-react-components":"1.4.106", "@digit-ui/digit-ui-module-core-base":"1.0.8", "react-hook-form": "6.15.8", "react-i18next": "11.16.2", diff --git a/micro-ui/web/packages/hrms/public/index.html b/micro-ui/web/packages/hrms/public/index.html index 266bc6968a7..59571a96707 100644 --- a/micro-ui/web/packages/hrms/public/index.html +++ b/micro-ui/web/packages/hrms/public/index.html @@ -4,7 +4,14 @@ Hrms Page - + { + console.log("qc in remote hrms",queryClient); +initHRMSComponents(); + + return ( + + + + + + ); +}; + +export default App; diff --git a/micro-ui/web/packages/hrms/src/SIngleSpaEntry.js b/micro-ui/web/packages/hrms/src/SIngleSpaEntry.js new file mode 100644 index 00000000000..59fda042cd9 --- /dev/null +++ b/micro-ui/web/packages/hrms/src/SIngleSpaEntry.js @@ -0,0 +1,25 @@ +import React from "react"; +import ReactDOM from "react-dom"; +import singleSpaReact from "single-spa-react"; +import App from "./HRMSWrapper"; +const appLifeCycles = singleSpaReact({ + React, + ReactDOM, + rootComponent: App, + errorBoundary() { + // https://reactjs.org/docs/error-boundaries.html + return
This renders when a catastrophic error occurs
; + }, +}); + +export function bootstrap(props) { + return appLifeCycles.bootstrap(props); +} + +export function mount(props) { + return appLifeCycles.mount(props); +} + +export function unmount(props) { + return appLifeCycles.unmount(props); +} \ No newline at end of file diff --git a/micro-ui/web/packages/hrms/src/pages/index.js b/micro-ui/web/packages/hrms/src/pages/index.js index 007518f74dc..d865d6c657d 100644 --- a/micro-ui/web/packages/hrms/src/pages/index.js +++ b/micro-ui/web/packages/hrms/src/pages/index.js @@ -1,10 +1,15 @@ import { PrivateRoute } from "@egovernments/digit-ui-react-components"; -import React,{ useEffect } from "react"; +import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; -import { Link, Switch, useLocation } from "react-router-dom"; +import { + Link, + Switch, + useLocation, + BrowserRouter as Router, +} from "react-router-dom"; import { SVG } from "@egovernments/digit-ui-react-components"; -const {SixFtApart,Rotate360}=SVG; +const { SixFtApart, Rotate360 } = SVG; const EmployeeApp = ({ path, url, userType }) => { const { t } = useTranslation(); const location = useLocation(); @@ -16,46 +21,84 @@ const EmployeeApp = ({ path, url, userType }) => { }, }; - const HRMSResponse = Digit?.ComponentRegistryService?.getComponent("HRMSResponse"); - const HRMSDetails = Digit?.ComponentRegistryService?.getComponent("HRMSDetails"); + const HRMSResponse = + Digit?.ComponentRegistryService?.getComponent("HRMSResponse"); + const HRMSDetails = + Digit?.ComponentRegistryService?.getComponent("HRMSDetails"); const Inbox = Digit?.ComponentRegistryService?.getComponent("HRInbox"); - const CreateEmployee = Digit?.ComponentRegistryService?.getComponent("HRCreateEmployee"); - const EditEmpolyee = Digit?.ComponentRegistryService?.getComponent("HREditEmpolyee"); + const CreateEmployee = + Digit?.ComponentRegistryService?.getComponent("HRCreateEmployee"); + const EditEmpolyee = + Digit?.ComponentRegistryService?.getComponent("HREditEmpolyee"); const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {}); const [sessionFormData,setSessionFormData, clearSessionFormData] = employeeCreateSession; // remove session form data if user navigates away from the estimate create screen - useEffect(()=>{ - if (!window.location.href.includes("/hrms/create") && sessionFormData && Object.keys(sessionFormData) != 0) { - clearSessionFormData(); - } -},[location]); + useEffect(()=>{ + if (!window.location.href.includes("/hrms/create") && sessionFormData && Object.keys(sessionFormData) != 0) { + clearSessionFormData(); + } + },[location]); return ( - - -
-

- - {t("HR_COMMON_BUTTON_HOME")} - {" "} - / {location.pathname === `/${window?.contextPath}/employee/hrms/inbox` ? t("HR_COMMON_HEADER") : t("HR_COMMON_HEADER")} -

- ( - - )} - /> - } /> - } /> - } /> - } /> -
-
-
+ + + +
+

+ + {t("HR_COMMON_BUTTON_HOME")} + {" "} + /{" "} + + {location.pathname === + `/${window?.contextPath}/employee/hrms/inbox` + ? t("HR_COMMON_HEADER") + : t("HR_COMMON_HEADER")} + +

+ ( + + )} + /> + } + /> + ( + + )} + /> + } + /> + } + /> +
+
+
+
); }; -export default EmployeeApp; \ No newline at end of file +export default EmployeeApp; diff --git a/micro-ui/web/packages/hrms/webpack.dev.js b/micro-ui/web/packages/hrms/webpack.dev.js index bf6c49f95c1..46fdfe96933 100644 --- a/micro-ui/web/packages/hrms/webpack.dev.js +++ b/micro-ui/web/packages/hrms/webpack.dev.js @@ -41,7 +41,7 @@ module.exports = () => { name: "hrms", filename: "remoteEntry.js", exposes: { - "./HrmsModule": "./src/bootstrap", + "./HrmsModule": "./src/SingleSpaEntry", }, shared: packageJson.dependencies, }), diff --git a/micro-ui/web/packages/hrms/webpack.prod.js b/micro-ui/web/packages/hrms/webpack.prod.js index 5a234d73fe0..5b445b0b2c4 100644 --- a/micro-ui/web/packages/hrms/webpack.prod.js +++ b/micro-ui/web/packages/hrms/webpack.prod.js @@ -24,3 +24,4 @@ module.exports = () => { return merge(commonConfig, prodConfig); +}; \ No newline at end of file