import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
import type { RoomConfiguration } from "@/types/trpc/routers/hotel/roomAvailability"

// Used to ensure `Available` rooms
// are shown before all `NotAvailable`
const statusLookup = {
  [AvailabilityEnum.Available]: 1,
  [AvailabilityEnum.NotAvailable]: 2,
}

export function sortRoomConfigs(a: RoomConfiguration, b: RoomConfiguration) {
  // @ts-expect-error - array indexing
  return statusLookup[a.status] - statusLookup[b.status]
}
