Merged in feat/SW-2266-campaign-hero (pull request #2344)
Feat/SW-2266 campaign hero Approved-by: Erik Tiekstra
This commit is contained in:
@@ -11,6 +11,11 @@ import {
|
||||
carouselCardsSchema,
|
||||
} from "../schemas/blocks/carouselCards"
|
||||
import { essentialsBlockSchema } from "../schemas/blocks/essentials"
|
||||
import { tempImageVaultAssetSchema } from "../schemas/imageVault"
|
||||
import {
|
||||
linkConnectionRefs,
|
||||
linkConnectionSchema,
|
||||
} from "../schemas/linkConnection"
|
||||
import { systemSchema } from "../schemas/system"
|
||||
|
||||
import { CampaignPageEnum } from "@/types/enums/campaignPage"
|
||||
@@ -39,10 +44,25 @@ export const blocksSchema = z.discriminatedUnion("__typename", [
|
||||
campaignPageAccordion,
|
||||
])
|
||||
|
||||
export const heroSchema = z.object({
|
||||
image: tempImageVaultAssetSchema,
|
||||
heading: z.string(),
|
||||
theme: z.enum(["Peach", "Burgundy"]).default("Peach"),
|
||||
benefits: z.array(z.string()).nullish(),
|
||||
rate_text: z
|
||||
.object({
|
||||
bold_text: z.string().nullish(),
|
||||
text: z.string().nullish(),
|
||||
})
|
||||
.nullish(),
|
||||
button: z.intersection(z.object({ cta: z.string() }), linkConnectionSchema),
|
||||
})
|
||||
|
||||
export const campaignPageSchema = z.object({
|
||||
campaign_page: z.object({
|
||||
title: z.string(),
|
||||
campaign_identifier: z.string().nullish(),
|
||||
hero: heroSchema,
|
||||
heading: z.string(),
|
||||
subheading: z.string().nullish(),
|
||||
preamble: z.object({
|
||||
@@ -80,9 +100,13 @@ const campaignPageBlockRefsItem = z.discriminatedUnion("__typename", [
|
||||
campaignPageCarouselCardsRef,
|
||||
campaignPageAccordionRefs,
|
||||
])
|
||||
const heroRefsSchema = z.object({
|
||||
button: linkConnectionRefs,
|
||||
})
|
||||
|
||||
export const campaignPageRefsSchema = z.object({
|
||||
campaign_page: z.object({
|
||||
hero: heroRefsSchema,
|
||||
blocks: discriminatedUnionArray(
|
||||
campaignPageBlockRefsItem.options
|
||||
).nullable(),
|
||||
|
||||
@@ -46,7 +46,6 @@ export const campaignPageQueryRouter = router({
|
||||
ttl: "max",
|
||||
}
|
||||
)
|
||||
|
||||
if (!refsResponse.data) {
|
||||
const notFoundError = notFound(refsResponse)
|
||||
metricsGetCampaignPageRefs.noDataError()
|
||||
|
||||
@@ -173,6 +173,7 @@ export function transformPageLink(data: Data) {
|
||||
title: data.title,
|
||||
url: removeMultipleSlashes(`/${data.system.locale}/${data.url}`),
|
||||
}
|
||||
|
||||
case ContentEnum.blocks.CollectionPage:
|
||||
case ContentEnum.blocks.ContentPage:
|
||||
case ContentEnum.blocks.LoyaltyPage:
|
||||
|
||||
Reference in New Issue
Block a user