51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { trpc } from "@/lib/trpc/client"
|
|
|
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
|
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,
|
|
bookingCode?: string,
|
|
redemption?: boolean
|
|
) {
|
|
return trpc.hotel.availability.roomsCombinedAvailability.useQuery({
|
|
adultsCount,
|
|
bookingCode,
|
|
childArray,
|
|
hotelId,
|
|
lang,
|
|
redemption,
|
|
roomStayEndDate: toDateString,
|
|
roomStayStartDate: fromDateString,
|
|
})
|
|
}
|
|
|
|
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,
|
|
})
|
|
}
|