Files
web/apps/scandic-web/server/routers/hotels/input.ts
Hrishikesh Vaipurkar c5e294c7ea Merged in feat/SW-1356-reward-night-booking-2- (pull request #1559)
feat: SW-1356 Reward night bookingflow

* feat: SW-1356 Reward night bookingflow

* feat: SW-1356 Removed extra param booking call

* feat: SW-1356 Optimized as review comments

* feat: SW-1356 Schema validation updates

* feat: SW-1356 Fix after rebase

* feat: SW-1356 Optimised price.redemptions check

* feat: SW-1356 Updated Props naming


Approved-by: Arvid Norlin
2025-03-24 08:54:02 +00:00

162 lines
4.2 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(""),
redemption: z.boolean().optional().default(false),
})
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({
adultsCount: z.array(z.number()),
bookingCode: z.string().optional(),
childArray: z
.array(
z
.array(
z.object({
age: z.number(),
bed: z.nativeEnum(ChildBedMapEnum),
})
)
.nullable()
)
.nullish(),
hotelId: z.string(),
lang: z.nativeEnum(Lang),
rateCode: z.string().optional(),
roomStayEndDate: z.string(),
roomStayStartDate: z.string(),
redemption: z.boolean().optional(),
})
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(),
counterRateCode: z.string().optional(),
packageCodes: z.array(z.nativeEnum(RoomPackageCodeEnum)).optional(),
lang: z.nativeEnum(Lang).optional(),
redemption: z.boolean().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 getAllHotelsInput = z
.object({
lang: z.nativeEnum(Lang),
})
.optional()
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(),
})
export const getLocationsInput = z.object({
lang: z.nativeEnum(Lang),
})