From 4a578f4ea78d0d5a8548dfbf7a70a45d3a728594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez=20Mu=C3=B1oz?= Date: Wed, 20 Sep 2023 10:11:31 +0200 Subject: [PATCH] hides PU areas legends when needed --- .../scenarios/edit/map/legend/hooks/index.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/layout/scenarios/edit/map/legend/hooks/index.ts b/app/layout/scenarios/edit/map/legend/hooks/index.ts index 4fca49f883..59cdfd75a2 100644 --- a/app/layout/scenarios/edit/map/legend/hooks/index.ts +++ b/app/layout/scenarios/edit/map/legend/hooks/index.ts @@ -226,8 +226,13 @@ export const useLockInLegend = () => { const { puTmpIncludedValue, puIncludedValue, layerSettings } = useAppSelector( (state) => state[`/scenarios/${sid}/edit`] ); + + const totalIncludedAreas = [...puIncludedValue, ...puTmpIncludedValue]; + + if (!totalIncludedAreas.length) return null; + return LEGEND_LAYERS['lock-in']({ - puIncludedValue: [...puIncludedValue, ...puTmpIncludedValue], + puIncludedValue: totalIncludedAreas, onChangeVisibility: () => { dispatch( setLayerSettings({ @@ -253,8 +258,12 @@ export const useLockOutLegend = () => { (state) => state[`/scenarios/${sid}/edit`] ); + const totalExcludedAreas = [...puExcludedValue, ...puTmpExcludedValue]; + + if (!totalExcludedAreas.length) return null; + return LEGEND_LAYERS['lock-out']({ - puExcludedValue: [...puExcludedValue, ...puTmpExcludedValue], + puExcludedValue: totalExcludedAreas, onChangeVisibility: () => { dispatch( setLayerSettings({ @@ -279,8 +288,12 @@ export const useLockAvailableLegend = () => { (state) => state[`/scenarios/${sid}/edit`] ); + const totalAvailableAreas = [...puAvailableValue, ...puTmpAvailableValue]; + + if (!totalAvailableAreas.length) return null; + return LEGEND_LAYERS['lock-available']({ - puAvailableValue: [...puAvailableValue, ...puTmpAvailableValue], + puAvailableValue: totalAvailableAreas, onChangeVisibility: () => { dispatch( setLayerSettings({