From 2ab4f34e609521ef4e5034c1c2f3afec1dae03d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa?= Date: Fri, 24 May 2024 14:18:22 +0200 Subject: [PATCH] fix max stack --- .../datasets/species-threatened/constants.ts | 8 ++- .../map/iucn-ecoregion-popup/index.tsx | 6 +-- src/containers/navigation/menu/index.tsx | 2 +- src/containers/widgets/widgets-menu/index.tsx | 50 ++++++------------- 4 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/containers/datasets/species-threatened/constants.ts b/src/containers/datasets/species-threatened/constants.ts index 440895f50..92ab0f80e 100644 --- a/src/containers/datasets/species-threatened/constants.ts +++ b/src/containers/datasets/species-threatened/constants.ts @@ -1,4 +1,8 @@ -const Types = { +export type ThreatenedSpecies = 'ex' | 'ew' | 're' | 'cr' | 'en' | 'vu' | 'lr' | 'nt' | 'lc' | 'dd'; + +export type Colors = Partial>; + +export const Types: Record = { EX: 'ex', EW: 'ew', RE: 're', @@ -24,7 +28,7 @@ export const RED_LIST_CATEGORIES = { [Types.DD]: 'Data Deficient', }; -export const COLORS = { +export const COLORS: Colors = { ex: '#000000', ew: '#542243', cr: '#EE4D5A', diff --git a/src/containers/map/iucn-ecoregion-popup/index.tsx b/src/containers/map/iucn-ecoregion-popup/index.tsx index 449d36079..e2d82fa96 100644 --- a/src/containers/map/iucn-ecoregion-popup/index.tsx +++ b/src/containers/map/iucn-ecoregion-popup/index.tsx @@ -4,12 +4,12 @@ import cn from 'lib/classnames'; import { AnimatePresence, motion } from 'framer-motion'; -import { INFO } from 'containers/datasets'; +// import { INFO } from 'containers/datasets'; import { COLORS } from 'containers/datasets/iucn-ecoregion/constants'; import { useMangroveEcoregions } from 'containers/datasets/iucn-ecoregion/hooks'; import type { IUCNEcoregionPopUpInfo, Label } from 'containers/datasets/iucn-ecoregion/types'; -import { Dialog, DialogContent, DialogTrigger, DialogClose } from 'components/ui/dialog'; +// import { Dialog, DialogContent, DialogTrigger, DialogClose } from 'components/ui/dialog'; import { WIDGET_CARD_WRAPPER_STYLE } from 'styles/widgets'; type Tags = @@ -62,7 +62,7 @@ const FAKE_DATA_POP_UP = [ }, ]; -const Info = INFO['mangrove_iucn_ecoregion']; +// const Info = INFO['mangrove_iucn_ecoregion']; const IucnEcoregionPopup = ({ info }: { info: IUCNEcoregionPopUpInfo }) => { const [open, setOpen] = useState(false); diff --git a/src/containers/navigation/menu/index.tsx b/src/containers/navigation/menu/index.tsx index 6b9e7774f..14b2ac452 100644 --- a/src/containers/navigation/menu/index.tsx +++ b/src/containers/navigation/menu/index.tsx @@ -10,9 +10,9 @@ import Helper from 'containers/guide/helper'; import About from 'containers/navigation/menu/about'; import BlogContent from 'containers/news/content'; +import { Media } from 'components/media-query'; import { Dialog, DialogContent, DialogClose, DialogTrigger } from 'components/ui/dialog'; import Icon from 'components/ui/icon'; -import { Media } from 'components/media-query'; import GMA_PNG from 'images/gma.png'; diff --git a/src/containers/widgets/widgets-menu/index.tsx b/src/containers/widgets/widgets-menu/index.tsx index b63f45aa1..72ac7b0ce 100644 --- a/src/containers/widgets/widgets-menu/index.tsx +++ b/src/containers/widgets/widgets-menu/index.tsx @@ -62,45 +62,27 @@ const WidgetsMenu: FC = () => { if (newCat !== categorySelected) setCategory(newCat); }, - [activeWidgets, setActiveWidgets, setCategory, categorySelected] + [activeWidgets, setActiveWidgets, setCategory, categorySelected, widgets] ); const handleAllWidgets = useCallback(() => { activeWidgets.length === widgets.length ? setActiveWidgets([]) : setActiveWidgets(widgetsIds); - }, [widgetsIds, setActiveWidgets, activeWidgets]); + }, [widgetsIds, setActiveWidgets, activeWidgets, widgets]); - const handleAllLayers = useCallback( - (e) => { - if (activeLayers.length <= LAYERS.length) { - setActiveLayers([]); - } - if (LAYERS.length > activeLayers.length) { - const NewLayersActive: ActiveLayers[] = LAYERS.map((layer) => ({ - id: layer.id as WidgetSlugType | ContextualBasemapsId | 'custom-area', - opacity: '1', - visibility: 'visible', - })); - - setActiveLayers(NewLayersActive); - } - - // const activeLayers = LAYERS.map((layer) => ({ - // id: layer.id, - // opacity: '1', - // visibility: 'visible', - // })); - // e - // ? setActiveLayers( - // activeLayers as { - // id: WidgetSlugType | ContextualBasemapsId | 'custom-area'; - // opacity: string; - // visibility: Visibility; - // }[] - // ) - // : setActiveLayers([]); - }, - [setActiveLayers] - ); + const handleAllLayers = useCallback(() => { + if (activeLayers.length <= LAYERS.length && activeLayers.length > 0) { + setActiveLayers([]); + } + if (LAYERS.length > activeLayers.length) { + const NewLayersActive: ActiveLayers[] = LAYERS.map((layer) => ({ + id: layer.id as WidgetSlugType | ContextualBasemapsId | 'custom-area', + opacity: '1', + visibility: 'visible', + })); + + setActiveLayers(NewLayersActive); + } + }, [setActiveLayers, activeLayers]); const handleLayers = useCallback( (e: WidgetSlugType) => {