From 02b1cf2ded5924a0ed88690b0413cd74d6a928b7 Mon Sep 17 00:00:00 2001 From: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:23:42 +0530 Subject: [PATCH] Updated the components version --- .../micro-ui-internals/example/package.json | 4 +- .../example/src/components/DocumentCard.js | 86 +++++++++ .../example/src/components/EngagementCard.js | 169 ++++++++++++++++++ .../micro-ui-internals/example/src/index.js | 7 +- .../web/micro-ui-internals/example/src/pgr.js | 8 +- .../packages/modules/pgr/package.json | 2 +- .../modules/pgr/src/components/PGRCard.js | 2 +- .../packages/modules/sandbox/src/Module.js | 1 + .../packages/modules/workbench/package.json | 2 +- .../packages/modules/workbench/src/Module.js | 2 +- .../workbench/src/components/HRMSCard.js | 2 +- .../workbench/src/components/WorkbenchCard.js | 2 - 12 files changed, 273 insertions(+), 14 deletions(-) create mode 100644 micro-ui/web/micro-ui-internals/example/src/components/DocumentCard.js create mode 100644 micro-ui/web/micro-ui-internals/example/src/components/EngagementCard.js diff --git a/micro-ui/web/micro-ui-internals/example/package.json b/micro-ui/web/micro-ui-internals/example/package.json index aa4b438a4f9..2993d9000de 100644 --- a/micro-ui/web/micro-ui-internals/example/package.json +++ b/micro-ui/web/micro-ui-internals/example/package.json @@ -10,8 +10,8 @@ }, "devDependencies": { "@egovernments/digit-ui-libraries": "1.8.2-beta.8", - "@egovernments/digit-ui-module-workbench": "1.0.2-beta.10", - "@egovernments/digit-ui-module-pgr": "1.8.1-beta.2", + "@egovernments/digit-ui-module-workbench": "1.0.2-beta.11", + "@egovernments/digit-ui-module-pgr": "1.8.1-beta.3", "@egovernments/digit-ui-module-dss": "1.8.1-beta.1", "@egovernments/digit-ui-module-core": "1.8.2-beta.29", "@egovernments/digit-ui-module-common": "1.8.1-beta.1", diff --git a/micro-ui/web/micro-ui-internals/example/src/components/DocumentCard.js b/micro-ui/web/micro-ui-internals/example/src/components/DocumentCard.js new file mode 100644 index 00000000000..1ce1f4b2f4d --- /dev/null +++ b/micro-ui/web/micro-ui-internals/example/src/components/DocumentCard.js @@ -0,0 +1,86 @@ +import React from 'react' +import { + Card, + CardCaption, + CardHeader, + CardText, + LinkButton, + DownloadImgIcon, + ViewsIcon, + ExternalLinkIcon, + GenericFileIcon, + PDFSvg +} from "@egovernments/digit-ui-react-components"; +import { format } from 'date-fns'; +// import { getFileSize } from '../../utils'; +var Digit = window.Digit || {}; + + +const DocumentCard = ({ documentTitle, documentSize = 2.3, lastModifiedData, description, filestoreId, documentLink, t }) => { + let isMobile = window.Digit.Utils.browser.isMobile(); + + + return ( +
+
+ +
+
+
+ {documentTitle} + + {/* {documentSize ? {getFileSize(documentSize)} : null} */} +
+
+ {`${t(`CE_DCOUMENT_UPLOADED_ON`)} ${lastModifiedData ? format(new Date(lastModifiedData), "do MMMM yyyy") : "-"}`} +
+
+ + {description?.length ? description : "NA"} + +
+
+ {filestoreId && filestoreId.length ? openUploadedDocument(filestoreId ? filestoreId : null, documentTitle)} + > + +

{t(`CE_DOCUMENT_VIEW_LINK`)}

+
+ } + /> : null + } + {documentLink && documentLink.length ? + ( openDocumentLink(documentLink, documentTitle)} + > + +

{t(`CE_DOCUMENT_OPEN_LINK`)}

+
+ } + />) : null + } + {filestoreId && filestoreId.length ? + + +

{t(`CE_DOCUMENT_DOWNLOAD_LINK`)}

+
+ } + // onClick={() => downloadDocument(filestoreId ? filestoreId : null, documentTitle)} + /> : null + } + + + + + ) +} + +export default DocumentCard; diff --git a/micro-ui/web/micro-ui-internals/example/src/components/EngagementCard.js b/micro-ui/web/micro-ui-internals/example/src/components/EngagementCard.js new file mode 100644 index 00000000000..e02d3999dc0 --- /dev/null +++ b/micro-ui/web/micro-ui-internals/example/src/components/EngagementCard.js @@ -0,0 +1,169 @@ +import React, { useEffect, Fragment, useMemo, useState } from "react"; +import { Link } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import { + EmployeeModuleCard, + DocumentIconSolid, + EventsIconSolid, + PMBIconSolid, + SurveyIconSolid, + PropertyHouse, +} from "@egovernments/digit-ui-react-components"; +var Digit = window.Digit || {}; + +const EngagementCard = () => { + const userRoles = Digit.SessionStorage.get("User")?.info?.roles; + const isEmployee = userRoles.find((role) => role.code === "EMPLOYEE"); + + useEffect(() => { + Digit.SessionStorage.set("CITIZENSURVEY.INBOX", null); + }, []); + + if (!isEmployee) return null; + const tenantId = Digit.ULBService.getCurrentTenantId(); + const { data: documentsCount, isLoading: isLoadingDocs } = Digit.Hooks.engagement.useDocSearch( + { tenantIds: tenantId }, + { + select: (data) => { + return data?.totalCount; + }, + } + ); + const { data: MessagesCount, isLoading: isLoadingMessages } = Digit.Hooks.events.useInbox( + tenantId, + {}, + { status: "ACTIVE,INACTIVE", eventTypes: "BROADCAST" }, + { + select: (data) => data?.totalCount, + } + ); + + const { data: totalEvents, isLoading: isLoadingEvents } = Digit.Hooks.events.useInbox( + tenantId, + {}, + { eventTypes: "EVENTSONGROUND" }, + { + select: (data) => data?.totalCount, + } + ); + + const { data: surveysCount, isLoading: isLoadingSurveys } = Digit.Hooks.survey.useSearch( + { tenantIds: tenantId }, + { select: (data) => data?.TotalCount } + ); + + const totalDocsCount = useMemo(() => (isLoadingDocs ? "-" : documentsCount), [isLoadingDocs, documentsCount]); + const totalEventsCount = useMemo(() => (isLoadingEvents ? "-" : totalEvents), [isLoadingEvents, totalEvents]); + const totalMessagesCount = useMemo(() => (isLoadingMessages ? "-" : MessagesCount), [isLoadingMessages, MessagesCount]); + const totalSurveysCount = useMemo(() => (isLoadingSurveys ? "-" : surveysCount), [isLoadingSurveys, surveysCount]); + + const { t } = useTranslation(); + let result = null; + + const propsForSurveyModuleCard = { + Icon: "ImportContacts", + moduleName: t("CS_COMMON_SURVEYS"), + kpis: [ + { + count: totalSurveysCount, + label: t("TOTAL_SURVEYS"), + link: `/${window?.contextPath}/employee/engagement/surveys/inbox`, + }, + ], + links: [ + { + count: totalSurveysCount, + label: t("ES_TITLE_INBOX"), + link: `/${window?.contextPath}/employee/engagement/surveys/inbox`, + }, + { + label: t("CS_COMMON_NEW_SURVEY"), + link: `/${window?.contextPath}/employee/engagement/surveys/create`, + }, + ], + }; + + const propsForPMBModuleCard = { + Icon: "Campaign", + moduleName: t("ACTION_TEST_PUBLIC_MESSAGE_BROADCAST"), + kpis: [ + { + count: totalMessagesCount, + label: t("TOTAL_MESSAGES"), + link: `/${window?.contextPath}/employee/engagement/messages/inbox`, + }, + ], + + links: [ + { + count: totalMessagesCount, + label: t("ES_TITLE_INBOX"), + link: `/${window?.contextPath}/employee/engagement/messages/inbox`, + }, + { + label: t("NEW_PUBLIC_MESSAGE_BUTTON_LABEL"), + link: `/${window?.contextPath}/employee/engagement/messages/create`, + }, + ], + }; + const propsForEventsModuleCard = { + Icon: "Event", + moduleName: t("TOTAL_EVENTS"), + kpis: [ + { + count: totalEventsCount, + label: t("TOTAL_EVENTS"), + link: `/${window?.contextPath}/employee/engagement/event/inbox`, + }, + ], + + links: [ + { + count: totalEventsCount, + label: t("ES_TITLE_INBOX"), + link: `/${window?.contextPath}/employee/engagement/event/inbox`, + }, + { + label: t("ES_TITLE_NEW_EVENTS"), + link: `/${window?.contextPath}/employee/engagement/event/new-event`, + }, + ], + }; + const propsForDocumentModuleCard = { + Icon: "File", + moduleName: t("ES_TITLE_DOCS"), + kpis: [ + { + count: totalDocsCount, + label: t("TOTAL_DOCUMENTS"), + link: `/${window?.contextPath}/employee/engagement/documents/inbox`, + }, + ], + links: [ + { + count: totalDocsCount, + label: t("ES_TITLE_INBOX"), + link: `/${window?.contextPath}/employee/engagement/documents/inbox`, + }, + { + label: t("NEW_DOCUMENT_TEXT"), + link: `/${window?.contextPath}/employee/engagement/documents/new-doc`, + }, + ], + }; + + const engagementSubModulesProps = [propsForDocumentModuleCard, propsForEventsModuleCard, propsForPMBModuleCard, propsForSurveyModuleCard]; + + if (isEmployee) + result = ( + <> + {engagementSubModulesProps.map((propsForModuleCard, index) => ( + + ))} + + ); + + return result; +}; + +export default EngagementCard; diff --git a/micro-ui/web/micro-ui-internals/example/src/index.js b/micro-ui/web/micro-ui-internals/example/src/index.js index abfc8a9170c..78ef2be0806 100644 --- a/micro-ui/web/micro-ui-internals/example/src/index.js +++ b/micro-ui/web/micro-ui-internals/example/src/index.js @@ -15,7 +15,7 @@ import { initSandboxComponents } from "@egovernments/digit-ui-module-sandbox"; import "@egovernments/digit-ui-css/example/index.css"; -import { pgrCustomizations, pgrComponents } from "./pgr"; +import { pgrCustomizations, overrideComponents } from "./pgr"; import { UICustomizations } from "./UICustomizations"; var Digit = window.Digit || {}; @@ -80,8 +80,10 @@ const initDigitUI = () => { PGR: pgrCustomizations, commonUiConfig: UICustomizations, }; + initEngagementComponents(); + window?.Digit.ComponentRegistryService.setupRegistry({ - ...pgrComponents, + ...overrideComponents, // PaymentModule, // ...paymentConfigs, // PaymentLinks, @@ -89,7 +91,6 @@ const initDigitUI = () => { initCoreComponents(); initDSSComponents(); initHRMSComponents(); - initEngagementComponents(); initUtilitiesComponents(); initWorkbenchComponents(); initPGRComponents(); diff --git a/micro-ui/web/micro-ui-internals/example/src/pgr.js b/micro-ui/web/micro-ui-internals/example/src/pgr.js index 48a498e4582..06d56419cac 100644 --- a/micro-ui/web/micro-ui-internals/example/src/pgr.js +++ b/micro-ui/web/micro-ui-internals/example/src/pgr.js @@ -1,3 +1,5 @@ +import DocumentCard from "./components/DocumentCard"; +import EngagementCard from "./components/EngagementCard"; import SelectName from "./components/SelectName"; // import { config as complaintConfig } from "./complaintConfig"; @@ -9,7 +11,9 @@ const pgrCustomizations = { }, }; -const pgrComponents = { +const overrideComponents = { SelectName: SelectName, + DocumentCard, + EngagementCard }; -export { pgrCustomizations, pgrComponents }; +export { pgrCustomizations, overrideComponents }; diff --git a/micro-ui/web/micro-ui-internals/packages/modules/pgr/package.json b/micro-ui/web/micro-ui-internals/packages/modules/pgr/package.json index 0fc38419bd0..50c38d00cec 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/pgr/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/pgr/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-pgr", - "version": "1.8.1-beta.2", + "version": "1.8.1-beta.3", "license": "MIT", "main": "dist/index.js", "module": "dist/index.modern.js", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/PGRCard.js b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/PGRCard.js index 0e62f6a8fe9..784845f909f 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/PGRCard.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/PGRCard.js @@ -48,7 +48,7 @@ let propsForSandbox = [ propsForCSR = propsForCSR.filter(link => link?.roles ? Digit.Utils.didEmployeeHasAtleastOneRole(link.roles) : true ); propsForSandbox = propsForSandbox.filter(link => link?.roles ? Digit.Utils.didEmployeeHasAtleastOneRole(link.roles) : true ); const propsForModuleCard = { - Icon: , + Icon: "File", moduleName: t("ES_PGR_HEADER_COMPLAINT"), kpis: [ { diff --git a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/Module.js b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/Module.js index 4b3faeedb5f..3565b81a36a 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/Module.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/Module.js @@ -34,6 +34,7 @@ const componentsToRegister = { SandboxModule, SandboxCard, WorkbenchCard: null, + HRMSCard:null, SandboxModuleCard: ModuleCard, ConfigUploaderComponent, LogoUploaderComponent diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json b/micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json index 909316fbd50..c8f1e0ceda1 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-workbench", - "version": "1.0.2-beta.10", + "version": "1.0.2-beta.11", "description": "Workbench", "main": "dist/index.js", "module": "dist/index.modern.js", diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/Module.js b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/Module.js index 9f82135cb1a..695782a4b98 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/Module.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/Module.js @@ -35,7 +35,7 @@ const componentsToRegister = { DigitJSONForm, LevelCards, DSSCard: null, // TO HIDE THE DSS CARD IN HOME SCREEN as per workbench - // HRMSCard // Overridden the HRMS card as per workbench + HRMSCard // Overridden the HRMS card as per workbench }; const overrideHooks = () => { diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/HRMSCard.js b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/HRMSCard.js index 9e4124b6550..660ea534e53 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/HRMSCard.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/HRMSCard.js @@ -12,7 +12,7 @@ const HRMSCard = () => { // const { isLoading, isError, error, data, ...rest } = Digit.Hooks.hrms.useHRMSCount(tenantId); const propsForModuleCard = { - Icon: , + Icon: 'SupervisorAccount', moduleName: t("ACTION_TEST_9HRMS"), kpis: [ // { diff --git a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/WorkbenchCard.js b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/WorkbenchCard.js index 6dd193223e4..bba867feb22 100644 --- a/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/WorkbenchCard.js +++ b/micro-ui/web/micro-ui-internals/packages/modules/workbench/src/components/WorkbenchCard.js @@ -13,9 +13,7 @@ const WorkbenchCard = () => { if (!Digit.Utils.didEmployeeHasAtleastOneRole(Object.values(ROLES).flatMap((e) => e))) { return null; } - const { t } = useTranslation(); - const tenantId = Digit.ULBService.getCurrentTenantId(); let links = [ {