import { HotelPin } from "@/types/components/hotelReservation/selectHotel/map"

export function getCentralCoordinates(hotels: HotelPin[]) {
  const centralCoordinates = hotels.reduce(
    (acc, pin) => {
      acc.lat += pin.coordinates.lat
      acc.lng += pin.coordinates.lng
      return acc
    },
    { lat: 0, lng: 0 }
  )

  centralCoordinates.lat /= hotels.length
  centralCoordinates.lng /= hotels.length

  return centralCoordinates
}
