feat(sw-453): implemented filter from packages
This commit is contained in:
59
server/routers/hotels/schemas/packages.ts
Normal file
59
server/routers/hotels/schemas/packages.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export enum RoomPackageCode {
|
||||
PETR = "PETR",
|
||||
ALLG = "ALLG",
|
||||
ACCE = "ACCE",
|
||||
}
|
||||
|
||||
export const getRoomPackagesInputSchema = 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([]),
|
||||
})
|
||||
|
||||
const packagesSchema = z.array(
|
||||
z.object({
|
||||
code: z.enum([
|
||||
RoomPackageCode.PETR,
|
||||
RoomPackageCode.ALLG,
|
||||
RoomPackageCode.ACCE,
|
||||
]),
|
||||
itemCode: z.string(),
|
||||
description: z.string(),
|
||||
currency: z.string(),
|
||||
calculatedPrice: z.number(),
|
||||
inventories: z.array(
|
||||
z.object({
|
||||
date: z.string(),
|
||||
total: z.number(),
|
||||
available: z.number(),
|
||||
})
|
||||
),
|
||||
})
|
||||
)
|
||||
|
||||
export const getRoomPackagesSchema = z
|
||||
.object({
|
||||
data: z.object({
|
||||
attributes: z.object({
|
||||
hotelId: z.number(),
|
||||
packages: packagesSchema,
|
||||
}),
|
||||
relationships: z
|
||||
.object({
|
||||
links: z.array(
|
||||
z.object({
|
||||
url: z.string(),
|
||||
type: z.string(),
|
||||
})
|
||||
),
|
||||
})
|
||||
.optional(),
|
||||
type: z.string(),
|
||||
}),
|
||||
})
|
||||
.transform((data) => data.data.attributes.packages)
|
||||
@@ -92,9 +92,3 @@ export const roomSchema = z
|
||||
roomFacilities: data.attributes.roomFacilities,
|
||||
}
|
||||
})
|
||||
|
||||
export const roomFilterSchema = z.object({
|
||||
accessibility: z.boolean(),
|
||||
petFriendly: z.boolean(),
|
||||
allergyFriendly: z.boolean(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user