Skip to content

Commit

Permalink
added pgr module
Browse files Browse the repository at this point in the history
  • Loading branch information
nipunarora-eGov committed Mar 4, 2024
1 parent af62abb commit 5fa50e6
Show file tree
Hide file tree
Showing 79 changed files with 4,665 additions and 3 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/mfe-pgr-ui-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: pgr ui service docker Image CI

on:
push:
branches: [ "mf-build-docker","mf-stable-common-module" ]
pull_request:
branches: [ "mf-build" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for tags and branches

- name: Set up environment variables
id: env
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "ACTION_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
echo "COMMIT_ID=${GITHUB_SHA: -8}" >> $GITHUB_ENV # Extract last 8 characters of SHA
- name: Build the Docker image
id: docker_build
working-directory: ./micro-ui/web/packages/pgr
run: |
IMAGE_TAG=egovio/pgr-ui:${{ env.BRANCH_NAME }}-${{ env.COMMIT_ID }}-${{ env.ACTION_NUMBER }}
docker build . \
--file docker/Dockerfile \
--tag $IMAGE_TAG
echo "::set-output name=image_name::$IMAGE_TAG"
- name: Login to Docker Hub and Push Docker Image
working-directory: ./micro-ui/web/packages/pgr
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_NAME: ${{ steps.docker_build.outputs.image_name }}
run: |
# Authenticate with Docker Hub
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# Push the image to Docker Hub
docker push $IMAGE_NAME
echo "Docker image pushed: $IMAGE_NAME"
3 changes: 2 additions & 1 deletion micro-ui/web/lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"packages/workbench",
"packages/ui-core",
"packages/app1",
"packages/common"
"packages/common",
"packages/pgr"
],
"command": {
"run": {
Expand Down
3 changes: 2 additions & 1 deletion micro-ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"packages/workbench",
"packages/ui-core",
"packages/app1",
"packages/common"
"packages/common",
"packages/pgr"
],
"scripts": {
"build": "yarn lerna run build",
Expand Down
10 changes: 10 additions & 0 deletions micro-ui/web/packages/core/src/modules/registerRemotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ export default (queryClient) => {
},
});

registerApplication({
name: "PGR",
app: () => import("pgr/PGRModule"),
activeWhen: `/${window.contextPath ? window.contextPath : "core-digit-ui"}/employee/pgr`,
customProps: {
title: "PGR is running on host",
queryClient,
userType
},
});

