feat: prevent users from selecting the same room when there is no vacancy for it
This commit is contained in:
committed by
Michael Zetterberg
parent
4f0c61f68f
commit
1f1bcd480b
14
apps/scandic-web/utils/sort.ts
Normal file
14
apps/scandic-web/utils/sort.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
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]
|
||||
}
|
||||
Reference in New Issue
Block a user