Feat/SW-2113 allow feature combinations * feat(SW-2113): Refactor features data to be fetched on filter room filter change * feat(SW-2113): added loading state * fix: now clear room selection when applying filter and room doesnt exists. And added room features to mobile summary * fix * fix: add package to price details * feat(SW-2113): added buttons to room filter * fix: active room * fix: remove console log * fix: added form and close handler to room package filter * fix: add restriction so you cannot select pet room with allergy room and vice versa * fix: fixes from review feedback * fix * fix: hide modify button if on nextcoming rooms if no selection is made, and adjust filter logic in togglePackage * fix: forgot to use roomFeatureCodes from input.. * fix: naming Approved-by: Simon.Emanuelsson
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { REDEMPTION } from "@/constants/booking"
|
|
import { trpc } from "@/lib/trpc/client"
|
|
|
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
|
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
|
import type { Lang } from "@/constants/languages"
|
|
import type { ChildrenInRoom } from "@/utils/hotelSearchDetails"
|
|
|
|
export function useRoomsAvailability(
|
|
adultsCount: number[],
|
|
hotelId: string,
|
|
fromDateString: string,
|
|
toDateString: string,
|
|
lang: Lang,
|
|
childArray: ChildrenInRoom,
|
|
booking: SelectRateSearchParams
|
|
) {
|
|
const redemption = booking.searchType
|
|
? booking.searchType === REDEMPTION
|
|
: undefined
|
|
|
|
const roomFeatureCodesArray = booking.rooms.map(
|
|
(room) => room.packages ?? null
|
|
)
|
|
|
|
const roomsAvailability =
|
|
trpc.hotel.availability.roomsCombinedAvailability.useQuery({
|
|
adultsCount,
|
|
childArray,
|
|
hotelId,
|
|
lang,
|
|
redemption,
|
|
roomStayEndDate: toDateString,
|
|
roomStayStartDate: fromDateString,
|
|
bookingCode: booking.bookingCode,
|
|
roomFeatureCodesArray,
|
|
})
|
|
|
|
return roomsAvailability
|
|
}
|
|
|
|
export function useHotelPackages(
|
|
adultArray: number[],
|
|
childArray: ChildrenInRoom,
|
|
fromDateString: string,
|
|
toDateString: string,
|
|
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,
|
|
packageCodes: [
|
|
RoomPackageCodeEnum.ACCESSIBILITY_ROOM,
|
|
RoomPackageCodeEnum.PET_ROOM,
|
|
RoomPackageCodeEnum.ALLERGY_ROOM,
|
|
],
|
|
startDate: fromDateString,
|
|
lang: lang,
|
|
})
|
|
}
|