42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
|
import { PackageTypeEnum } from "@/types/enums/packages"
|
|
|
|
// TODO: Remove optional and default when the API change has been deployed
|
|
export const packagePriceSchema = z
|
|
.object({
|
|
currency: z.string().default("N/A"),
|
|
price: z.string(),
|
|
totalPrice: z.string(),
|
|
})
|
|
.optional()
|
|
.default({
|
|
currency: "N/A",
|
|
price: "0",
|
|
totalPrice: "0",
|
|
})
|
|
|
|
const inventorySchema = z.object({
|
|
date: z.string(),
|
|
total: z.number(),
|
|
available: z.number(),
|
|
})
|
|
|
|
export const packageSchema = z.object({
|
|
code: z.nativeEnum(RoomPackageCodeEnum),
|
|
description: z.string(),
|
|
inventories: z.array(inventorySchema),
|
|
itemCode: z.string().default(""),
|
|
localPrice: packagePriceSchema,
|
|
requestedPrice: packagePriceSchema,
|
|
})
|
|
|
|
export const breakfastPackageSchema = z.object({
|
|
code: z.string(),
|
|
description: z.string(),
|
|
localPrice: packagePriceSchema,
|
|
requestedPrice: packagePriceSchema,
|
|
packageType: z.literal(PackageTypeEnum.BreakfastAdult),
|
|
})
|