fix: handle undefined values schemas

This commit is contained in:
Christel Westerberg
2025-01-02 10:55:32 +01:00
parent 139accb8ed
commit 1f516c7c20
3 changed files with 14 additions and 12 deletions

View File

@@ -150,13 +150,13 @@ export default function RoomCard({
</div>
<div className={styles.specification}>
{occupancy && (
{occupancy?.total && (
<Caption color="uiTextMediumContrast" className={styles.guests}>
{intl.formatMessage(
{
id: "booking.guests",
},
{ nrOfGuests: occupancy?.total }
{ nrOfGuests: occupancy.total }
)}
</Caption>
)}

View File

@@ -37,14 +37,16 @@ export const restaurantSchema = z
.object({
attributes: z.object({
name: z.string().optional(),
isPublished: z.boolean(),
isPublished: z.boolean().default(false),
email: z.string().optional(),
phoneNumber: z.string().optional(),
externalBreakfast: z.object({
isAvailable: z.boolean(),
localPriceForExternalGuests: restaurantPriceSchema.optional(),
requestedPriceForExternalGuests: restaurantPriceSchema.optional(),
}),
externalBreakfast: z
.object({
isAvailable: z.boolean(),
localPriceForExternalGuests: restaurantPriceSchema.optional(),
requestedPriceForExternalGuests: restaurantPriceSchema.optional(),
})
.optional(),
menus: z
.array(
z.object({
@@ -53,7 +55,7 @@ export const restaurantSchema = z
})
)
.default([]),
openingDetails: z.array(restaurantOpeningDetailSchema),
openingDetails: z.array(restaurantOpeningDetailSchema).default([]),
content: z.object({
images: z.array(imageSchema),
texts: z.object({

View File

@@ -63,9 +63,9 @@ export const roomSchema = z
roomTypes: z.array(roomTypesSchema),
roomFacilities: z.array(roomFacilitiesSchema),
occupancy: z.object({
total: z.number(),
adults: z.number(),
children: z.number(),
total: z.number().optional(),
adults: z.number().optional(),
children: z.number().optional(),
}),
roomSize: z.object({
min: z.number(),