Merged in feat/SW-1584-destination-content-blocks (pull request #1278)

Feat/SW-1584 destination content blocks

* feat(SW-1584): Added accordion and content blocks to destination city pages

* feat(SW-1584): Added accordion and content blocks to destination country pages


Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-02-10 09:28:32 +00:00
parent 918887a63f
commit eb0b88f8ea
18 changed files with 546 additions and 33 deletions
@@ -1,5 +1,12 @@
import { z } from "zod"
import { discriminatedUnionArray } from "@/lib/discriminatedUnion"
import {
accordionRefsSchema,
accordionSchema,
} from "../schemas/blocks/accordion"
import { contentRefsSchema, contentSchema } from "../schemas/blocks/content"
import { tempImageVaultAssetSchema } from "../schemas/imageVault"
import {
linkRefsUnionSchema,
@@ -14,6 +21,28 @@ import {
type TrackingSDKPageData,
} from "@/types/components/tracking"
import { Country } from "@/types/enums/country"
import { DestinationCountryPageEnum } from "@/types/enums/destinationCountryPage"
export const destinationCountryPageContent = z
.object({
__typename: z.literal(
DestinationCountryPageEnum.ContentStack.blocks.Content
),
})
.merge(contentSchema)
export const destinationCountryPageAccordion = z
.object({
__typename: z.literal(
DestinationCountryPageEnum.ContentStack.blocks.Accordion
),
})
.merge(accordionSchema)
export const blocksSchema = z.discriminatedUnion("__typename", [
destinationCountryPageAccordion,
destinationCountryPageContent,
])
export const destinationCountryPageSchema = z
.object({
@@ -57,6 +86,7 @@ export const destinationCountryPageSchema = z
}),
}),
}),
blocks: discriminatedUnionArray(blocksSchema.options).nullable(),
system: systemSchema.merge(
z.object({
created_at: z.string(),
@@ -91,6 +121,26 @@ export const destinationCountryPageSchema = z
})
/** REFS */
const destinationCountryPageContentRefs = z
.object({
__typename: z.literal(
DestinationCountryPageEnum.ContentStack.blocks.Content
),
})
.merge(contentRefsSchema)
const destinationCountryPageAccordionRefs = z
.object({
__typename: z.literal(
DestinationCountryPageEnum.ContentStack.blocks.Accordion
),
})
.merge(accordionRefsSchema)
const blocksRefsSchema = z.discriminatedUnion("__typename", [
destinationCountryPageAccordionRefs,
destinationCountryPageContentRefs,
])
export const destinationCountryPageRefsSchema = z.object({
destination_country_page: z.object({
sidepeek_content: z.object({
@@ -104,6 +154,7 @@ export const destinationCountryPageRefsSchema = z.object({
}),
}),
}),
blocks: discriminatedUnionArray(blocksRefsSchema.options).nullable(),
system: systemSchema,
}),
})