Chore/refactor hotel trpc routes * chore(SW-3519): refactor trpc hotel routers * chore(SW-3519): refactor trpc hotel routers * refactor * merge * Merge branch 'master' of bitbucket.org:scandic-swap/web into chore/refactor-hotel-trpc-routes Approved-by: Linus Flood
153 lines
3.9 KiB
TypeScript
153 lines
3.9 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { Lang } from "@scandic-hotels/common/constants/language"
|
|
|
|
import { BreakfastPackageEnum } from "../../enums/breakfast"
|
|
import { ChildBedMapEnum } from "../../enums/childBedMapEnum"
|
|
import { RoomPackageCodeEnum } from "../../enums/roomFilter"
|
|
import { Country } from "../../types/country"
|
|
|
|
const childrenInRoomSchema = z
|
|
.array(
|
|
z.object({
|
|
age: z.number(),
|
|
bed: z.nativeEnum(ChildBedMapEnum),
|
|
})
|
|
)
|
|
.optional()
|
|
|
|
export const baseRoomSchema = z.object({
|
|
adults: z.number().int().min(1),
|
|
bookingCode: z.string().optional(),
|
|
childrenInRoom: childrenInRoomSchema,
|
|
packages: z
|
|
.array(z.nativeEnum({ ...BreakfastPackageEnum, ...RoomPackageCodeEnum }))
|
|
.optional(),
|
|
})
|
|
|
|
export const selectedRoomSchema = z.object({
|
|
counterRateCode: z.string().optional(),
|
|
rateCode: z.string(),
|
|
roomTypeCode: z.string(),
|
|
})
|
|
|
|
export const baseBookingSchema = z.object({
|
|
bookingCode: z.string().optional(),
|
|
fromDate: z.string(),
|
|
hotelId: z.string(),
|
|
searchType: z.string().optional(),
|
|
toDate: z.string(),
|
|
})
|
|
|
|
export const roomFeaturesInputSchema = z.object({
|
|
adults: z.number(),
|
|
childrenInRoom: childrenInRoomSchema,
|
|
endDate: z.string(),
|
|
hotelId: z.string(),
|
|
lang: z.nativeEnum(Lang),
|
|
roomFeatureCodes: z
|
|
.array(z.nativeEnum({ ...BreakfastPackageEnum, ...RoomPackageCodeEnum }))
|
|
.optional(),
|
|
startDate: z.string(),
|
|
})
|
|
|
|
export type RoomFeaturesInput = z.input<typeof roomFeaturesInputSchema>
|
|
|
|
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()),
|
|
})
|
|
.nullish(),
|
|
hotelsToInclude: z.array(z.string()),
|
|
contentType: z
|
|
.enum(["hotel", "restaurant", "meeting"])
|
|
.optional()
|
|
.default("hotel"),
|
|
})
|
|
export interface GetHotelsByCSFilterInput
|
|
extends z.input<typeof getHotelsByCSFilterInput> {}
|
|
|
|
export const nearbyHotelIdsInput = z.object({
|
|
hotelId: z.string(),
|
|
})
|
|
|
|
export const getDestinationsMapDataInput = z
|
|
.object({
|
|
lang: z.nativeEnum(Lang),
|
|
warmup: z.boolean().optional(),
|
|
})
|
|
.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({
|
|
adults: z.number(),
|
|
children: z.number().optional().default(0),
|
|
endDate: z.string(),
|
|
hotelId: z.string(),
|
|
lang: z.nativeEnum(Lang),
|
|
packageCodes: z.array(z.string()).optional().default([]),
|
|
startDate: z.string(),
|
|
})
|
|
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),
|
|
})
|
|
|
|
export const getLocationsUrlsInput = z.object({
|
|
lang: z.nativeEnum(Lang),
|
|
})
|