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",
|
id: "Select payment method",
|
||||||
})
|
})
|
||||||
|
|
||||||
const roomPrice =
|
const roomPrice = {
|
||||||
user && roomAvailability.memberRate
|
memberPrice: roomAvailability.memberRate?.localPrice.pricePerStay,
|
||||||
? roomAvailability.memberRate?.localPrice.pricePerStay
|
publicPrice: roomAvailability.publicRate!.localPrice.pricePerStay,
|
||||||
: roomAvailability.publicRate!.localPrice.pricePerStay
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export default async function Details({
|
|||||||
</li>
|
</li>
|
||||||
<li className={styles.listItem}>
|
<li className={styles.listItem}>
|
||||||
<Body>{intl.formatMessage({ id: "Cancellation policy" })}</Body>
|
<Body>{intl.formatMessage({ id: "Cancellation policy" })}</Body>
|
||||||
<Body>N/A</Body>
|
<Body>{booking.rateDefinition.cancellationText}</Body>
|
||||||
</li>
|
</li>
|
||||||
<li className={styles.listItem}>
|
<li className={styles.listItem}>
|
||||||
<Body>{intl.formatMessage({ id: "Rebooking" })}</Body>
|
<Body>{intl.formatMessage({ id: "Rebooking" })}</Body>
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ export default function Payment({
|
|||||||
breakfast,
|
breakfast,
|
||||||
bedType,
|
bedType,
|
||||||
membershipNo,
|
membershipNo,
|
||||||
|
join,
|
||||||
|
dateOfBirth,
|
||||||
|
zipCode,
|
||||||
} = userData
|
} = userData
|
||||||
const { toDate, fromDate, rooms: rooms, hotel } = roomData
|
const { toDate, fromDate, rooms: rooms, hotel } = roomData
|
||||||
|
|
||||||
@@ -181,6 +184,9 @@ export default function Payment({
|
|||||||
phoneNumber,
|
phoneNumber,
|
||||||
countryCode,
|
countryCode,
|
||||||
membershipNumber: membershipNo,
|
membershipNumber: membershipNo,
|
||||||
|
becomeMember: join,
|
||||||
|
dateOfBirth,
|
||||||
|
postalCode: zipCode,
|
||||||
},
|
},
|
||||||
packages: {
|
packages: {
|
||||||
breakfast: breakfast !== BreakfastPackageEnum.NO_BREAKFAST,
|
breakfast: breakfast !== BreakfastPackageEnum.NO_BREAKFAST,
|
||||||
|
|||||||
@@ -2,6 +2,15 @@ import { z } from "zod"
|
|||||||
|
|
||||||
import { ChildBedTypeEnum } from "@/constants/booking"
|
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(
|
const roomsSchema = z.array(
|
||||||
z.object({
|
z.object({
|
||||||
adults: z.number().int().nonnegative(),
|
adults: z.number().int().nonnegative(),
|
||||||
@@ -15,14 +24,17 @@ const roomsSchema = z.array(
|
|||||||
.default([]),
|
.default([]),
|
||||||
rateCode: z.string(),
|
rateCode: z.string(),
|
||||||
roomTypeCode: z.coerce.string(),
|
roomTypeCode: z.coerce.string(),
|
||||||
guest: z.object({
|
guest: z.intersection(
|
||||||
firstName: z.string(),
|
z.object({
|
||||||
lastName: z.string(),
|
firstName: z.string(),
|
||||||
email: z.string().email(),
|
lastName: z.string(),
|
||||||
phoneNumber: z.string(),
|
email: z.string().email(),
|
||||||
countryCode: z.string(),
|
phoneNumber: z.string(),
|
||||||
membershipNumber: z.string().optional(),
|
countryCode: z.string(),
|
||||||
}),
|
membershipNumber: z.string().optional(),
|
||||||
|
}),
|
||||||
|
signupSchema
|
||||||
|
),
|
||||||
smsConfirmationRequested: z.boolean(),
|
smsConfirmationRequested: z.boolean(),
|
||||||
packages: z.object({
|
packages: z.object({
|
||||||
breakfast: z.boolean(),
|
breakfast: z.boolean(),
|
||||||
@@ -30,7 +42,13 @@ const roomsSchema = z.array(
|
|||||||
petFriendly: z.boolean(),
|
petFriendly: z.boolean(),
|
||||||
accessibility: 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(),
|
cancellationNumber: z.string().nullable(),
|
||||||
reservationStatus: z.string(),
|
reservationStatus: z.string(),
|
||||||
paymentUrl: z.string().nullable(),
|
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(),
|
type: z.string(),
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
@@ -77,7 +88,16 @@ export const bookingConfirmationSchema = z
|
|||||||
guest: guestSchema,
|
guest: guestSchema,
|
||||||
hotelId: z.string(),
|
hotelId: z.string(),
|
||||||
packages: z.array(packageSchema),
|
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(),
|
reservationStatus: z.string(),
|
||||||
roomPrice: z.number().int(),
|
roomPrice: z.number().int(),
|
||||||
roomTypeCode: z.string(),
|
roomTypeCode: z.string(),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export interface BreakfastSelectionProps extends SectionProps {
|
|||||||
export interface DetailsProps extends SectionProps {}
|
export interface DetailsProps extends SectionProps {}
|
||||||
|
|
||||||
export interface PaymentProps {
|
export interface PaymentProps {
|
||||||
roomPrice: number
|
roomPrice: { publicPrice: number; memberPrice: number | undefined }
|
||||||
otherPaymentOptions: string[]
|
otherPaymentOptions: string[]
|
||||||
savedCreditCards: CreditCard[] | null
|
savedCreditCards: CreditCard[] | null
|
||||||
mustBeGuaranteed: boolean
|
mustBeGuaranteed: boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user