From 5f1633cb1f3af07299dd5226f51999754d9d7b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Fri, 18 Oct 2024 09:55:26 +0200 Subject: [PATCH] Hide conservation widget if empty values --- .../details/widgets/marine-conservation/index.tsx | 15 ++++++++++++++- .../widgets/terrestrial-conservation/index.tsx | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/marine-conservation/index.tsx b/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/marine-conservation/index.tsx index f6de2341..177a4372 100644 --- a/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/marine-conservation/index.tsx +++ b/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/marine-conservation/index.tsx @@ -155,11 +155,24 @@ const MarineConservationWidget: FCWithMessages = return data; }, [location, aggregatedData]); + const noData = useMemo(() => { + if (!chartData.length) { + return true; + } + + const emptyValues = chartData.every((d) => d.percentage === 0); + if (emptyValues) { + return true; + } + + return false; + }, [chartData]); + return ( { + if (!chartData.length) { + return true; + } + + const emptyValues = chartData.every((d) => d.percentage === 0); + if (emptyValues) { + return true; + } + + return false; + }, [chartData]); + return (