From 339bfe44e0b18a637d219672ac1f7f931e547df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Fri, 18 Oct 2024 09:59:33 +0200 Subject: [PATCH] Hide fishing protection widget if empty values --- .../details/widgets/fishing-protection/index.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/fishing-protection/index.tsx b/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/fishing-protection/index.tsx index 5a5f11ef..dfcd7467 100644 --- a/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/fishing-protection/index.tsx +++ b/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/fishing-protection/index.tsx @@ -114,15 +114,25 @@ const FishingProtectionWidget: FCWithMessages = ({ return parsedFishingProtectionLevelData?.filter(Boolean) ?? []; }, [t, protectionLevelsData, metadata]); - const noData = !widgetChartData.length; - const loading = isFetchingProtectionLevelsData; + const noData = useMemo(() => { + if (!widgetChartData.length) { + return true; + } + + const emptyValues = widgetChartData.every((d) => d.totalArea === Infinity); + if (emptyValues) { + return true; + } + + return false; + }, [widgetChartData]); return ( {widgetChartData.map((chartData) => (