start();
}
Expand Down
3 changes: 2 additions & 1 deletion micro-ui/web/packages/core/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ module.exports = () => {
// dashboard: "dashboard@http://localhost:8084/remoteEntry.js",
// hrms: "hrms@https://localhost:8085/remoteEntry.js",
// workbench: "workbench@https://localhost:8086/remoteEntry.js",
common:"common@https://localhost:8090/remoteEntry.js"
common:"common@https://localhost:8090/remoteEntry.js",
pgr:"pgr@https://localhost:8087/remoteEntry.js",
// app1: "app1@https://localhost:8001/remoteEntry.js",
// dss: "dss@https://localhost:8087/remoteEntry.js",
// measurement : "measurement@https://localhost:8088/remoteEntry.js"
Expand Down
1 change: 1 addition & 0 deletions micro-ui/web/packages/core/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = () => {
// dashboard: `dashboard@${domain}/dashboard/remoteEntry.js`,
// hrms: `hrms@${domain}/hrms/remoteEntry.js`,
common: `common@${domain}/common-ui/remoteEntry.js`,
pgr: `pgr@${domain}/pgr-ui/remoteEntry.js`,
// workbench : `workbench_web@${domain}/workbench/remoteEntry.js`,
// dss : `dss@${domain}/dss/remoteEntry.js`,
// measurement : `measurement@${domain}/measurement/remoteEntry.js`
Expand Down
30 changes: 30 additions & 0 deletions micro-ui/web/packages/pgr/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use Node.js base image with version 16
FROM node:16 AS build

# Set working directory
WORKDIR /app

# Copy package.json and yarn.lock (if exists)
COPY package.json ./

# clear cache
RUN yarn cache clean

# Install dependencies
RUN yarn install

# Copy the rest of the application
COPY . .

# Build the React app with Webpack
RUN yarn build

FROM nginx:mainline-alpine

ENV WORK_DIR=/var/web/pgr-ui

RUN mkdir -p ${WORK_DIR}


COPY --from=build /app/dist ${WORK_DIR}/
COPY --from=build /app/docker/nginx.conf /etc/nginx/conf.d/default.conf
12 changes: 12 additions & 0 deletions micro-ui/web/packages/pgr/docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server
{
listen 80;
underscores_in_headers on;

location /pgr-ui
{
root /var/web;
index index.html index.htm;
try_files $uri $uri/ /pgr-ui/index.html;
}
}
50 changes: 50 additions & 0 deletions micro-ui/web/packages/pgr/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@digit-ui/digit-ui-module-pgr-mfe",
"version": "1.0.6",
"description": "",
"main": "module.js",
"scripts": {
"predeploy": "yarn build",
"deploy": "gh-pages -d dist",
"start": "webpack serve --config webpack.dev.js",
"build": "webpack --config webpack.prod.js"
},
"homepage": "http://design-egov.github.io/auth",
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "7.12.10",
"@babel/preset-react": "7.12.10",
"babel-loader": "8.2.2",
"gh-pages": "^5.0.0",
"html-webpack-plugin": "^5.5.0",
"babel-plugin-react-html-attrs": "^3.0.5",
"@babel/preset-env": "7.23.9"
},
"dependencies": {
"single-spa-react": "^4.6.1",
"@digit-ui/digit-ui-libraries-mfe": "1.0.6",
"@digit-ui/digit-ui-module-core-base": "1.0.8",
"@egovernments/digit-ui-react-components": "1.4.107",
"@egovernments/digit-ui-svg-components": "0.0.8",
"@rjsf/core": "5.10.0",
"@rjsf/utils": "5.10.0",
"@rjsf/validator-ajv8": "5.10.0",
"react": "17.0.1",
"react-date-range": "1.4.0",
"react-dom": "17.0.1",
"react-hook-form": "6.15.8",
"react-i18next": "11.16.2",
"react-query": "3.6.1",
"react-router-dom": "5.2.0",
"react-select": "5.7.4",
"webpack": "^5.68.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.8.1",
"react-redux": "7.2.8",
"redux": "4.1.2",
"redux-thunk": "2.4.1",
"webpack-merge": "5.7.3"
}
}
26 changes: 26 additions & 0 deletions micro-ui/web/packages/pgr/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>PGR Page</title>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<script src="https://s3.ap-south-1.amazonaws.com/egov-dev-assets/globalConfigsWorkbench.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />

<link href="https://fonts.googleapis.com/css2?family=Oxygen:wght@400;700&display=swap" rel="stylesheet" />
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Oxygen", sans-serif;
}
</style>
</head>

<body>
<div id="pgr-module-root"></div>

</body>

</html>
23 changes: 23 additions & 0 deletions micro-ui/web/packages/pgr/src/EmployeeApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react";
import { AppContainer, EmployeeAppContainer } from "@egovernments/digit-ui-react-components";
import Complaint from "./pages/employee/index";
import { Provider } from "react-redux";
import getStore from "./redux/store";
import { PGRReducers } from "./Module";

const App = () => {
const { isLoading, data: initData } = Digit.Hooks.useInitStore("pg", ["PT", "HRMS", "Workbench", "DSS", "Measurement", "PGR"]);
const moduleReducers = (initData) => ({
pgr: PGRReducers(initData),
});

return (
<Provider store={getStore(initData, moduleReducers(initData))}>
<EmployeeAppContainer>
<Complaint />
</EmployeeAppContainer>
</Provider>
);
};

export default App;
8 changes: 8 additions & 0 deletions micro-ui/web/packages/pgr/src/Icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";

export const Close = () => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFFFFF">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
</svg>
);
87 changes: 87 additions & 0 deletions micro-ui/web/packages/pgr/src/Module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React, { useEffect } from "react";
import PGRCard from "./components/PGRCard";

import getRootReducer from "./redux/reducers";
import CitizenApp from "./pages/citizen";

