feat(SW-497): added link and refs to site config

This commit is contained in:
Erik Tiekstra
2024-10-18 09:02:23 +02:00
parent c8d4f6c47c
commit 62b9a66569
7 changed files with 227 additions and 12 deletions

View File

@@ -541,6 +541,7 @@ export const headerRefsSchema = z
})
const linkUnionSchema = z.discriminatedUnion("__typename", [
pageLinks.accountPageSchema,
pageLinks.contentPageSchema,
pageLinks.hotelPageSchema,
pageLinks.loyaltyPageSchema,
@@ -674,7 +675,9 @@ export const alertSchema = z
phone_number: z.string().nullable(),
footnote: z.string().nullable(),
}),
has_sidepeek_button: z.boolean().default(false),
has_link: z.boolean(),
link: linkAndTitleSchema,
has_sidepeek_button: z.boolean(),
sidepeek_button: z.object({
cta_text: z.string(),
}),
@@ -711,10 +714,13 @@ export const alertSchema = z
heading,
text,
phone_contact,
has_link,
link,
has_sidepeek_button,
sidepeek_button,
sidepeek_content,
}) => {
const hasLink = has_link && link.link
return {
type,
text,
@@ -727,9 +733,17 @@ export const alertSchema = z
footnote: phone_contact.footnote,
}
: null,
hasSidepeekButton: has_sidepeek_button,
sidepeekButton: has_sidepeek_button ? sidepeek_button : null,
sidepeekContent: has_sidepeek_button ? sidepeek_content : null,
hasSidepeekButton: !!has_sidepeek_button,
link: hasLink
? {
url: link.link.url,
title: link.title,
}
: null,
sidepeekButton:
!hasLink && has_sidepeek_button ? sidepeek_button : null,
sidepeekContent:
!hasLink && has_sidepeek_button ? sidepeek_content : null,
}
}
)
@@ -772,3 +786,44 @@ export const siteConfigSchema = z
bookingWidgetDisabled: sitewide_alert.booking_widget_disabled,
}
})
const sidepeekContentRefSchema = z.object({
content: z.object({
embedded_itemsConnection: z.object({
edges: z.array(
z.object({
node: z.discriminatedUnion("__typename", [
pageLinks.accountPageRefSchema,
pageLinks.contentPageRefSchema,
pageLinks.hotelPageRefSchema,
pageLinks.loyaltyPageRefSchema,
]),
})
),
}),
}),
})
const alertConnectionRefSchema = z.object({
edges: z.array(
z.object({
node: z.object({
link: linkRefsSchema,
sidepeek_content: sidepeekContentRefSchema,
}),
})
),
})
export const siteConfigRefSchema = z.object({
all_site_config: z.object({
items: z.array(
z.object({
sitewide_alert: z.object({
alertConnection: alertConnectionRefSchema,
}),
system: systemSchema,
})
),
}),
})