From e956f5e14530a30f1bbb3d7fadce5be674b49710 Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Mon, 16 Dec 2024 13:32:31 -0400 Subject: [PATCH] [TM-1466] adjust no data to display div --- .../MonitoredTab/components/DataCard.tsx | 2 +- .../components/MonitoredCharts.tsx | 30 +++++++++++++++++-- .../MonitoredTab/components/NoDataState.tsx | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/admin/components/ResourceTabs/MonitoredTab/components/DataCard.tsx b/src/admin/components/ResourceTabs/MonitoredTab/components/DataCard.tsx index f51a80836..bb523eaee 100644 --- a/src/admin/components/ResourceTabs/MonitoredTab/components/DataCard.tsx +++ b/src/admin/components/ResourceTabs/MonitoredTab/components/DataCard.tsx @@ -644,7 +644,7 @@ const DataCard = ({ -
+
{ + const [hasNoData, setHasNoData] = useState(false); + + useEffect(() => { + const noData = selected.some(chartId => { + switch (chartId) { + case "1": + case "2": + return !parsedData?.length; + case "3": + return !ecoRegionData?.chartData?.length; + case "4": + return !strategiesData?.length; + case "5": + return !landUseData?.graphicTargetLandUseTypes?.length; + default: + return false; + } + }); + setHasNoData(noData); + }, [selected, parsedData, ecoRegionData, strategiesData, landUseData]); + const renderChart = (chartId: React.Key) => { switch (chartId) { case "1": @@ -124,7 +146,11 @@ const MonitoredCharts = ({ }; return ( -
+
{selected.map( (id: React.Key | null | undefined) => id != null && ( diff --git a/src/admin/components/ResourceTabs/MonitoredTab/components/NoDataState.tsx b/src/admin/components/ResourceTabs/MonitoredTab/components/NoDataState.tsx index c4125b03c..fdac5578f 100644 --- a/src/admin/components/ResourceTabs/MonitoredTab/components/NoDataState.tsx +++ b/src/admin/components/ResourceTabs/MonitoredTab/components/NoDataState.tsx @@ -6,7 +6,7 @@ import Icon from "@/components/extensive/Icon/Icon"; import { IconNames } from "@/components/extensive/Icon/Icon"; export const NoDataState = () => ( -
+
No Data to Display