fix(SW-1754): Fix rate limit issue on Destination Overview Page * fix(SW-1754): Fix rate limit issue on Destination Overview Page Approved-by: Matilda Landström
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { discriminatedUnionArray } from "@/lib/discriminatedUnion"
|
|
|
|
import {
|
|
cardGalleryRefsSchema,
|
|
cardGallerySchema,
|
|
} from "../schemas/blocks/cardGallery"
|
|
import { systemSchema } from "../schemas/system"
|
|
|
|
import { DestinationOverviewPageEnum } from "@/types/enums/destinationOverviewPage"
|
|
|
|
const destinationOverviewPageCardGallery = z
|
|
.object({
|
|
__typename: z.literal(
|
|
DestinationOverviewPageEnum.ContentStack.blocks.CardGallery
|
|
),
|
|
})
|
|
.merge(cardGallerySchema)
|
|
|
|
export const blocksSchema = z.discriminatedUnion("__typename", [
|
|
destinationOverviewPageCardGallery,
|
|
])
|
|
|
|
export const destinationOverviewPageSchema = z.object({
|
|
destination_overview_page: z.object({
|
|
title: z.string(),
|
|
blocks: discriminatedUnionArray(blocksSchema.options),
|
|
system: systemSchema.merge(
|
|
z.object({
|
|
created_at: z.string(),
|
|
updated_at: z.string(),
|
|
})
|
|
),
|
|
}),
|
|
trackingProps: z.object({
|
|
url: z.string(),
|
|
}),
|
|
})
|
|
|
|
/** REFS */
|
|
const destinationOverviewPageCardGalleryRef = z
|
|
.object({
|
|
__typename: z.literal(
|
|
DestinationOverviewPageEnum.ContentStack.blocks.CardGallery
|
|
),
|
|
})
|
|
.merge(cardGalleryRefsSchema)
|
|
|
|
const blocksRefsSchema = z.discriminatedUnion("__typename", [
|
|
destinationOverviewPageCardGalleryRef,
|
|
])
|
|
|
|
export const destinationOverviewPageRefsSchema = z.object({
|
|
destination_overview_page: z.object({
|
|
blocks: discriminatedUnionArray(blocksRefsSchema.options).nullable(),
|
|
system: systemSchema,
|
|
}),
|
|
})
|