From a73b8a413a9ff5695244106b3a893df7dfb8ee02 Mon Sep 17 00:00:00 2001 From: anamontiaga Date: Mon, 4 Sep 2023 11:57:56 +0200 Subject: [PATCH] remove layer when click twice --- .../project/inventory-panel/cost-surfaces/index.tsx | 8 ++++++-- app/layout/projects/show/map/index.tsx | 5 +---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx index 4e982cc38b..9f33a37025 100644 --- a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx @@ -81,9 +81,13 @@ const InventoryPanelCostSurface = ({ noData: noDataMessage }: { noData: string } const toggleSeeOnMap = useCallback( (costSurfaceId: CostSurface['id']) => { - dispatch(setVisibleCostSurface(costSurfaceId)); + if (costSurfaceId === visibleCostSurface) { + dispatch(setVisibleCostSurface(null)); + } else { + dispatch(setVisibleCostSurface(costSurfaceId)); + } }, - [dispatch] + [dispatch, visibleCostSurface] ); const handleSort = useCallback( diff --git a/app/layout/projects/show/map/index.tsx b/app/layout/projects/show/map/index.tsx index a3382fea3c..a803cf42b5 100644 --- a/app/layout/projects/show/map/index.tsx +++ b/app/layout/projects/show/map/index.tsx @@ -189,13 +189,11 @@ export const ProjectMap = (): JSX.Element => { ], options: { layerSettings, - cost: { name: allProjectCostSurfacesQuery.data.name, min: 1, max: 100 }, + cost: { name: allProjectCostSurfacesQuery.data?.name, min: 1, max: 100 }, items: selectedPreviewFeatures, }, }); - console.log({ LEGEND }); - const SCENARIOS_RUNNED = useMemo(() => { const status = rawScenariosData .filter((s) => { @@ -436,7 +434,6 @@ export const ProjectMap = (): JSX.Element => { > {LEGEND.map((i) => { const { type, items, intersections } = i; - console.log({ i }); return (