feat(SW-2873): Move select-hotel to booking flow * crude setup of select-hotel in partner-sas * wip * Fix linting * restructure tracking files * Remove dependency on trpc in tracking hooks * Move pageview tracking to common * Fix some lint and import issues * Add AlternativeHotelsPage * Add SelectHotelMapPage * Add AlternativeHotelsMapPage * remove next dependency in tracking store * Remove dependency on react in tracking hooks * move isSameBooking to booking-flow * Inject searchParamsComparator into tracking store * Move useTrackHardNavigation to common * Move useTrackSoftNavigation to common * Add TrackingSDK to partner-sas * call serverclient in layout * Remove unused css * Update types * Move HotelPin type * Fix todos * Merge branch 'master' into feat/sw-2873-move-selecthotel-to-booking-flow * Merge branch 'master' into feat/sw-2873-move-selecthotel-to-booking-flow * Fix component Approved-by: Joakim Jäderberg
30 lines
814 B
TypeScript
30 lines
814 B
TypeScript
import type { HotelPin } from "../../../HotelCardDialogListing/utils"
|
|
import type { HotelResponse } from "../../helpers"
|
|
|
|
export 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
|
|
}
|