import EmployeeApp from "./EmployeeApp";
import { ComplaintIcon, CitizenHomeCard, Loader } from "@egovernments/digit-ui-react-components";
import { PGR_CITIZEN_CREATE_COMPLAINT } from "./constants/Citizen";
import { useTranslation } from "react-i18next";
import { LOCALE } from "./constants/Localization";
import { ComplaintDetails } from "./pages/employee/ComplaintDetails";
import { CreateComplaint as CreateComplaintEmp } from "./pages/employee/CreateComplaint";
import Inbox from "./pages/employee/Inbox";
import ResponseEmp from "./pages/employee/Response";

import { CreateComplaint as CreateComplaintCitizen } from "./pages/citizen/Create";
import { ComplaintsList } from "./pages/citizen/ComplaintsList";
import ComplaintDetailsPage from "./pages/citizen/ComplaintDetails";
import SelectRating from "./pages/citizen/Rating/SelectRating";
import ResponseCitizen from "./pages/citizen/Response";
import InboxV2 from "./pages/employee/InboxV2";


export const PGRReducers = getRootReducer;

const PGRModule = ({ stateCode, userType, tenants }) => {
const moduleCode = "PGR";
const language = Digit.StoreData.getCurrentLanguage();
const { isLoading, data: store } = Digit.Services.useStore({ stateCode, moduleCode, language });

if (isLoading) {
return <Loader />;
}

Digit.SessionStorage.set("PGR_TENANTS", tenants);

if (userType === "citizen") {
return <CitizenApp />;
} else {
return <EmployeeApp />;
}
};

const PGRLinks = ({ matchPath }) => {
const { t } = useTranslation();
const [params, setParams, clearParams] = Digit.Hooks.useSessionStorage(PGR_CITIZEN_CREATE_COMPLAINT, {});

useEffect(() => {
clearParams();
}, []);

const links = [
{
link: `${matchPath}/create-complaint/complaint-type`,
i18nKey: t("CS_COMMON_FILE_A_COMPLAINT"),
},
{
link: `${matchPath}/complaints`,
i18nKey: t(LOCALE.MY_COMPLAINTS),
},
];

return <CitizenHomeCard header={t("CS_COMMON_HOME_COMPLAINTS")} links={links} Icon={ComplaintIcon} />;
};

const componentsToRegister = {
PGRModule,
PGRLinks,
PGRCard,
PGRComplaintDetails : ComplaintDetails,
PGRCreateComplaintEmp : CreateComplaintEmp,
PGRInbox : Inbox,
PGRInboxV2 : InboxV2,
PGRResponseEmp : ResponseEmp,
PGRCreateComplaintCitizen : CreateComplaintCitizen,
PGRComplaintsList : ComplaintsList,
PGRComplaintDetailsPage : ComplaintDetailsPage,
PGRSelectRating : SelectRating,
PGRResponseCitzen : ResponseCitizen
};

export const initPGRComponents = () => {
Object.entries(componentsToRegister).forEach(([key, value]) => {
Digit.ComponentRegistryService.setComponent(key, value);
});
};
20 changes: 20 additions & 0 deletions micro-ui/web/packages/pgr/src/PGRWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { initPGRComponents } from './Module';
import { QueryClientProvider } from 'react-query';
import EmployeeApp from './EmployeeApp';
import { Switch, useLocation, BrowserRouter as Router } from 'react-router-dom';

const App = ({ queryClient, title,userType }) => {
initPGRComponents();
//make way to do this job in container while registering remotes

return (
<QueryClientProvider client={queryClient}>
<Router>
<EmployeeApp path={`/${window.contextPath}/${userType}/pgr`} />
</Router>
</QueryClientProvider>
);
};

export default App;
26 changes: 26 additions & 0 deletions micro-ui/web/packages/pgr/src/SingleSpaEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import ReactDOM from "react-dom";
import singleSpaReact from "single-spa-react";
import App from "./PGRWrapper";

const appLifeCycles = singleSpaReact({
React,
ReactDOM,
rootComponent: App,
errorBoundary() {
// https://reactjs.org/docs/error-boundaries.html
return <div>This renders when a catastrophic error occurs</div>;
},
});

export function bootstrap(props) {
return appLifeCycles.bootstrap(props);
}

export function mount(props) {
return appLifeCycles.mount(props);
}

export function unmount(props) {
return appLifeCycles.unmount(props);
}
Loading

0 comments on commit 5fa50e6

Please sign in to comment.