feat(SW-791): make confirmation page dynamic
This commit is contained in:
@@ -2,6 +2,10 @@ import { z } from "zod"
|
||||
|
||||
import { ChildBedTypeEnum } from "@/constants/booking"
|
||||
|
||||
import { phoneValidator } from "@/utils/phoneValidator"
|
||||
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
|
||||
// MUTATION
|
||||
export const createBookingSchema = z
|
||||
.object({
|
||||
@@ -42,20 +46,20 @@ const extraBedTypesSchema = z.object({
|
||||
})
|
||||
|
||||
const guestSchema = z.object({
|
||||
email: z.string().email().nullable().default(""),
|
||||
firstName: z.string(),
|
||||
lastName: z.string(),
|
||||
email: z.string().nullable(),
|
||||
phoneNumber: z.string().nullable(),
|
||||
phoneNumber: phoneValidator().nullable().default(""),
|
||||
})
|
||||
|
||||
const packagesSchema = z.array(
|
||||
z.object({
|
||||
accessibility: z.boolean().optional(),
|
||||
allergyFriendly: z.boolean().optional(),
|
||||
breakfast: z.boolean().optional(),
|
||||
petFriendly: z.boolean().optional(),
|
||||
})
|
||||
)
|
||||
const packageSchema = z.object({
|
||||
code: z.string().default(""),
|
||||
currency: z.nativeEnum(CurrencyEnum),
|
||||
quantity: z.number().int(),
|
||||
totalPrice: z.number(),
|
||||
totalQuantity: z.number().int(),
|
||||
unitPrice: z.number(),
|
||||
})
|
||||
|
||||
export const bookingConfirmationSchema = z
|
||||
.object({
|
||||
@@ -66,17 +70,21 @@ export const bookingConfirmationSchema = z
|
||||
checkOutDate: z.date({ coerce: true }),
|
||||
createDateTime: z.date({ coerce: true }),
|
||||
childrenAges: z.array(z.number()),
|
||||
extraBedTypes: z.array(extraBedTypesSchema),
|
||||
extraBedTypes: z.array(extraBedTypesSchema).default([]),
|
||||
computedReservationStatus: z.string(),
|
||||
confirmationNumber: z.string(),
|
||||
currencyCode: z.string(),
|
||||
currencyCode: z.nativeEnum(CurrencyEnum),
|
||||
guest: guestSchema,
|
||||
hasPayRouting: z.boolean().optional(),
|
||||
hotelId: z.string(),
|
||||
packages: packagesSchema,
|
||||
packages: z.array(packageSchema),
|
||||
rateCode: z.string(),
|
||||
reservationStatus: z.string(),
|
||||
roomPrice: z.number().int(),
|
||||
roomTypeCode: z.string(),
|
||||
totalPrice: z.number(),
|
||||
totalPriceExVat: z.number(),
|
||||
vatAmount: z.number(),
|
||||
vatPercentage: z.number(),
|
||||
}),
|
||||
id: z.string(),
|
||||
type: z.literal("booking"),
|
||||
|
||||
Reference in New Issue
Block a user