65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { transformedImageVaultAssetSchema } from "@scandic-hotels/common/utils/imageVault"
|
|
|
|
import * as pageLinks from "../../../../routers/contentstack/schemas/pageLinks"
|
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
|
import { systemSchema } from "../system"
|
|
import { buttonSchema } from "./utils/buttonLinkSchema"
|
|
|
|
export const fullWidthCampaignSchema = z.object({
|
|
full_width_campaign: z
|
|
.object({
|
|
full_width_campaignConnection: z.object({
|
|
edges: z.array(
|
|
z.object({
|
|
node: z.object({
|
|
background_image: transformedImageVaultAssetSchema,
|
|
heading: z.string().optional(),
|
|
body_text: z.string().optional(),
|
|
scripted_top_title: z.string().optional(),
|
|
has_primary_button: z.boolean().default(false),
|
|
primary_button: buttonSchema,
|
|
has_secondary_button: z.boolean().default(false),
|
|
secondary_button: buttonSchema,
|
|
system: systemSchema,
|
|
}),
|
|
})
|
|
),
|
|
}),
|
|
})
|
|
.transform((data) => {
|
|
return data.full_width_campaignConnection.edges[0]?.node || null
|
|
}),
|
|
})
|
|
|
|
export const fullWidthCampaignBlockSchema = z
|
|
.object({
|
|
typename: z
|
|
.literal(BlocksEnums.block.FullWidthCampaign)
|
|
.optional()
|
|
.default(BlocksEnums.block.FullWidthCampaign),
|
|
})
|
|
.merge(fullWidthCampaignSchema)
|
|
|
|
export const fullWidthCampaignBlockRefsSchema = z.object({
|
|
full_width_campaign: z.object({
|
|
full_width_campaignConnection: z.object({
|
|
edges: z.array(
|
|
z.object({
|
|
node: z.discriminatedUnion("__typename", [
|
|
pageLinks.accountPageRefSchema,
|
|
pageLinks.contentPageRefSchema,
|
|
pageLinks.loyaltyPageRefSchema,
|
|
pageLinks.collectionPageRefSchema,
|
|
pageLinks.hotelPageRefSchema,
|
|
pageLinks.destinationCityPageRefSchema,
|
|
pageLinks.destinationCountryPageRefSchema,
|
|
pageLinks.destinationOverviewPageRefSchema,
|
|
]),
|
|
})
|
|
),
|
|
}),
|
|
}),
|
|
})
|