From bcee55c359eb3df613d3c85634383feef5151d0d Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Tue, 22 Oct 2024 09:42:08 +0200 Subject: [PATCH] fix(SW-672): Added nullable and default values to schema to avoid validation issues from ContentStack with changed models --- .../HotelPage/TabNavigation/index.tsx | 2 +- .../HotelPage/hotelPage.module.css | 1 - server/routers/contentstack/base/output.ts | 54 ++++++++++--------- .../contentstack/schemas/blocks/hotelFaq.ts | 5 +- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/components/ContentType/HotelPage/TabNavigation/index.tsx b/components/ContentType/HotelPage/TabNavigation/index.tsx index 8e80459b4..6f8b29130 100644 --- a/components/ContentType/HotelPage/TabNavigation/index.tsx +++ b/components/ContentType/HotelPage/TabNavigation/index.tsx @@ -88,7 +88,7 @@ export default function TabNavigation({ scroll={true} onClick={pauseScrollSpy} > - {intl.formatMessage({ id: link.text })} + {link.text} ) })} diff --git a/components/ContentType/HotelPage/hotelPage.module.css b/components/ContentType/HotelPage/hotelPage.module.css index 09f900159..771c4e76e 100644 --- a/components/ContentType/HotelPage/hotelPage.module.css +++ b/components/ContentType/HotelPage/hotelPage.module.css @@ -11,7 +11,6 @@ "mapContainer"; margin: 0 auto; max-width: var(--max-width); - z-index: 0; } .hotelImages { diff --git a/server/routers/contentstack/base/output.ts b/server/routers/contentstack/base/output.ts index 85aa2651a..9fc8f3e53 100644 --- a/server/routers/contentstack/base/output.ts +++ b/server/routers/contentstack/base/output.ts @@ -369,16 +369,16 @@ export const validateFooterConfigSchema = z all_footer: z.object({ items: z.array( z.object({ - main_links: validateLinks, + main_links: validateLinks.default([]), app_downloads: z.object({ title: z.string(), - links: validateLinksWithType, + links: validateLinksWithType.default([]), }), - secondary_links: validateSecondaryLinks, + secondary_links: validateSecondaryLinks.default([]), social_media: z.object({ - links: validateLinksWithType, + links: validateLinksWithType.default([]), }), - tertiary_links: validateLinks, + tertiary_links: validateLinks.default([]), }) ), }), @@ -418,25 +418,31 @@ export const validateFooterRefConfigSchema = z.object({ items: z .array( z.object({ - main_links: z.array( - z.object({ - pageConnection: pageConnectionRefs, - }) - ), - secondary_links: z.array( - z.object({ - links: z.array( - z.object({ - pageConnection: pageConnectionRefs, - }) - ), - }) - ), - tertiary_links: z.array( - z.object({ - pageConnection: pageConnectionRefs, - }) - ), + main_links: z + .array( + z.object({ + pageConnection: pageConnectionRefs, + }) + ) + .nullable(), + secondary_links: z + .array( + z.object({ + links: z.array( + z.object({ + pageConnection: pageConnectionRefs, + }) + ), + }) + ) + .nullable(), + tertiary_links: z + .array( + z.object({ + pageConnection: pageConnectionRefs, + }) + ) + .nullable(), system: systemSchema, }) ) diff --git a/server/routers/contentstack/schemas/blocks/hotelFaq.ts b/server/routers/contentstack/schemas/blocks/hotelFaq.ts index b6d4d42cf..aade71e3d 100644 --- a/server/routers/contentstack/schemas/blocks/hotelFaq.ts +++ b/server/routers/contentstack/schemas/blocks/hotelFaq.ts @@ -31,7 +31,8 @@ export const hotelFaqSchema = z .object({ questions: accordionItemsSchema, }) - .optional(), + .optional() + .nullable(), }) .transform((data) => { const array = [] @@ -51,7 +52,7 @@ export const hotelFaqRefsSchema = z .optional() .default(HotelPageEnum.ContentStack.blocks.Faq), global_faqConnection: globalAccordionConnectionRefs.optional(), - specific_faq: specificAccordionConnectionRefs.optional(), + specific_faq: specificAccordionConnectionRefs.optional().nullable(), }) .transform((data) => { const array = []