diff --git a/components/HotelReservation/SelectRate/Rooms/utils.ts b/components/HotelReservation/SelectRate/Rooms/utils.ts index 030eba3fd..fa9b1ac0e 100644 --- a/components/HotelReservation/SelectRate/Rooms/utils.ts +++ b/components/HotelReservation/SelectRate/Rooms/utils.ts @@ -1,3 +1,4 @@ +import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel" import type { RoomConfiguration } from "@/types/trpc/routers/hotel/roomAvailability" /** @@ -32,14 +33,21 @@ export function filterDuplicateRoomTypesByLowestPrice( const previousRoom = roomMap.get(roomType) // Prioritize 'Available' status - if (status === "Available" && previousRoom?.status === "NotAvailable") { + if ( + status === AvailabilityEnum.Available && + previousRoom?.status === AvailabilityEnum.NotAvailable + ) { roomMap.set(roomType, room) return } - if (status === "NotAvailable" && previousRoom?.status === "Available") { + if ( + status === AvailabilityEnum.NotAvailable && + previousRoom?.status === AvailabilityEnum.Available + ) { return } + if (previousRoom) { products.forEach((product) => { const { productType } = product diff --git a/server/routers/hotels/query.ts b/server/routers/hotels/query.ts index fbfc29b64..43c0d996d 100644 --- a/server/routers/hotels/query.ts +++ b/server/routers/hotels/query.ts @@ -55,6 +55,7 @@ import { } from "./utils" import type { BedTypeSelection } from "@/types/components/hotelReservation/enterDetails/bedType" +import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel" import { BreakfastPackageEnum } from "@/types/enums/breakfast" import { HotelTypeEnum } from "@/types/enums/hotelType" import type { RequestOptionsWithOutBody } from "@/types/fetch" @@ -675,14 +676,14 @@ export const hotelQueryRouter = router({ validateAvailabilityData.data.roomConfigurations.filter((room) => { if (packageCodes) { return ( - room.status === "Available" && + room.status === AvailabilityEnum.Available && room.features.some( (feature) => packageCodes.includes(feature.code) && feature.inventory > 0 ) ) } - return room.status === "Available" + return room.status === AvailabilityEnum.Available }) const selectedRoom = availableRooms.find(