import { AdvancedMarker, AdvancedMarkerAnchorPoint, } from "@vis.gl/react-google-maps" import { useCallback } from "react" import { useHotelsMapStore } from "@/stores/hotels-map" import HotelCardDialog from "@/components/HotelReservation/HotelCardDialog" import HotelPin from "./HotelPin" import styles from "./hotelListingMapContent.module.css" import type { HotelListingMapContentProps } from "@/types/components/hotelReservation/selectHotel/map" function HotelListingMapContent({ hotelPins }: HotelListingMapContentProps) { const { activeHotel, hoveredHotel, activate, deactivate, engage, disengage } = useHotelsMapStore() const toggleActiveHotelPin = useCallback( (pinName: string | null) => { if (activeHotel === pinName || pinName === null) { deactivate() return } activate(pinName) }, [activeHotel, activate, deactivate] ) return (
{hotelPins.map((pin) => { const isActiveOrHovered = activeHotel === pin.name || hoveredHotel === pin.name const hotelPrice = pin.memberPrice ?? pin.publicPrice ?? pin.redemptionPrice return ( engage(pin.name)} onMouseLeave={() => disengage()} onClick={() => toggleActiveHotelPin(pin.name)} >
void }) => { event.stopPropagation() deactivate() disengage() }} data={pin} />
) })}
) } export default HotelListingMapContent