Files
web/server/routers/hotels/input.ts
Linus Flood e2749f5593 Merged in feat/refactor-select-rate (pull request #1402)
Select-rate: refactor - converted RoomsContainer into a client component

* feat/select-rate - refactor and fixed duplicate key warning

* Rooms as client component

* Fixed lang in input

* It works

* Cleanup

* Cleanup

* PR fixes


Approved-by: Joakim Jäderberg
2025-02-25 08:40:36 +00:00

143 lines
3.8 KiB
TypeScript

import { z } from "zod"
import { Lang } from "@/constants/languages"
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
import { Country } from "@/types/enums/country"
export const hotelsAvailabilityInputSchema = z.object({
cityId: z.string(),
roomStayStartDate: z.string(),
roomStayEndDate: z.string(),
adults: z.number(),
children: z.string().optional(),
bookingCode: z.string().optional().default(""),
})
export const getHotelsByHotelIdsAvailabilityInputSchema = z.object({
hotelIds: z.array(z.number()),
roomStayStartDate: z.string(),
roomStayEndDate: z.string(),
adults: z.number(),
children: z.string().optional(),
bookingCode: z.string().optional().default(""),
})
export const roomsCombinedAvailabilityInputSchema = z.object({
hotelId: z.number(),
roomStayStartDate: z.string(),
roomStayEndDate: z.string(),
uniqueAdultsCount: z.array(z.number()),
childArray: z
.array(
z.object({
bed: z.nativeEnum(ChildBedMapEnum),
age: z.number(),
})
)
.optional(),
bookingCode: z.string().optional(),
rateCode: z.string().optional(),
lang: z.nativeEnum(Lang),
})
export const selectedRoomAvailabilityInputSchema = z.object({
hotelId: z.string(),
roomStayStartDate: z.string(),
roomStayEndDate: z.string(),
adults: z.number(),
children: z.string().optional(),
bookingCode: z.string().optional(),
rateCode: z.string(),
roomTypeCode: z.string(),
packageCodes: z.array(z.nativeEnum(RoomPackageCodeEnum)).optional(),
})
export type GetSelectedRoomAvailabilityInput = z.input<
typeof selectedRoomAvailabilityInputSchema
>
export const ratesInputSchema = z.object({
hotelId: z.string(),
})
export const hotelInputSchema = z.object({
hotelId: z.string(),
isCardOnlyPayment: z.boolean(),
language: z.nativeEnum(Lang),
})
export const getHotelsByCSFilterInput = z.object({
locationFilter: z
.object({
city: z.string().nullable(),
country: z.nativeEnum(Country).nullable(),
excluded: z.array(z.string()),
})
.nullable(),
hotelsToInclude: z.array(z.string()),
})
export interface GetHotelsByCSFilterInput
extends z.infer<typeof getHotelsByCSFilterInput> {}
export const nearbyHotelIdsInput = z.object({
hotelId: z.string(),
})
export const breakfastPackageInputSchema = z.object({
adults: z.number().min(1, { message: "at least one adult is required" }),
fromDate: z
.string()
.min(1, { message: "fromDate is required" })
.pipe(z.coerce.date()),
hotelId: z.string().min(1, { message: "hotelId is required" }),
toDate: z
.string()
.min(1, { message: "toDate is required" })
.pipe(z.coerce.date()),
})
export const ancillaryPackageInputSchema = z.object({
fromDate: z
.string()
.min(1, { message: "fromDate is required" })
.pipe(z.coerce.date()),
hotelId: z.string().min(1, { message: "hotelId is required" }),
toDate: z.string().pipe(z.coerce.date()).optional(),
})
export const roomPackagesInputSchema = z.object({
hotelId: z.string(),
startDate: z.string(),
endDate: z.string(),
adults: z.number(),
children: z.number().optional().default(0),
packageCodes: z.array(z.string()).optional().default([]),
lang: z.nativeEnum(Lang),
})
export const cityCoordinatesInputSchema = z.object({
city: z.string(),
hotel: z.object({
address: z.string().optional(),
}),
})
export const getMeetingRoomsInputSchema = z.object({
hotelId: z.string(),
language: z.string(),
})
export const getAdditionalDataInputSchema = z.object({
hotelId: z.string(),
language: z.string(),
})
export const getHotelsByCountryInput = z.object({
country: z.nativeEnum(Country),
})
export const getHotelsByCityIdentifierInput = z.object({
cityIdentifier: z.string(),
})