Skip to content

Commit

Permalink
fixed targetvalidation and added no results in boundary (#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavya-egov authored Nov 7, 2024
1 parent 0b6af4c commit 2760c50
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -156,7 +157,8 @@ const componentsToRegister = {
ViewBoundary,
ViewHierarchy,
BoundarySummary,
MapView
MapView,
NoResultsFound
};

const overrideHooks = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" && (
<div className="campaign-preview-edit-container" onClick={() => handleRedirect(1)}>
<span>{t(`CAMPAIGN_EDIT`)}</span>
<EditIcon />
</div>
),
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" && (
<div className="campaign-preview-edit-container" onClick={() => handleRedirect(1)}>
<span>{t(`CAMPAIGN_EDIT`)}</span>
<EditIcon />
</div>
),
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: [
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<div className={`digit-no-data-found ${props?.className ? props?.className : ""}`} style={props?.style}>
<SVG.NoResultsFoundIcon height={iconHeight} width={iconWidth} />
<span className="digit-error-msg">{props?.text ? t(props?.text) : t("COMMON_NO_RESULTS_FOUND")}</span>
</div>
);
};
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;
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -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(
Expand Down

0 comments on commit 2760c50

Please sign in to comment.