diff --git a/health/micro-ui/web/micro-ui-internals/example/package.json b/health/micro-ui/web/micro-ui-internals/example/package.json index 2d8c8857b45..e1bd379be46 100644 --- a/health/micro-ui/web/micro-ui-internals/example/package.json +++ b/health/micro-ui/web/micro-ui-internals/example/package.json @@ -14,7 +14,7 @@ "@egovernments/digit-ui-components": "0.0.2-beta.1", "@egovernments/digit-ui-module-core": "1.8.2-beta.2", "@egovernments/digit-ui-module-utilities": "1.0.1-beta.30", - "@egovernments/digit-ui-react-components": "1.8.2-beta.6", + "@egovernments/digit-ui-react-components": "1.8.2-beta.10", "@egovernments/digit-ui-module-hcmworkbench":"0.0.38", "@egovernments/digit-ui-module-campaign-manager": "0.0.1", "@egovernments/digit-ui-module-hcmmicroplanning": "0.0.1", diff --git a/health/micro-ui/web/micro-ui-internals/package.json b/health/micro-ui/web/micro-ui-internals/package.json index d15c627d3ab..9c291afc34b 100644 --- a/health/micro-ui/web/micro-ui-internals/package.json +++ b/health/micro-ui/web/micro-ui-internals/package.json @@ -47,7 +47,7 @@ "ajv": "8.12.0", "lodash": "4.17.21", "microbundle-crl": "0.13.11", - "@egovernments/digit-ui-react-components": "1.8.2-beta.6", + "@egovernments/digit-ui-react-components": "1.8.2-beta.10", "@egovernments/digit-ui-components": "0.0.2-beta.1", "react": "17.0.2", "react-dom": "17.0.2", diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json index 41e43fdb6fd..6bf03a8c422 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/package.json @@ -18,7 +18,7 @@ "react-router-dom": "5.3.0" }, "dependencies": { - "@egovernments/digit-ui-react-components": "1.8.2-beta.6", + "@egovernments/digit-ui-react-components": "1.8.2-beta.10", "@egovernments/digit-ui-components": "0.0.2-beta.1", "@rjsf/core": "5.10.0", "@rjsf/utils": "5.10.0", diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/Module.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/Module.js index cc2f33443d4..049aa1dbe03 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/Module.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/Module.js @@ -24,6 +24,7 @@ import AddProductField from "./components/AddProductField"; import CycleDataPreview from "./components/CycleDataPreview"; import { ErrorBoundary } from "@egovernments/digit-ui-components"; import CampaignResourceDocuments from "./components/CampaignResourceDocuments"; +import { DSSCard } from "./components/DSSCard"; /** * The CampaignModule function fetches store data based on state code, module code, and language, and @@ -82,6 +83,7 @@ const componentsToRegister = { AddProductField, CycleDataPreview, CampaignResourceDocuments, + DSSCard }; const overrideHooks = () => { diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DSSCard.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DSSCard.js new file mode 100644 index 00000000000..97ee3a85608 --- /dev/null +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DSSCard.js @@ -0,0 +1,209 @@ +import { EmployeeModuleCard, ModuleCardFullWidth, DSSIcon } from "@egovernments/digit-ui-react-components"; +import React from "react"; +import { useTranslation } from "react-i18next"; + +const nationalScreenURLs = { + overview: { key: "national-overview", stateKey: "overview", label: "NURT_OVERVIEW", active: true, nActive: true }, + propertytax: { key: "national-propertytax", stateKey: "propertytax", label: "NURT_PROPERTY_TAX", active: true, nActive: true }, + tradelicense: { key: "national-tradelicense", stateKey: "tradelicense", label: "NURT_TRADE_LICENCE", active: true, nActive: true }, + pgr: { key: "national-pgr", stateKey: "pgr", label: "NURT_COMPLAINS", active: true, nActive: true }, + fsm: { key: "fsm", stateKey: "fsm", label: "CS_HOME_FSM_SERVICES", active: true, nActive: false }, + mCollect: { key: "national-mcollect", stateKey: "mCollect", label: "NURT_MCOLLECT", active: true, nActive: true }, + ws: { key: "national-ws", stateKey: "ws", label: "NURT_WATER_SEWERAGE", active: true, nActive: true }, + obps: { key: "nss-obps", stateKey: "obps", label: "DSS_BUILDING_PERMISSION", active: true, nActive: true }, + noc: { key: "national-firenoc", stateKey: "noc", label: "NURT_FIRENOC", active: true, nActive: true }, + bnd: { key: "nss-birth-death", stateKey: "birth-death", label: "BIRTH_AND_DEATH", active: true, nActive: true }, + faqs: { key: "national-faqs", stateKey: "national-faqs", label: "DSS_FAQS", active: false, nActive: true, others: true }, + finance: { key: "national-finance", stateKey: "finance", label: "DSS_FINANCE", active: true, nActive: false }, + about: { key: "national-about", stateKey: "national-about", label: "DSS_ABOUT_DASHBOARD", active: false, nActive: true, others: true }, +}; + +const healthDSSURLs = { + about: { key: "about", stateKey: "about", label: "DSS_ABOUT", active: true }, + faqs: { key: "faqs", stateKey: "faqs", label: "DSS_FAQS", active: true }, + calculations: { key: "calculations", stateKey: "calculations", label: "DSS_CALCULATIONS", active: true } +}; + +export const checkCurrentScreen = () => { + const moduleName = Digit.Utils.dss.getCurrentModuleName(); + const nationalURLS = Object.keys(nationalScreenURLs).map((key) => nationalScreenURLs[key].key); + return nationalURLS.filter(ele=>ele!=="fsm").some((e) => moduleName?.includes(e)); +}; + +const NDSSCard = () => { + const NATADMIN = Digit.UserService.hasAccess("NATADMIN"); + const { t } = useTranslation(); + + if (!NATADMIN) { + return null; + } + + let links = Object.values(nationalScreenURLs) + .filter((ele) => ele["nActive"] === true) + .map((obj) => ({ + label: t(obj?.label), + link: `/digit-ui/employee/dss/dashboard/${obj?.key}`, + link: obj?.others?`/digit-ui/employee/dss/${obj?.key}`:`/digit-ui/employee/dss/dashboard/${obj?.key}`, + })); + + const propsForModuleCard = { + headerStyle: { border: "none", height: "48px" }, + moduleName: t("ACTION_TEST_NATDASHBOARD"), + subHeader: t("ACTION_TEST_NATDASHBOARD"), + subHeaderLink: `/digit-ui/employee/dss/landing/NURT_DASHBOARD`, + className: "employeeCard customEmployeeCard card-home full-width-card full-employee-card-height", + links: [...links], + }; + return ; +}; + +const DSSCard = () => { + const STADMIN = Digit.UserService.hasAccess("STADMIN"); + const { t } = useTranslation(); + + const { data: tenantData } = Digit.Hooks.dss.useMDMS(Digit.ULBService.getStateId(), "tenant", ["tenants"], { + select: (data) => { + const tenantData = data?.["tenant"]?.["tenants"]?.[0]; + return tenantData; + }, + enabled: true, + }); + + const shouldInvokeProjectService = tenantData?.integrateProjectService || false; + if (shouldInvokeProjectService) { + return ; + } + + if (!STADMIN) { + return null; + } + + let links = Object.values(nationalScreenURLs) + .filter((ele) => ele["active"] === true) + .map((obj) => ({ + label: t(obj?.label), + link: obj.active ? `/digit-ui/employee/dss/dashboard/${obj?.stateKey}` : `/employee/integration/dss/${obj?.stateKey}`, + })); + + const propsForModuleCard = { + headerStyle: { border: "none", height: "48px" }, + moduleName: t("ES_TITLE_DSS"), + subHeader: t("ACTION_TEST_SURE_DASHBOARD"), + subHeaderLink: `/digit-ui/employee/dss/landing/home`, + className: "employeeCard card-home customEmployeeCard full-width-card full-employee-card-height", + links: [...links], + }; + return ; +}; + +const DynamicDSSCard = () => { + const { t } = useTranslation(); + + const isNationalSupervisor = Digit.UserService.hasAccess(["NATIONAL_SUPERVISOR"]); + const isProvincialSupervisor = Digit.UserService.hasAccess(["PROVINCIAL_SUPERVISOR"]); + const isDistrictSupervisor = Digit.UserService.hasAccess(["DISTRICT_SUPERVISOR"]); + const isHealthFacilitySupervisor = Digit.UserService.hasAccess(["HEALTH_FACILITY_SUPERVISOR"]); + const isCommunitySupervisor = Digit.UserService.hasAccess(["COMMUNITY_SUPERVISOR"]); + + const projectTypes = Digit.SessionStorage.get("projectTypes"); + const campaignData = Digit.SessionStorage.get("campaigns-info"); + + if(!isCommunitySupervisor && !isHealthFacilitySupervisor){ + if (!campaignData || !projectTypes) { + return null; + } + } + const generateLinks = (location, code) => { + let links = []; + Object.keys(campaignData)?.map((key) => { + if (key === "LLIN-Default") { + const campaignType = campaignData[key]; + campaignType.forEach((data) => { + const locationParam = data.boundaries?.[location]?.[0]; + const url = projectTypes?.filter(project => project?.code === "LLIN-Default")[0]?.dashboardUrls?.[code] + links.push({ + label: `${t(key)} - ${Digit.Utils.locale.getTitleHeading(locationParam)}`, + link: location === "province" ? `${url}?province=${locationParam}` : `${url}`, + }); + }) + } + }); + return links; + }; + + let links = []; + + // if (isNationalSupervisor) { + // links = Object.keys(campaignData)?.map((key) => { + // return { + // label: `${t(`${key}`)} - Mozambique`, + // link: projectTypes?.filter(project => project?.code === key)[0]?.dashboardUrls?.["NATIONAL_SUPERVISOR"] + // }; + // }); + // } else if (isProvincialSupervisor) { + // links = generateLinks("province","PROVINCIAL_SUPERVISOR"); + // } else if (isDistrictSupervisor) { + // links = generateLinks("district","DISTRICT_SUPERVISOR"); + // } + // links.push(...Object.values(healthDSSURLs) + // .filter((ele) => ele["active"] === true) + // .map((obj) => ({ + // label: t(obj?.label), + // link: `/digit-ui/employee/dss/${obj?.stateKey}` + // }))); + + if (isNationalSupervisor) { + links.push({ + label: t("NATIONAL_DASHBOARD"), + link: "/digit-ui/employee/utilities/iframe/elastic/national" + }); + // TODO: To remove these hardcoded urls and generate all of this from mdms config + links.push({ + label: t("NDSS_DASHBOARD"), + link: "/digit-ui/employee/dss/landing/national-health-dashboard" + }) + } else if (isProvincialSupervisor) { + links.push({ + label: t("PROVINCIAL_DASHBOARD"), + link: "/digit-ui/employee/utilities/iframe/elastic/province?query=true" + }) + links = [...links, ...generateLinks("province","PROVINCIAL_SUPERVISOR")] + } else if (isDistrictSupervisor) { + links.push({ + label: t("DISTRICT_DASHBOARD"), + link: "/digit-ui/employee/utilities/iframe/elastic/district?query=true" + }) + links = [...links, ...generateLinks("district","DISTRICT_SUPERVISOR")] + console.log(links) + } + else if(isHealthFacilitySupervisor){ + links.push({ + label: t("REFERRAL_DASHBOARD"), + link: "/digit-ui/employee/utilities/iframe/elastic/hf?query=true" + }) + } + + // if(isNationalSupervisor || isProvincialSupervisor || isDistrictSupervisor){ + // links.push({ + // label: t('CUSTOM_REPORTS_LINK'), + // link: Digit.SessionStorage.get("initData")?.stateInfo?.customReportsDriveLink, + // external: true + // }) + + // links.push({ + // label: t('FEEDBACK_LINK'), + // link: Digit.SessionStorage.get("initData")?.stateInfo?.feedbackLink, + // external: true + // }) + // } + + const propsForModuleCard = { + Icon: , + moduleName: t("DSS_CARD_HEADER_DASHBOARD"), + links: [...links], + }; + + return ; +}; + +export { DSSCard, NDSSCard }; \ No newline at end of file diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js index 239cf948ee0..95f90030602 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js @@ -47,6 +47,60 @@ function SelectingBoundaries({ onSelect, formData, ...props }) { const lowestChild = hierarchyTypeDataresult?.boundaryHierarchy.filter((item) => item.parentBoundaryType === lowestHierarchy)?.[0]?.boundaryType; const searchParams = new URLSearchParams(location.search); const isDraft = searchParams.get("draft"); + const draftBoundary = searchParams.get("draftBoundary"); + + function updateUrlParams(params) { + const url = new URL(window.location.href); + Object.entries(params).forEach(([key, value]) => { + url.searchParams.set(key, value); + }); + window.history.replaceState({}, "", url); + } + + const fetchOptions = async ()=>{ + setLoaderEnabled(true); + const draftSelected = props?.props?.sessionData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType?.selectedData; + for (const item of draftSelected) { + const code = item?.code; + const parent = item?.parent; + const boundary = item?.type; + + const childBoundary = props?.props?.dataParams?.hierarchy?.boundaryHierarchy.filter((item) => item.parentBoundaryType === boundary)?.[0]?.boundaryType; + const reqCriteriaBoundaryTypeSearch = await Digit.CustomService.getResponse({ + url: "/boundary-service/boundary-relationships/_search", + params: { + tenantId: tenantId, + hierarchyType: props?.props?.dataParams?.hierarchyType, + boundaryType: childBoundary, + parent: code, + }, + body: {}, + }); + const boundaryTypeData = reqCriteriaBoundaryTypeSearch; + + setBoundaryData((prevBoundaryData) => { + const existingData = prevBoundaryData[childBoundary] || []; + + // Check if the entry already exists + const updatedData = { + ...prevBoundaryData, + [childBoundary]: [...existingData.filter((entry) => entry.parentCode !== code), { parentCode: code, boundaryTypeData }], + }; + return updatedData; + }); + } + updateUrlParams({ draftBoundary: false }); + setLoaderEnabled(false); + } + + useEffect(()=>{ + if(isDraft == "true" && props?.props?.dataParams?.hierarchy && + props?.props?.sessionData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType?.selectedData?.length > 0 && + draftBoundary === "true" + ){ + fetchOptions(); + } + },[isDraft,draftBoundary,props?.props?.dataParams?.hierarchy , props?.props?.sessionData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType?.selectedData]) useEffect(() => { if (!updateBoundary) { @@ -333,7 +387,7 @@ function SelectingBoundaries({ onSelect, formData, ...props }) { } else { // transformedRes = selectedData.filter((item) => item?.type === boundary?.boundaryType) const filteredData = selectedData.filter((item) => item?.type === boundary?.boundaryType); - if (filteredData.length === 0) { + if (filteredData.length === 0 || filteredData.length !== res.length) { // If no selected data for the particular boundary type, run the transformation logic transformedRes = res?.map((item) => ({ code: item.code, diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js index 4e72d9f98e1..d6565de7d04 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js @@ -47,7 +47,7 @@ const MyCampaign = () => { history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&preview=${true}&action=${false}`); break; case "CAMPAIGN_DRAFTS": - history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&draft=${true}&fetchBoundary=${true}`); + history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&draft=${true}&fetchBoundary=${true}&draftBoundary=${true}`); break; case "CAMPAIGN_FAILED": history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.id}&preview=${true}&action=${false}`); diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js index 0dc19dab4d7..847d58ec364 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js @@ -189,26 +189,28 @@ function groupByTypeRemap(data) { data.forEach((item) => { const type = item?.type; const boundaryType = item?.type; - const parentCode = item?.parent; - const obj = { - parentCode, - boundaryTypeData: { - TenantBoundary: [ - { - boundary: [{ ...item, boundaryType }], - }, - ], - }, - }; + const parentCode = item?.parent !== undefined ? item.parent : null; - if (result[type]) { - result[type][0].boundaryTypeData.TenantBoundary[0].boundary.push(item); - } else { - result[type] = [obj]; + if (!result[type]) { + result[type] = {}; + } + + if (!result[type][parentCode]) { + result[type][parentCode] = { + parentCode, + boundaryTypeData: { + TenantBoundary: [ + { + boundary: [], + }, + ], + }, + }; } - }); - return result; + const targetBoundaryArray = result[type][parentCode].boundaryTypeData.TenantBoundary[0].boundary; + targetBoundaryArray.push({ ...item, boundaryType }); + }); } // Example usage: diff --git a/health/micro-ui/web/package.json b/health/micro-ui/web/package.json index e90ab5a52ba..7336d39215c 100644 --- a/health/micro-ui/web/package.json +++ b/health/micro-ui/web/package.json @@ -18,7 +18,7 @@ "@egovernments/digit-ui-module-workbench": "1.0.1-beta.16", "@egovernments/digit-ui-module-core": "1.8.2-beta.2", "@egovernments/digit-ui-module-hrms": "1.8.0-beta.2", - "@egovernments/digit-ui-react-components": "1.8.2-beta.6", + "@egovernments/digit-ui-react-components": "1.8.2-beta.10", "@egovernments/digit-ui-components": "0.0.2-beta.1", "@egovernments/digit-ui-module-dss": "1.8.0-beta", "@egovernments/digit-ui-module-common": "1.8.0-beta", diff --git a/health/micro-ui/web/workbench/package.json b/health/micro-ui/web/workbench/package.json index 7cc60ef7bff..e849ea199f4 100644 --- a/health/micro-ui/web/workbench/package.json +++ b/health/micro-ui/web/workbench/package.json @@ -17,7 +17,7 @@ "@egovernments/digit-ui-components": "0.0.2-beta.1", "@egovernments/digit-ui-module-core": "1.8.2-beta.2", "@egovernments/digit-ui-module-utilities": "1.0.1-beta.30", - "@egovernments/digit-ui-react-components": "1.8.2-beta.6", + "@egovernments/digit-ui-react-components": "1.8.2-beta.10", "@egovernments/digit-ui-module-hcmworkbench":"0.0.38", "@egovernments/digit-ui-module-campaign-manager": "0.0.1", "babel-loader": "8.1.0",