Files
web/server/routers/hotels/schemas/packages.ts
Bianca Widstam 224a41ec74 feat/SW-1546-list-ancillaries-my-stay (pull request #1259)
Feat/SW-1546 list ancillaries my stay

* feat(SW-1546): foundation for listing ancillaries

* feat(SW-1546): foundation for listing ancillaries

* feat(SW-1546): refactor type

* feat(SW-1546): fix date format

* feat(SW-1546): refactor usestate

* feat(SW-1546): refactor typing

* feat(SW-1546): refactor types

* feat(SW-1546): responsive width on modal

* feat(SW-1546): update design

* feat(SW-1546): rebase master

* feat(SW-1546): show points only if logged in

* feat(SW-1546): always show points

* feat(SW-1546): small fix

* feat(SW-1546): remove spread object

* feat(SW-1546): fix import order


Approved-by: Simon.Emanuelsson
2025-02-14 10:37:17 +00:00

61 lines
1.6 KiB
TypeScript

import { z } from "zod"
import { imageSizesSchema } from "./image"
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 ancillaryContentSchema = z.object({
status: z.string(),
id: z.string(),
variants: z.object({
ancillary: z.object({ price: packagePriceSchema }),
ancillaryLoyalty: z.object({ points: z.number() }).optional(),
}),
title: z.string(),
descriptions: z.object({ html: z.string() }),
images: z.array(z.object({ imageSizes: imageSizesSchema })),
})
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),
})
export const ancillaryPackageSchema = z.object({
categoryName: z.string(),
ancillaryContent: z.array(ancillaryContentSchema),
})