diff --git a/src/containers/datasets/restoration/overview/hooks.tsx b/src/containers/datasets/restoration/overview/hooks.tsx index 76ed98303..0ce9b79f1 100644 --- a/src/containers/datasets/restoration/overview/hooks.tsx +++ b/src/containers/datasets/restoration/overview/hooks.tsx @@ -1,5 +1,3 @@ -import type { SourceProps, LayerProps } from 'react-map-gl'; - import { useRouter } from 'next/router'; import { numberFormat } from 'lib/format'; diff --git a/src/containers/map/index.tsx b/src/containers/map/index.tsx index e939aff14..730065f4f 100644 --- a/src/containers/map/index.tsx +++ b/src/containers/map/index.tsx @@ -400,6 +400,7 @@ const MapContainer = ({ mapId }: { mapId: string }) => { isEmpty(iucnEcoregionPopUp?.popupInfo) && isEmpty(restorationPopUp?.popupInfo), })} + onClose={() => removePopup('location')} nonExpansible={ isEmpty(iucnEcoregionPopUp?.popupInfo) && isEmpty(restorationPopUp?.popupInfo) } diff --git a/src/containers/map/location-pop-up/index.tsx b/src/containers/map/location-pop-up/index.tsx index de7159d03..8fda3ce80 100644 --- a/src/containers/map/location-pop-up/index.tsx +++ b/src/containers/map/location-pop-up/index.tsx @@ -13,13 +13,17 @@ import { useRecoilState } from 'recoil'; import { useLocations } from 'containers/datasets/locations/hooks'; +import Icon from 'components/icon'; import { WIDGET_SUBTITLE_STYLE } from 'styles/widgets'; import type { LocationPopUp } from 'types/map'; +import CLOSE_SVG from 'svgs/ui/close.svg?sprite'; + const LocationPopUP = ({ locationPopUpInfo, nonExpansible, className, + onClose, }: { locationPopUpInfo: { info: LocationPopUp; @@ -27,6 +31,7 @@ const LocationPopUP = ({ }; nonExpansible: boolean; className?: string; + onClose: () => void; }) => { const [open, setOpen] = useState(nonExpansible); const [locationBounds, setLocationBounds] = useRecoilState(locationBoundsAtom); @@ -57,18 +62,42 @@ const LocationPopUP = ({ } push(`/country/${location.iso}/${queryParams ? `?${queryParams}` : ''}`, null); + onClose(); } }, [setLocationBounds, push, queryParams, locations, feature]); + const handleClickProtectedArea = useCallback(() => { + const { ISO3, NAME } = info.protectedArea; + const location = locations.data?.find((l) => { + return l.iso === ISO3 && l.location_type === 'wdpa' && l.name === NAME; + }); + + if (location) { + const bbox = turfBbox(location.bounds); + + if (bbox) { + setLocationBounds(bbox as typeof locationBounds); + } + + push(`/wdpa/${location.location_id}/${queryParams ? `?${queryParams}` : ''}`, null); + onClose(); + } + }, [setLocationBounds, push, queryParams, locations, info]); + return (