From 2760c50ee4a467f1e72fc5c0998719d527075f11 Mon Sep 17 00:00:00 2001 From: Bhavya-egov <137176879+Bhavya-egov@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:03:01 +0530 Subject: [PATCH] fixed targetvalidation and added no results in boundary (#1768) --- .../modules/campaign-manager/src/Module.js | 4 +- .../src/components/CampaignUpdateSummary.js | 77 +++++++++++-------- .../src/components/NoResultsFound.js | 29 +++++++ .../src/components/UploadData.js | 2 + 4 files changed, 81 insertions(+), 31 deletions(-) create mode 100644 health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/NoResultsFound.js 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 0caf3513f18..1131214bd27 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 @@ -54,6 +54,7 @@ import ViewBoundary from "./pages/employee/ViewBoundary"; import ViewHierarchy from "./pages/employee/ViewHierarchy"; import MultiSelectDropdown from "./components/MultiSelectDropdown"; import MapView from "./components/MapView"; +import NoResultsFound from "./components/NoResultsFound"; /** * MDMS Module name @@ -156,7 +157,8 @@ const componentsToRegister = { ViewBoundary, ViewHierarchy, BoundarySummary, - MapView + MapView, + NoResultsFound }; const overrideHooks = () => { diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignUpdateSummary.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignUpdateSummary.js index 00fa9e2ff19..aee5defb135 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignUpdateSummary.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignUpdateSummary.js @@ -6,6 +6,7 @@ import { InfoBannerIcon, Toast } from "@egovernments/digit-ui-components"; import { DownloadIcon } from "@egovernments/digit-ui-react-components"; import { PRIMARY_COLOR, downloadExcelWithCustomName } from "../utils"; import getProjectServiceUrl from "../utils/getProjectServiceUrl"; +import NoResultsFound from "./NoResultsFound"; function boundaryDataGrp(boundaryData) { // Create an empty object to hold grouped data by type @@ -177,39 +178,55 @@ const CampaignUpdateSummary = (props) => { const target = data?.[0]?.deliveryRules; const boundaryData = boundaryDataGrp(data?.[0]?.boundaries); const hierarchyType = data?.[0]?.hierarchyType; + return { cards: [ - ...boundaryData?.map((item, index) => { - return { - navigationKey: "card1", - name: `HIERARCHY_${index + 1}`, - sections: [ - { + ...( + boundaryData.length > 0 + ? boundaryData.map((item, index) => ({ + navigationKey: "card1", name: `HIERARCHY_${index + 1}`, - type: "COMPONENT", - // cardHeader: { value: `${t(( hierarchyType + "_" + item?.type).toUpperCase())}`, inlineStyles: { color: "#0B4B66" } }, - cardHeader: { - value: hierarchyType - ? `${t((hierarchyType + "_" + item?.type).toUpperCase())}` - : t("To Be Updated"), - inlineStyles: { color: "#0B4B66" } - }, - - component: "BoundaryDetailsSummary", - cardSecondaryAction: noAction !== "false" && ( -
handleRedirect(1)}> - {t(`CAMPAIGN_EDIT`)} - -
- ), - props: { - boundaries: item, - hierarchyType: hierarchyType - }, - }, - ], - }; - }), + sections: [ + { + name: `HIERARCHY_${index + 1}`, + type: "COMPONENT", + cardHeader: { + value: hierarchyType + ? `${t((hierarchyType + "_" + item?.type).toUpperCase())}` + : t("To Be Updated"), + inlineStyles: { color: "#0B4B66" } + }, + component: "BoundaryDetailsSummary", + cardSecondaryAction: noAction !== "false" && ( +
handleRedirect(1)}> + {t(`CAMPAIGN_EDIT`)} + +
+ ), + props: { + boundaries: item, + hierarchyType: hierarchyType + }, + }, + ], + })) + : [ + { + navigationKey: "card1", + name: "HIERARCHY_1", + sections: [ + { + name: "NoResults", + type: "COMPONENT", + component: "NoResultsFound", + props: { + text: Digit.Utils.locale.getTransformedLocale(`NO_RESULTS`) + } + } + ] + } + ] + ), { navigationKey: "card2", sections: [ diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/NoResultsFound.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/NoResultsFound.js new file mode 100644 index 00000000000..d24c4df96f2 --- /dev/null +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/NoResultsFound.js @@ -0,0 +1,29 @@ +import React from "react"; +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { SVG } from "@egovernments/digit-ui-components"; + +const NoResultsFound = (props) => { + const { t } = useTranslation(); + const iconHeight = props?.height || 262; + const iconWidth = props?.width || 336; + return ( +
+ + {props?.text ? t(props?.text) : t("COMMON_NO_RESULTS_FOUND")} +
+ ); +}; +NoResultsFound.propTypes = { + style: PropTypes.object, + className: PropTypes.string, + height: PropTypes.number, // Prop for the height of the NoResultsFoundIcon + width: PropTypes.number, // Prop for the width of the NoResultsFoundIcon +}; + +// Default props for height and width +NoResultsFound.defaultProps = { + height: 262, + width: 336, +}; +export default NoResultsFound; diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js index a56b353c314..23af9fdf2c9 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js @@ -569,6 +569,7 @@ const UploadData = ({ formData, onSelect, ...props }) => { const headersToValidate = XLSX.utils.sheet_to_json(sheet, { header: 1, })[0]; + const requiredProperties = translatedSchema?.boundary?.required || []; const jsonData = XLSX.utils.sheet_to_json(sheet, { blankrows: true }); @@ -579,6 +580,7 @@ const UploadData = ({ formData, onSelect, ...props }) => { for (const row of jsonData) { for (let j = boundaryCodeIndex + 1; j < headersToValidate.length; j++) { const value = row[headersToValidate[j]]; + if(!requiredProperties.includes(headersToValidate[j])) continue; if (value === undefined || value === null) { targetError.push(