import type { DestinationPagesHotelData } from "@/types/hotel"

export function getVisibleHotels(
  hotels: DestinationPagesHotelData[],
  map: google.maps.Map | null
) {
  const bounds = map?.getBounds()
  if (!bounds) {
    return []
  }

  const visibleHotels = hotels.filter(({ hotel }) => {
    const { latitude, longitude } = hotel.location
    return bounds.contains({ lat: latitude, lng: longitude })
  })
  return visibleHotels
}
