Skip to content

Commit

Permalink
Merge pull request #192 from egovernments/mf-hrms-build
Browse files Browse the repository at this point in the history
DPG-2222 Implementing microfrontend Single Spa React for HRMS module
  • Loading branch information
nipunarora-eGov authored Mar 6, 2024
2 parents 899ce30 + 36aa390 commit 6d2fb31
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 32 deletions.
4 changes: 4 additions & 0 deletions micro-ui/web/lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
"packages/workbench",
"packages/pgr",
"packages/ui-core",

"packages/hrms",

"packages/app1",
"packages/dss"

],
"command": {
"run": {
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/packages/core/src/modules/Hrms.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef } from "react";
import { mount } from "hrms/HrmsModule";
import { mount } from "hrms/HRMSModule";
import { History } from "history";

// interface AuthProps {
Expand Down
39 changes: 21 additions & 18 deletions micro-ui/web/packages/core/src/modules/registerRemotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default (queryClient) => {
// },
// });



// registerApplication({
// name: "PGR",
// app: () => import("pgr/PGRModule"),
Expand All @@ -39,15 +41,15 @@ export default (queryClient) => {
// },
// });

registerApplication({
name: "Dss",
app: () => import("dss/DSSModule"),
activeWhen: "/workbench-ui/employee/dss",
customProps: {
title: "DSS is running on host",
queryClient,
},
});
// registerApplication({
// name: "Dss",
// app: () => import("dss/DSSModule"),
// activeWhen: "/workbench-ui/employee/dss",
// customProps: {
// title: "DSS is running on host",
// queryClient,
// },
// });

// registerApplication({
// name: "app1",
Expand All @@ -59,15 +61,16 @@ export default (queryClient) => {
// },
// });

// registerApplication({
// name: "HRMS",
// app: () => import("hrms/HRMSModule"),
// activeWhen: "/workbench-ui/employee/hrms",
// customProps: {
// title: "HRMS is running on host",
// queryClient,
// },
// });

// registerApplication({
// name: "HRMS",
// app: () => import("hrms/HRMSModule"),
// activeWhen: "/workbench-ui/employee/hrms",
// customProps: {
// title: "HRMS is running on host",
// queryClient,
// },
// });

start();
}
Expand Down
7 changes: 6 additions & 1 deletion micro-ui/web/packages/core/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ 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_ui@https://localhost:8085/remoteEntry.js",


// pgr: "pgr@https://localhost:8087/remoteEntry.js",
// hrms: "hrms@https://localhost:8085/remoteEntry.js",


// workbench: "workbench@https://localhost:8086/remoteEntry.js",
// common:"common@https://localhost:8090/remoteEntry.js"


// app1: "app1@https://localhost:8001/remoteEntry.js",
//dss: "dss_ui@https://localhost:8087/remoteEntry.js",
// measurement : "measurement@https://localhost:8088/remoteEntry.js"
Expand Down
5 changes: 5 additions & 0 deletions micro-ui/web/packages/core/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ module.exports = () => {
// auth: `auth@${domain}/auth/remoteEntry.js`,
// header: `header@${domain}/header/remoteEntry.js`,
// dashboard: `dashboard@${domain}/dashboard/remoteEntry.js`,

// hrms: `hrms_ui@${domain}/hrms/remoteEntry.js`,


// pgr : `pgr-ui@${domain}/pgr/remoteEntry.js`,
// hrms: `hrms@${domain}/hrms/remoteEntry.js`,
//dss : `dss_ui@${domain}/dss/remoteEntry.js`,

// common: `common-ui@${domain}/common-ui/remoteEntry.js`,
// workbench : `workbench_web@${domain}/workbench/remoteEntry.js`,

// dss : `dss@${domain}/dss/remoteEntry.js`,

// measurement : `measurement@${domain}/measurement/remoteEntry.js`
Expand Down
2 changes: 2 additions & 0 deletions micro-ui/web/packages/hrms/src/HRMSWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { initHRMSComponents } from './Module';
import EmployeeApp from './pages';

const App = ({ queryClient, title }) => {

console.log("qc in remote hrms",queryClient);

initHRMSComponents();

return (
Expand Down
6 changes: 3 additions & 3 deletions micro-ui/web/packages/hrms/src/components/InboxFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Filter = ({ searchParams, onFilterChange, onSearch, removeParam, ...props
)[0];
});
const { isLoading, isError, errors, data: data, ...rest } = Digit.Hooks.hrms.useHrmsMDMS(
tenantId ? tenantId.code : searchParams?.tenantId,
tenantId ? tenantId?.code : searchParams?.tenantId,
"egov-hrms",
"HRMSRolesandDesignation"
);
Expand All @@ -54,8 +54,8 @@ const Filter = ({ searchParams, onFilterChange, onSearch, removeParam, ...props
});

useEffect(() => {
if (tenantId.code) {
setSearchParams({ ..._searchParams, tenantId: tenantId.code });
if (tenantId?.code) {
setSearchParams({ ..._searchParams, tenantId: tenantId?.code });
}
}, [tenantId]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Jurisdictions = ({ t, config, onSelect, userType, formData }) => {
const [focusIndex, setFocusIndex] = useState(-1);

function gethierarchylistdata() {
return data?.MdmsRes?.["egov-location"]["TenantBoundary"].map((ele) => ele.hierarchyType);
return data?.MdmsRes?.["egov-location"]["TenantBoundary"]?.map((ele) => ele.hierarchyType);
}

function getboundarydata() {
Expand Down Expand Up @@ -173,8 +173,7 @@ function Jurisdiction({
const [Boundary, selectboundary] = useState([]);
useEffect(() => {
selectBoundaryType(
data?.MdmsRes?.["egov-location"]["TenantBoundary"]
.filter((ele) => {
data?.MdmsRes?.["egov-location"]["TenantBoundary"]?.filter((ele) => {
return ele?.hierarchyType?.code == jurisdiction?.hierarchy?.code;
})
.map((item) => { return { ...item.boundary, i18text: Digit.Utils.locale.convertToLocale(item.boundary.label, 'EGOV_LOCATION_BOUNDARYTYPE') } })
Expand Down
8 changes: 4 additions & 4 deletions micro-ui/web/packages/hrms/src/pages/Response.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Response = (props) => {
const [mutationHappened, setMutationHappened, clear] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_MUTATION_HAPPENED", false);
const [successData, setsuccessData, clearSuccessData] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_MUTATION_SUCCESS_DATA", false);
const [errorInfo, setErrorInfo, clearError] = Digit.Hooks.useSessionStorage("EMPLOYEE_HRMS_ERROR_DATA", false);
const mutation = state.key === "UPDATE" ? Digit.Hooks.hrms.useHRMSUpdate(tenantId) : Digit.Hooks.hrms.useHRMSCreate(tenantId);
const mutation = state?.key === "UPDATE" ? Digit.Hooks.hrms.useHRMSUpdate(tenantId) : Digit.Hooks.hrms.useHRMSCreate(tenantId);

const employeeCreateSession = Digit.Hooks.useSessionStorage("NEW_EMPLOYEE_CREATE", {});
const [sessionFormData,setSessionFormData, clearSessionFormData] = employeeCreateSession;
Expand All @@ -63,7 +63,7 @@ const Response = (props) => {
setMutationHappened(true);
};
if (!mutationHappened ) {
if (state.key === "UPDATE") {
if (state?.key === "UPDATE") {
mutation.mutate(
{
Employees: state.Employees,
Expand Down Expand Up @@ -97,12 +97,12 @@ const Response = (props) => {
<BannerPicker
t={t}
data={mutation?.data|| successData}
action={state.action}
action={state?.action}
isSuccess={!successData ? mutation?.isSuccess : true}
isLoading={(mutation.isIdle && !mutationHappened) || mutation?.isLoading}
isEmployee={props.parentRoute.includes("employee")}
/>
<CardText>{t(DisplayText(state.action, mutation.isSuccess || !!successData, props.parentRoute.includes("employee"), t), t)}</CardText>
<CardText>{t(DisplayText(state?.action, mutation.isSuccess || !!successData, props.parentRoute.includes("employee"), t), t)}</CardText>

<ActionBar>
<Link to={`${props.parentRoute.includes("employee") ? `/${window?.contextPath}/employee` : `/${window?.contextPath}/citizen`}`}>
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/packages/hrms/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = () => {
},
plugins: [
new ModuleFederationPlugin({
name: "hrms",
name: "hrms_ui",
filename: "remoteEntry.js",
exposes: {
"./HRMSModule": "./src/SingleSpaEntry",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/packages/hrms/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = () => {
},
plugins: [
new ModuleFederationPlugin({
name: "hrms-ui",
name: "hrms_ui",
filename: "remoteEntry.js",
exposes: {
"./HRMSModule": "./src/SingleSpaEntry",
Expand Down

0 comments on commit 6d2fb31

Please sign in to comment.