diff --git a/src/components/Modal.js b/src/components/Modal.js index 3e5ad751..10b6ae89 100644 --- a/src/components/Modal.js +++ b/src/components/Modal.js @@ -1,6 +1,6 @@ import { useModal } from '@/context/EmergencyProvider'; -const Modal = ({ children, maxWidth = 'max-w-2xl', allowClose = true }) => { +export const Modal = ({ children, maxWidth = 'max-w-2xl', allowClose = true }) => { const { showModal, toggleModal } = useModal(); if (!showModal) return null; diff --git a/src/components/map/map.tsx b/src/components/map/map.tsx index 9e2d9561..2f123efb 100644 --- a/src/components/map/map.tsx +++ b/src/components/map/map.tsx @@ -1,15 +1,18 @@ 'use client'; -import { FC, ReactNode, useRef, useState } from 'react'; -import ReactMap, { Popup } from 'react-map-gl/maplibre'; +import { FC, ReactNode, useState } from 'react'; +import ReactMap from 'react-map-gl/maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; import { Marker } from 'react-map-gl/maplibre'; import { MapPin } from 'lucide-react'; +import { useModal } from '@/context/EmergencyProvider'; +// @ts-ignore +import Modal from '@/components/Modal'; const urgencyToColor = { - alta: '#ef4444', //text-red-500 - media: '#f59e0b', //text-amber-500 - baja: '#10b981', //text-emerald-500 + alta: 'text-red-500', + media: 'text-amber-500', + baja: 'text-emerald-500', }; export type PinMapa = { @@ -31,6 +34,8 @@ const DEFAULT_ZOOM = 12; const Map: FC = ({ markers = [] }) => { const [selectedMarker, setSelectedMarker] = useState(null); + const { showModal, toggleModal } = useModal(); + console.log(selectedMarker); return ( = ({ markers = [] }) => { return ( setSelectedMarker(m)} + longitude={m.longitude} + latitude={m.latitude} + onClick={() => { + toggleModal(true); + setSelectedMarker(m); + }} anchor="bottom" > - + ); })} - {selectedMarker && ( - setSelectedMarker(null)} - > - {selectedMarker.popup} - - )} + {selectedMarker && showModal && {selectedMarker.popup}} ); };