From edc826254007e09bd19887963cf491c31bedf68b Mon Sep 17 00:00:00 2001 From: ishaan-egov Date: Tue, 6 May 2025 17:03:27 +0530 Subject: [PATCH 01/35] fetch_bills_screen - open overlay on click --- .../src/components/UploadAndFetchBillsCard.js | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 health/micro-ui/web/micro-ui-internals/packages/modules/health-payments/src/components/UploadAndFetchBillsCard.js diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/health-payments/src/components/UploadAndFetchBillsCard.js b/health/micro-ui/web/micro-ui-internals/packages/modules/health-payments/src/components/UploadAndFetchBillsCard.js new file mode 100644 index 00000000000..f16132676dc --- /dev/null +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/health-payments/src/components/UploadAndFetchBillsCard.js @@ -0,0 +1,172 @@ +import { EmployeeModuleCard, SVG } from "@egovernments/digit-ui-react-components"; +import React, { useEffect,useState } from "react"; +import { useTranslation } from "react-i18next"; +import { Card, Header, Button, ActionBar, Dropdown, Toast,PopUp } from "@egovernments/digit-ui-components"; +import { CloudDownload } from "../../../../../../../../../micro-ui/web/micro-ui-internals/packages/svg-components/src"; +import { FileUpload } from "../../../../../../../../../micro-ui/web/micro-ui-internals/packages/svg-components/src"; +import MyBills from "../pages/employee/my_bills"; +import VerifyBills from "../pages/employee/verify_bills"; + +const ROLES = { + ATTENDANCE: ["PROXIMITY_SUPERVISOR"], + BILLS: ["CAMPAIGN_SUPERVISOR"], +}; + +const UploadAndFetchBillsCard = () => { + // Reset session storage + useEffect(() => { + Digit.SessionStorage.del("paymentInbox"); + Digit.SessionStorage.del("selectedValues"); + Digit.SessionStorage.del("selectedLevel"); + Digit.SessionStorage.del("selectedProject"); + Digit.SessionStorage.del("selectedBoundaryCode"); + Digit.SessionStorage.del("boundary"); + }, []); + const [showModal, setShowModal] = useState(false); + + const openModal = () => setShowModal(true); + const closeModal = () => setShowModal(false); + + const { t } = useTranslation(); + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + const generateLink = (labelKey, pathSuffix, roles = ROLES.ATTENDANCE) => { + return { + label: t(labelKey), + link: `/${window?.contextPath}/employee/payments/${pathSuffix}`, + roles: roles, + }; + }; + + if (!Digit.Utils.didEmployeeHasAtleastOneRole(Object.values(ROLES).flatMap((e) => e))) { + return null; + } + + let links = [ + generateLink("ATTENDANCE_REGISTERS", "project-selection"), + generateLink("CS_COMMON_INBOX", "project-and-aggregation-selection", ROLES.BILLS), + generateLink("CS_TITLE_MY_BILLS", "my-bills", ROLES.BILLS), + generateLink("VERIFY-BILLS", "verify-bills", ROLES.BILLS), + ]; + const hasRequiredRoles = (link) => { + if (!link?.roles?.length) return true; + return Digit.Utils.didEmployeeHasAtleastOneRole(link.roles); + }; + links = links.filter(hasRequiredRoles); + + const propsForUploadBillsCard = { + Icon: "UpdateExpense", + moduleName: t("UPLOAD_LOCAL_BILLS"), + kpis: [], + links: links, + }; + const propsForFetchBillsCard = { + Icon: "UpdateExpense", + moduleName: t("FETCH_HCM_BILLS"), + kpis: [], + links: links, + }; + return ( + +
+ +
+
{t("UPLOAD_OR_FETCH_BILLS")}
+
{t("PLEASE_SELECT_ONE")}
+
+
+
+ +
+ +
+
{t("UPLOAD_BILLS")}
+
+ + +
+ +
+
{t("FETCH_BILLS")}
+
+
+
+
+ {showModal && ( + + + + )} +
+ , +