Skip to content

Commit

Permalink
Updated the components version
Browse files Browse the repository at this point in the history
  • Loading branch information
jagankumar-egov committed Nov 18, 2024
1 parent c5c6adb commit 02b1cf2
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 14 deletions.
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 @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<div className="notice_and_circular_main">
<div className="notice_and_circular_image">
<GenericFileIcon height={`${isMobile ? 66 : 100}`} width={`${isMobile ? 53 : 100}`} />
</div>
<div className="notice_and_circular_content">
<div className="notice_and_circular_heading_mb">
<CardHeader>{documentTitle}</CardHeader>

{/* {documentSize ? <CardCaption>{getFileSize(documentSize)}</CardCaption> : null} */}
</div>
<div className="notice_and_circular_caption">
<CardCaption>{`${t(`CE_DCOUMENT_UPLOADED_ON`)} ${lastModifiedData ? format(new Date(lastModifiedData), "do MMMM yyyy") : "-"}`}</CardCaption>
</div>
<div className="notice_and_circular_text">
<CardText>
{description?.length ? description : "NA"}
</CardText>
</div>
<div className="view_download_main">
{filestoreId && filestoreId.length ? <LinkButton

label={
<div className="views"
// onClick={() => openUploadedDocument(filestoreId ? filestoreId : null, documentTitle)}
>
<ViewsIcon />
<p>{t(`CE_DOCUMENT_VIEW_LINK`)}</p>
</div>
}
/> : null
}
{documentLink && documentLink.length ?
(<LinkButton

label={
<div className="views"
// onClick={() => openDocumentLink(documentLink, documentTitle)}
>
<ExternalLinkIcon />
<p>{t(`CE_DOCUMENT_OPEN_LINK`)}</p>
</div>
}
/>) : null
}
{filestoreId && filestoreId.length ?
<LinkButton
label={
<div className="views download_views_padding" >
<DownloadImgIcon />
<p>{t(`CE_DOCUMENT_DOWNLOAD_LINK`)}</p>
</div>
}
// onClick={() => downloadDocument(filestoreId ? filestoreId : null, documentTitle)}
/> : null
}
</div>
</div>

</div>
)
}

export default DocumentCard;
Original file line number Diff line number Diff line change
@@ -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) => (
<EmployeeModuleCard key={index} longModuleName={true} {...propsForModuleCard} />
))}
</>
);

return result;
};

export default EngagementCard;
7 changes: 4 additions & 3 deletions micro-ui/web/micro-ui-internals/example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand Down Expand Up @@ -80,16 +80,17 @@ const initDigitUI = () => {
PGR: pgrCustomizations,
commonUiConfig: UICustomizations,
};
initEngagementComponents();

window?.Digit.ComponentRegistryService.setupRegistry({
...pgrComponents,
...overrideComponents,
// PaymentModule,
// ...paymentConfigs,
// PaymentLinks,
});
initCoreComponents();
initDSSComponents();
initHRMSComponents();
initEngagementComponents();
initUtilitiesComponents();
initWorkbenchComponents();
initPGRComponents();
Expand Down
8 changes: 6 additions & 2 deletions micro-ui/web/micro-ui-internals/example/src/pgr.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -9,7 +11,9 @@ const pgrCustomizations = {
},
};

const pgrComponents = {
const overrideComponents = {
SelectName: SelectName,
DocumentCard,
EngagementCard
};
export { pgrCustomizations, pgrComponents };
export { pgrCustomizations, overrideComponents };
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 />,
Icon: "File",
moduleName: t("ES_PGR_HEADER_COMPLAINT"),
kpis: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const componentsToRegister = {
SandboxModule,
SandboxCard,
WorkbenchCard: null,
HRMSCard:null,
SandboxModuleCard: ModuleCard,
ConfigUploaderComponent,
LogoUploaderComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const HRMSCard = () => {
// const { isLoading, isError, error, data, ...rest } = Digit.Hooks.hrms.useHRMSCount(tenantId);

const propsForModuleCard = {
Icon: <HRIcon />,
Icon: 'SupervisorAccount',
moduleName: t("ACTION_TEST_9HRMS"),
kpis: [
// {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down

0 comments on commit 02b1cf2

Please sign in to comment.