Files
web/apps/scandic-web/components/Maps/InteractiveMap/HotelListingMapContent/index.tsx
Hrishikesh Vaipurkar 74a5b5748a Merged in fix/SW-2642-select-hotel-corporate-ch (pull request #2003)
fix: SW-2642 Fixed corporate chq and voucher rates city search

* fix: SW-2642 Fixed corporate chq and voucher rates city search

* fix: SW-2642 Fixed no availability alert for all hotels

* fix: SW-2642 Combined flags to suitable variable

* fix: SW-2642 Fixed map view to show prices


Approved-by: Arvid Norlin
2025-05-08 10:46:05 +00:00

89 lines
2.6 KiB
TypeScript

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 (
<div>
{hotelPins.map((pin) => {
const isActiveOrHovered =
activeHotel === pin.name || hoveredHotel === pin.name
const hotelPrice =
pin.memberPrice ??
pin.publicPrice ??
pin.redemptionPrice ??
pin.voucherPrice ??
pin.chequePrice?.numberOfCheques ??
null
const hotelAdditionalPrice = pin.chequePrice
? pin.chequePrice.additionalPricePerStay
: undefined
const hotelAdditionalCurrency = pin.chequePrice
? pin.chequePrice.currency?.toString()
: undefined
return (
<AdvancedMarker
key={pin.name}
className={styles.advancedMarker}
position={pin.coordinates}
anchorPoint={AdvancedMarkerAnchorPoint.CENTER}
zIndex={isActiveOrHovered ? 2 : 0}
onMouseEnter={() => engage(pin.name)}
onMouseLeave={() => disengage()}
onClick={() => toggleActiveHotelPin(pin.name)}
>
<div className={styles.dialogContainer}>
<HotelCardDialog
isOpen={isActiveOrHovered}
handleClose={(event: { stopPropagation: () => void }) => {
event.stopPropagation()
deactivate()
disengage()
}}
data={pin}
/>
</div>
<HotelPin
isActive={isActiveOrHovered}
hotelPrice={hotelPrice}
currency={pin.currency}
hotelAdditionalPrice={hotelAdditionalPrice}
hotelAdditionalCurrency={hotelAdditionalCurrency}
/>
</AdvancedMarker>
)
})}
</div>
)
}
export default HotelListingMapContent