feat(SW-717) use of AvailabilityEnum instead of strings
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
||||||
import type { RoomConfiguration } from "@/types/trpc/routers/hotel/roomAvailability"
|
import type { RoomConfiguration } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,14 +33,21 @@ export function filterDuplicateRoomTypesByLowestPrice(
|
|||||||
const previousRoom = roomMap.get(roomType)
|
const previousRoom = roomMap.get(roomType)
|
||||||
|
|
||||||
// Prioritize 'Available' status
|
// Prioritize 'Available' status
|
||||||
if (status === "Available" && previousRoom?.status === "NotAvailable") {
|
if (
|
||||||
|
status === AvailabilityEnum.Available &&
|
||||||
|
previousRoom?.status === AvailabilityEnum.NotAvailable
|
||||||
|
) {
|
||||||
roomMap.set(roomType, room)
|
roomMap.set(roomType, room)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status === "NotAvailable" && previousRoom?.status === "Available") {
|
if (
|
||||||
|
status === AvailabilityEnum.NotAvailable &&
|
||||||
|
previousRoom?.status === AvailabilityEnum.Available
|
||||||
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previousRoom) {
|
if (previousRoom) {
|
||||||
products.forEach((product) => {
|
products.forEach((product) => {
|
||||||
const { productType } = product
|
const { productType } = product
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import {
|
|||||||
} from "./utils"
|
} from "./utils"
|
||||||
|
|
||||||
import type { BedTypeSelection } from "@/types/components/hotelReservation/enterDetails/bedType"
|
import type { BedTypeSelection } from "@/types/components/hotelReservation/enterDetails/bedType"
|
||||||
|
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
||||||
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
import { BreakfastPackageEnum } from "@/types/enums/breakfast"
|
||||||
import { HotelTypeEnum } from "@/types/enums/hotelType"
|
import { HotelTypeEnum } from "@/types/enums/hotelType"
|
||||||
import type { RequestOptionsWithOutBody } from "@/types/fetch"
|
import type { RequestOptionsWithOutBody } from "@/types/fetch"
|
||||||
@@ -675,14 +676,14 @@ export const hotelQueryRouter = router({
|
|||||||
validateAvailabilityData.data.roomConfigurations.filter((room) => {
|
validateAvailabilityData.data.roomConfigurations.filter((room) => {
|
||||||
if (packageCodes) {
|
if (packageCodes) {
|
||||||
return (
|
return (
|
||||||
room.status === "Available" &&
|
room.status === AvailabilityEnum.Available &&
|
||||||
room.features.some(
|
room.features.some(
|
||||||
(feature) =>
|
(feature) =>
|
||||||
packageCodes.includes(feature.code) && feature.inventory > 0
|
packageCodes.includes(feature.code) && feature.inventory > 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return room.status === "Available"
|
return room.status === AvailabilityEnum.Available
|
||||||
})
|
})
|
||||||
|
|
||||||
const selectedRoom = availableRooms.find(
|
const selectedRoom = availableRooms.find(
|
||||||
|
|||||||
Reference in New Issue
Block a user