Skip to content

Commit

Permalink
Base hcm workbench (#83)
Browse files Browse the repository at this point in the history
* Update package.json

* HLM-4751 added facilty and product tab in view project (#76)

* Hlm 4539 update (#75)

* Added the Download feature in the view screen

* updated the view page code

* updated the version

* updated all package version

* HLM-4668: UI Project Staff add / delete in view Campaign screen (#77)

* HLM-4536 made the view screen

* HLM-4536 table the table in the components

* HLM-4537:Added edit option for dates

* HLM-4537:Updated code

* HLM-4668: Added api integration for project staff

* HLM-4668: Updated modal

* HLM-4468: Fixed delete issue

---------

Co-authored-by: Bhavya-egov <[email protected]>

* Hlm 4751 enhancement in view project  (#82)

* HLM-4751 added facilty and product tab in view project

* HLM-4751 added new columns in view product and facility table

* HLM-4751 resolved the conflicts

* HLM-4751 added label in the project staff

* HLM-4751 updated the package version

---------

Co-authored-by: Bhavya-egov <[email protected]>
Co-authored-by: himanshukeshari-eGov <[email protected]>
Co-authored-by: Anil Singha <[email protected]>
Co-authored-by: Bhavya-egov <[email protected]>
  • Loading branch information
5 people authored Jan 3, 2024
1 parent fcdf4a3 commit 791eb35
Show file tree
Hide file tree
Showing 24 changed files with 899 additions and 164 deletions.
2 changes: 1 addition & 1 deletion micro-ui/web/core/inter-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"dependencies": {
"lodash": "4.17.21",
"microbundle-crl": "0.13.11",
"@egovernments/digit-ui-react-components": "1.8.0-beta.1",
"@egovernments/digit-ui-react-components": "1.8.0-beta.4",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "6.15.8",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@egovernments/digit-ui-module-workbench": "1.0.0-beta.6",
"@egovernments/digit-ui-module-core": "1.8.0-beta.8",
"@egovernments/digit-ui-module-hrms": "1.8.0-beta.2",
"@egovernments/digit-ui-react-components": "1.8.0-beta.1",
"@egovernments/digit-ui-react-components": "1.8.0-beta.4",
"@egovernments/digit-ui-module-dss": "1.8.0-beta",
"@egovernments/digit-ui-module-common": "1.8.0-beta",
"@egovernments/digit-ui-module-utilities": "1.0.0-beta",
Expand Down
4 changes: 2 additions & 2 deletions micro-ui/web/micro-ui-internals/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"devDependencies": {
"@egovernments/digit-ui-libraries": "1.8.0-beta.2",
"@egovernments/digit-ui-module-workbench": "1.0.0-beta.6",
"@egovernments/digit-ui-module-hcmworkbench": "0.0.13",
"@egovernments/digit-ui-module-hcmworkbench": "0.0.16",
"@egovernments/digit-ui-module-dss": "1.8.0-beta",
"@egovernments/digit-ui-module-core": "1.8.0-beta.8",
"@egovernments/digit-ui-module-common": "1.8.0-beta",
"@egovernments/digit-ui-module-hrms": "1.8.0-beta.2",
"@egovernments/digit-ui-module-utilities": "1.0.0-beta",
"@egovernments/digit-ui-module-engagement": "1.5.20",
"@egovernments/digit-ui-react-components": "1.8.0-beta.1",
"@egovernments/digit-ui-react-components": "1.8.0-beta.4",
"http-proxy-middleware": "^1.0.5",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
10 changes: 6 additions & 4 deletions micro-ui/web/micro-ui-internals/example/src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ const createProxy = createProxyMiddleware({
// target: process.env.REACT_APP_PROXY_API || "https://qa.digit.org",
target: process.env.REACT_APP_PROXY_API || "https://works-dev.digit.org",
changeOrigin: true,
secure:false
secure: false,
});
const assetsProxy = createProxyMiddleware({
target: process.env.REACT_APP_PROXY_ASSETS || "https://works-dev.digit.org",
changeOrigin: true,
secure:false
secure: false,
});
const mdmsProxy = createProxyMiddleware({
target: process.env.REACT_APP_PROXY_ASSETS || "http://localhost:8080",
changeOrigin: true,
secure:false
secure: false,
});
module.exports = function (app) {
["/mdms-v2/v2/_create"].forEach((location) => app.use(location, mdmsProxy));
Expand Down Expand Up @@ -85,7 +85,9 @@ module.exports = function (app) {
"/project",
"/project/staff/v1/_search",
"/project/v1/_search",
"/facility/v1/_search"
"/facility/v1/_search",
"/product/v1/_search",
"/product/variant/v1/_search"

].forEach((location) => app.use(location, createProxy));
["/pb-egov-assets"].forEach((location) => app.use(location, assetsProxy));
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/micro-ui-internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"dependencies": {
"lodash": "4.17.21",
"microbundle-crl": "0.13.11",
"@egovernments/digit-ui-react-components": "1.8.0-beta.1",
"@egovernments/digit-ui-react-components": "1.8.0-beta.4",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "6.15.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,43 @@ function getDate(timestamp) {

const monthNames = ["Jan", "Feb", "March", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec"];

export { getDate, monthNames };


/*
Digit.Utils.date.convertDateToEpoch()
* @params dateString date as string
dayStartOrEnd defaults to dayend
//example input format : "2018-10-02"
*/
const convertDateToEpoch = (dateString, dayStartOrEnd = "dayend") => {
try {
const parts = dateString.match(/(\d{4})-(\d{1,2})-(\d{1,2})/);
const DateObj = new Date(Date.UTC(parts[1], parts[2] - 1, parts[3]));
DateObj.setMinutes(DateObj.getMinutes() + DateObj.getTimezoneOffset());
if (dayStartOrEnd === "dayend") {
DateObj.setHours(DateObj.getHours() + 24);
DateObj.setSeconds(DateObj.getSeconds() - 1);
}
return DateObj.getTime();
} catch (e) {
return dateString;
}
};

const convertEpochToDate = (dateEpoch) => {
if (dateEpoch == null || dateEpoch == undefined || dateEpoch == "") {
return "NA";
}
const dateFromApi = new Date(dateEpoch);
let month = dateFromApi.getMonth() + 1;
let day = dateFromApi.getDate();
let year = dateFromApi.getFullYear();
month = (month > 9 ? "" : "0") + month;
day = (day > 9 ? "" : "0") + day;
return `${day}/${month}/${year}`;
};

export { getDate, monthNames, convertEpochToDate, convertDateToEpoch };

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prepublish": "yarn build"
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.0-beta.1",
"@egovernments/digit-ui-react-components": "1.8.0-beta.4",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-i18next": "11.16.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-module-hcmworkbench",
"version": "0.0.13",
"version": "0.0.17",
"description": "Workbench-HCM",
"main": "dist/index.js",
"module": "dist/index.modern.js",
Expand All @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.0-beta.2",
"@egovernments/digit-ui-react-components": "1.8.0-beta.1",
"@egovernments/digit-ui-react-components": "1.8.0-beta.4",
"@rjsf/core": "5.10.0",
"@rjsf/utils": "5.10.0",
"@rjsf/validator-ajv8": "5.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Loader } from "@egovernments/digit-ui-react-components";
import ProjectBeneficiaryComponent from "./components/ProjectBeneficiaryComponent";
import ProjectChildrenComponent from "./components/ProjectChildrenComponent";
import ProjectStaffComponent from "./components/ProjectStaffComponent";
import FacilityComponent from "./components/FacilityComponent";

const HCMWORKBENCHModule = ({ stateCode, userType, tenants }) => {
const moduleCode = ["workbench-hcm"];
Expand All @@ -34,7 +35,8 @@ const componentsToRegister = {
HCMWORKBENCHCard,
ProjectBeneficiaryComponent,
ProjectChildrenComponent,
ProjectStaffComponent
ProjectStaffComponent,
FacilityComponent
};

const overrideHooks = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Card, Modal, CloseSvg, Close } from "@egovernments/digit-ui-react-components";
import React, { useState } from "react";

const ConfirmationDialog = ({ t, onSubmit, closeModal, heading }) => {
const CloseBtn = (props) => {
return (
<div onClick={props?.onClick} style={props?.isMobileView ? { padding: 5 } : null}>
{props?.isMobileView ? (
<CloseSvg />
) : (
<div className={"icon-bg-secondary"} style={{ backgroundColor: "#FFFFFF" }}>
<Close />
</div>
)}
</div>
);
};
const Heading = (props) => {
return <h1 className="heading-m">{props.heading}</h1>;
};
return (
<Modal
headerBarMain={<Heading t={t} heading={t(heading)} />}
headerBarEnd={<CloseBtn onClick={closeModal} />}
actionCancelLabel={t("CS_COMMON_CANCEL")}
actionCancelOnSubmit={closeModal}
actionSaveLabel={t("WBH_EVENT_DELETE")}
actionSaveOnSubmit={(confirmed) => onSubmit(confirmed)}
>
<Card style={{ boxShadow: "none" }}>{t("WBH_DELETE_TEXT")}</Card>
</Modal>
);
};
export default ConfirmationDialog;
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { Card, Header, Button, Loader } from "@egovernments/digit-ui-react-components";
import { data } from "../configs/ViewProjectConfig";

const FacilityComponent = (props) => {
const { t } = useTranslation();

const requestCriteria = {
url: "/project/facility/v1/_search",
changeQueryName: props.projectId,
params: {
tenantId: "mz",
offset: 0,
limit: 10,
},

body: {
ProjectFacility: {
"projectId": [props.projectId]
},
}
};

const { isLoading, data: projectFacility } = Digit.Hooks.useCustomAPIHook(requestCriteria);


const facilityRequestCriteria = {
url: "/facility/v1/_search",
changeQueryName: projectFacility?.ProjectFacilities?.[0]?.facilityId,
params: {
tenantId: "mz",
offset: 0,
limit: 10,
},

body: {
Facility: {
"id": [projectFacility?.ProjectFacilities?.[0]?.facilityId]
},
}
};

const { isLoadingFacilty, data: Facility } = Digit.Hooks.useCustomAPIHook(facilityRequestCriteria);

const updatedProjectFacility = projectFacility?.ProjectFacilities.map(row => {
const facilityData = Facility?.Facilities?.find(facility => facility.id === row.facilityId);
return {
...row,
storageCapacity: facilityData?.storageCapacity || "NA",
name: facilityData?.name || "NA",
usage: facilityData?.usage || "NA",
address: facilityData?.address || "NA",
};
});

const columns = [
{ label: t("FACILITY_ID"), key: "facilityId" },
{ label: t("PROJECT_FACILITY_ID"), key: "id" },
{ label: t("STORAGE_CAPACITY"), key: "storageCapacity" },
{ label: t("FACILITY_NAME"), key: "name" },
{ label: t("FACILITY_USAGE"), key: "usage" }
];


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

return (
<div className="override-card">
<Header className="works-header-view">{t("FACILITY")}</Header>
{updatedProjectFacility?.length === 0 ? (
<h1>{t("NO_FACILITY")}</h1>
) : (
<table className="table reports-table sub-work-table">
<thead>
<tr>
{columns.map((column, index) => (
<th key={index}>{column.label}</th>
))}
</tr>
</thead>
<tbody>
{updatedProjectFacility?.map((row, rowIndex) => (
<tr key={rowIndex}>
{columns.map((column, columnIndex) => (
<td key={columnIndex}>
{row[column.key] || "NA"}
</td>
))}
</tr>
))}
</tbody>
</table>
)
}

</div>

)
}

export default FacilityComponent
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { Card, Header, Button, Loader } from "@egovernments/digit-ui-react-components";
import { data } from "../configs/ViewProjectConfig";

const ProductDeliveryComponent = (props) => {
const { t } = useTranslation();

const requestCriteria = {
url: "/product/v1/_search",
changeQueryName:props.projectId,
params: {
tenantId : "mz",
offset: 0,
limit: 10,
},

body: {
Product: {

},
// apiOperation: "SEARCH"
}
};

const {isLoading, data: product } = Digit.Hooks.useCustomAPIHook(requestCriteria);
// console.log("product",product);


const columns = [
{ label: t("PRODUCT_ID"), key: "id" },
{ label: t("MANUFACTURER"), key: "manufacturer" },
{ label: t("NAME"), key: "name" },
{ label: t("TYPE"), key: "type" }
];


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

return (
<div className="override-card">
<Header className="works-header-view">{t("PRODUCT")}</Header>
{product?.Product.length === 0 ? (
<h1>{t("NO_PRODUCT")}</h1>
) : (
<table className="table reports-table sub-work-table">
<thead>
<tr>
{columns.map((column, index) => (
<th key={index}>{column.label}</th>
))}
</tr>
</thead>
<tbody>
{product?.Product.map((row, rowIndex) => (
<tr key={rowIndex}>
{columns.map((column, columnIndex) => (
<td key={columnIndex}>
{row[column.key] || "NA"}
</td>
))}
</tr>
))}
</tbody>
</table>
)
}

</div>

)
}

export default ProductDeliveryComponent;
Loading

0 comments on commit 791eb35

Please sign in to comment.