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>
<div className={styles.specification}> <div className={styles.specification}>
{occupancy && ( {occupancy?.total && (
<Caption color="uiTextMediumContrast" className={styles.guests}> <Caption color="uiTextMediumContrast" className={styles.guests}>
{intl.formatMessage( {intl.formatMessage(
{ {
id: "booking.guests", id: "booking.guests",
}, },
{ nrOfGuests: occupancy?.total } { nrOfGuests: occupancy.total }
)} )}
</Caption> </Caption>
)} )}

View File

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

View File

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