import { z } from "zod" import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" import { BreakfastPackageEnum } from "../../../enums/breakfast" import { PackageTypeEnum } from "../../../enums/packages" import { RoomPackageCodeEnum } from "../../../enums/roomFilter" import { imageWithoutMetaDataSchema } from "./image" // TODO: Remove optional and default when the API change has been deployed export const packagePriceSchema = z .object({ currency: z.nativeEnum(CurrencyEnum).default(CurrencyEnum.Unknown), price: z.number(), totalPrice: z.number(), }) .optional() .default({ currency: CurrencyEnum.Unknown, price: 0, totalPrice: 0, }) const inventorySchema = z.object({ date: z.string(), total: z.number(), available: z.number(), }) export const ancillaryContentSchema = z.object({ status: z.string(), id: z.string(), variants: z.object({ ancillary: z.object({ id: z.string(), price: packagePriceSchema }), ancillaryLoyalty: z .object({ points: z.number(), code: z.string() }) .optional(), }), title: z.string(), descriptions: z.object({ html: z.string() }), images: z.array(imageWithoutMetaDataSchema), requiresDeliveryTime: z.boolean(), unitName: z.string().optional(), }) export const packageSchema = z.object({ code: z.nativeEnum({ ...RoomPackageCodeEnum, ...BreakfastPackageEnum }), description: z.string(), inventories: z.array(inventorySchema), itemCode: z.string().default(""), localPrice: packagePriceSchema, requestedPrice: packagePriceSchema, }) export type BreakfastPackage = z.output export const breakfastPackageSchema = z.object({ code: z.string(), description: z.string(), localPrice: packagePriceSchema, requestedPrice: packagePriceSchema, packageType: z.enum([ PackageTypeEnum.BreakfastAdult, PackageTypeEnum.BreakfastChildren, ]), }) export const ancillaryPackageSchema = z.object({ categoryName: z.string(), internalCategoryName: z.string().optional(), ancillaryContent: z.array(ancillaryContentSchema), })