feat(SW-3354): Added possibility to add heading to top campaign on campaign overview page

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-09-03 10:52:50 +00:00
parent 260a544c99
commit 941eb51665
5 changed files with 55 additions and 37 deletions

View File

@@ -45,7 +45,6 @@ export const campaignPageBlocksSchema = z.discriminatedUnion("__typename", [
const topCampaignSchema = z
.object({
heading: z.string(),
hero: heroSchema,
included_hotels: includedHotelsSchema,
blocks: discriminatedUnionArray(campaignPageBlocksSchema.options),
@@ -106,12 +105,15 @@ export const campaignOverviewPageSchema = z.object({
preamble: z.string(),
navigation_links: navigationLinksSchema,
}),
top_campaignConnection: z.object({
edges: z.array(
z.object({
node: topCampaignSchema,
})
),
top_campaign_block: z.object({
heading: z.string().nullish(),
campaignConnection: z.object({
edges: z.array(
z.object({
node: topCampaignSchema,
})
),
}),
}),
blocks: discriminatedUnionArray(blocksSchema.options),
system: systemSchema.merge(
@@ -122,10 +124,15 @@ export const campaignOverviewPageSchema = z.object({
),
})
.transform((data) => {
const { top_campaignConnection, ...rest } = data
const { top_campaign_block, ...rest } = data
return {
...rest,
topCampaign: top_campaignConnection.edges.map(({ node }) => node)[0],
topCampaign: {
heading: top_campaign_block.heading,
campaign: top_campaign_block.campaignConnection.edges.map(
({ node }) => node
)[0],
},
}
}),
trackingProps: z.object({
@@ -163,14 +170,16 @@ const blockRefsSchema = z.discriminatedUnion("__typename", [
export const campaignOverviewPageRefsSchema = z.object({
campaign_overview_page: z.object({
header: campaignOverviewPageHeaderRefs,
top_campaignConnection: z.object({
edges: z.array(
z.object({
node: z.object({
system: systemSchema,
}),
})
),
top_campaign_block: z.object({
campaignConnection: z.object({
edges: z.array(
z.object({
node: z.object({
system: systemSchema,
}),
})
),
}),
}),
blocks: discriminatedUnionArray(blockRefsSchema.options).nullable(),
system: systemSchema,

View File

@@ -29,10 +29,12 @@ export function getConnections({
}
})
}
if (campaign_overview_page.top_campaignConnection) {
campaign_overview_page.top_campaignConnection.edges.forEach(({ node }) => {
connections.push(node.system)
})
if (campaign_overview_page.top_campaign_block.campaignConnection) {
campaign_overview_page.top_campaign_block.campaignConnection.edges.forEach(
({ node }) => {
connections.push(node.system)
}
)
}
if (campaign_overview_page.blocks) {
campaign_overview_page.blocks.forEach((block) => {