Files
web/packages/booking-flow/lib/components/SelectHotel/SelectHotelMap/SelectHotelMapContent/utils.ts
Anton Gunnarsson b0f3e4afbd Merged in chore/cleanup-booking-flow (pull request #2824)
chore: Cleanup booking-flow after migration

* Remove unused types

* Clean up exports, types, unused files etc in booking-flow


Approved-by: Joakim Jäderberg
2025-09-18 07:28:05 +00:00

30 lines
807 B
TypeScript

import type { HotelPin } from "../../../HotelCardDialogListing/utils"
import type { HotelResponse } from "../../helpers"
function getVisibleHotelPins(
map: google.maps.Map | null,
filteredHotelPins: HotelPin[]
) {
if (!map || !filteredHotelPins) return []
const bounds = map.getBounds()
if (!bounds) return []
return filteredHotelPins.filter((pin) => {
const { lat, lng } = pin.coordinates
return bounds.contains({ lat, lng })
})
}
export function getVisibleHotels(
hotels: HotelResponse[],
filteredHotelPins: HotelPin[],
map: google.maps.Map | null
) {
const visibleHotelPins = getVisibleHotelPins(map, filteredHotelPins)
const visibleHotels = hotels.filter((hotel) =>
visibleHotelPins.some((pin) => pin.operaId === hotel.hotel.operaId)
)
return visibleHotels
}