fix: update booking service schemas
This commit is contained in:
committed by
Joakim Jäderberg
parent
9c7ac78e14
commit
d67affd677
@@ -107,10 +107,10 @@ export default async function StepPage({
|
||||
id: "Select payment method",
|
||||
})
|
||||
|
||||
const roomPrice =
|
||||
user && roomAvailability.memberRate
|
||||
? roomAvailability.memberRate?.localPrice.pricePerStay
|
||||
: roomAvailability.publicRate!.localPrice.pricePerStay
|
||||
const roomPrice = {
|
||||
memberPrice: roomAvailability.memberRate?.localPrice.pricePerStay,
|
||||
publicPrice: roomAvailability.publicRate!.localPrice.pricePerStay,
|
||||
}
|
||||
|
||||
return (
|
||||
<section>
|
||||
|
||||
@@ -49,7 +49,7 @@ export default async function Details({
|
||||
</li>
|
||||
<li className={styles.listItem}>
|
||||
<Body>{intl.formatMessage({ id: "Cancellation policy" })}</Body>
|
||||
<Body>N/A</Body>
|
||||
<Body>{booking.rateDefinition.cancellationText}</Body>
|
||||
</li>
|
||||
<li className={styles.listItem}>
|
||||
<Body>{intl.formatMessage({ id: "Rebooking" })}</Body>
|
||||
|
||||
@@ -77,6 +77,9 @@ export default function Payment({
|
||||
breakfast,
|
||||
bedType,
|
||||
membershipNo,
|
||||
join,
|
||||
dateOfBirth,
|
||||
zipCode,
|
||||
} = userData
|
||||
const { toDate, fromDate, rooms: rooms, hotel } = roomData
|
||||
|
||||
@@ -181,6 +184,9 @@ export default function Payment({
|
||||
phoneNumber,
|
||||
countryCode,
|
||||
membershipNumber: membershipNo,
|
||||
becomeMember: join,
|
||||
dateOfBirth,
|
||||
postalCode: zipCode,
|
||||
},
|
||||
packages: {
|
||||
breakfast: breakfast !== BreakfastPackageEnum.NO_BREAKFAST,
|
||||
|
||||
@@ -2,6 +2,15 @@ import { z } from "zod"
|
||||
|
||||
import { ChildBedTypeEnum } from "@/constants/booking"
|
||||
|
||||
const signupSchema = z.discriminatedUnion("becomeMember", [
|
||||
z.object({
|
||||
dateOfBirth: z.string(),
|
||||
postalCode: z.string(),
|
||||
becomeMember: z.literal<boolean>(true),
|
||||
}),
|
||||
z.object({ becomeMember: z.literal<boolean>(false) }),
|
||||
])
|
||||
|
||||
const roomsSchema = z.array(
|
||||
z.object({
|
||||
adults: z.number().int().nonnegative(),
|
||||
@@ -15,14 +24,17 @@ const roomsSchema = z.array(
|
||||
.default([]),
|
||||
rateCode: z.string(),
|
||||
roomTypeCode: z.coerce.string(),
|
||||
guest: z.object({
|
||||
firstName: z.string(),
|
||||
lastName: z.string(),
|
||||
email: z.string().email(),
|
||||
phoneNumber: z.string(),
|
||||
countryCode: z.string(),
|
||||
membershipNumber: z.string().optional(),
|
||||
}),
|
||||
guest: z.intersection(
|
||||
z.object({
|
||||
firstName: z.string(),
|
||||
lastName: z.string(),
|
||||
email: z.string().email(),
|
||||
phoneNumber: z.string(),
|
||||
countryCode: z.string(),
|
||||
membershipNumber: z.string().optional(),
|
||||
}),
|
||||
signupSchema
|
||||
),
|
||||
smsConfirmationRequested: z.boolean(),
|
||||
packages: z.object({
|
||||
breakfast: z.boolean(),
|
||||
@@ -30,7 +42,13 @@ const roomsSchema = z.array(
|
||||
petFriendly: z.boolean(),
|
||||
accessibility: z.boolean(),
|
||||
}),
|
||||
roomPrice: z.number().or(z.string().transform((val) => Number(val))),
|
||||
roomPrice: z.object({
|
||||
publicPrice: z.number().or(z.string().transform((val) => Number(val))),
|
||||
memberPrice: z
|
||||
.number()
|
||||
.or(z.string().transform((val) => Number(val)))
|
||||
.optional(),
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -15,7 +15,18 @@ export const createBookingSchema = z
|
||||
cancellationNumber: z.string().nullable(),
|
||||
reservationStatus: z.string(),
|
||||
paymentUrl: z.string().nullable(),
|
||||
metadata: z.any(), // TODO: define metadata schema (not sure what it does)
|
||||
metadata: z
|
||||
.object({
|
||||
errorCode: z.number().optional(),
|
||||
errorMessage: z.string().optional(),
|
||||
priceChangedMetadata: z
|
||||
.object({
|
||||
roomPrice: z.number().optional(),
|
||||
totalPrice: z.number().optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
.nullable(),
|
||||
}),
|
||||
type: z.string(),
|
||||
id: z.string(),
|
||||
@@ -77,7 +88,16 @@ export const bookingConfirmationSchema = z
|
||||
guest: guestSchema,
|
||||
hotelId: z.string(),
|
||||
packages: z.array(packageSchema),
|
||||
rateCode: z.string(),
|
||||
rateDefinition: z.object({
|
||||
rateCode: z.string(),
|
||||
title: z.string().nullable(),
|
||||
breakfastIncluded: z.boolean(),
|
||||
isMemberRate: z.boolean(),
|
||||
generalTerms: z.array(z.string()).optional(),
|
||||
cancellationRule: z.string().optional(),
|
||||
cancellationText: z.string().optional(),
|
||||
mustBeGuaranteed: z.boolean(),
|
||||
}),
|
||||
reservationStatus: z.string(),
|
||||
roomPrice: z.number().int(),
|
||||
roomTypeCode: z.string(),
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface BreakfastSelectionProps extends SectionProps {
|
||||
export interface DetailsProps extends SectionProps {}
|
||||
|
||||
export interface PaymentProps {
|
||||
roomPrice: number
|
||||
roomPrice: { publicPrice: number; memberPrice: number | undefined }
|
||||
otherPaymentOptions: string[]
|
||||
savedCreditCards: CreditCard[] | null
|
||||
mustBeGuaranteed: boolean
|
||||
|
||||
Reference in New Issue
Block a user