fix: we showed duplicate rooms because every bed represents a room
This commit is contained in:
@@ -6,38 +6,22 @@ import type { ChildrenInRoom } from "@/utils/hotelSearchDetails"
|
||||
|
||||
export function useRoomsAvailability(
|
||||
adultsCount: number[],
|
||||
hotelId: number,
|
||||
hotelId: string,
|
||||
fromDateString: string,
|
||||
toDateString: string,
|
||||
lang: Lang,
|
||||
childArray: ChildrenInRoom,
|
||||
bookingCode?: string
|
||||
) {
|
||||
const roomsAvailability =
|
||||
trpc.hotel.availability.roomsCombinedAvailability.useQuery({
|
||||
adultsCount,
|
||||
bookingCode,
|
||||
childArray,
|
||||
hotelId,
|
||||
lang,
|
||||
roomStayEndDate: toDateString,
|
||||
roomStayStartDate: fromDateString,
|
||||
})
|
||||
|
||||
const data = roomsAvailability.data?.map((ra) => {
|
||||
if (ra.status === "fulfilled") {
|
||||
return ra.value
|
||||
}
|
||||
return {
|
||||
details: ra.reason,
|
||||
error: "request_failure",
|
||||
}
|
||||
return trpc.hotel.availability.roomsCombinedAvailability.useQuery({
|
||||
adultsCount,
|
||||
bookingCode,
|
||||
childArray,
|
||||
hotelId,
|
||||
lang,
|
||||
roomStayEndDate: toDateString,
|
||||
roomStayStartDate: fromDateString,
|
||||
})
|
||||
|
||||
return {
|
||||
...roomsAvailability,
|
||||
data,
|
||||
}
|
||||
}
|
||||
|
||||
export function useHotelPackages(
|
||||
@@ -45,14 +29,14 @@ export function useHotelPackages(
|
||||
childArray: ChildrenInRoom,
|
||||
fromDateString: string,
|
||||
toDateString: string,
|
||||
hotelId: number,
|
||||
hotelId: string,
|
||||
lang: Lang
|
||||
) {
|
||||
return trpc.hotel.packages.get.useQuery({
|
||||
adults: adultArray[0], // Using the first adult count
|
||||
children: childArray?.[0]?.length, // Using the first children count
|
||||
endDate: toDateString,
|
||||
hotelId: hotelId.toString(),
|
||||
hotelId,
|
||||
packageCodes: [
|
||||
RoomPackageCodeEnum.ACCESSIBILITY_ROOM,
|
||||
RoomPackageCodeEnum.PET_ROOM,
|
||||
|
||||
Reference in New Issue
Block a user