fix(SW-438): fix refs
This commit is contained in:
@@ -30,15 +30,12 @@ export default function Sidebar({ blocks }: SidebarProps) {
|
||||
</section>
|
||||
)
|
||||
case SidebarEnums.blocks.ContentCard:
|
||||
console.log("EEE", block.content_card)
|
||||
return (
|
||||
<TeaserCard
|
||||
{...block.content_card}
|
||||
title={block.content_card.heading}
|
||||
description={block.content_card.body_text}
|
||||
style={
|
||||
block.content_card.theme === "gray" ? "default" : "featured"
|
||||
}
|
||||
style={block.content_card.theme}
|
||||
/>
|
||||
)
|
||||
|
||||
|
||||
@@ -171,17 +171,30 @@ export function getConnections({ content_page }: ContentPageRefs) {
|
||||
connections.push(...block.content)
|
||||
}
|
||||
break
|
||||
|
||||
case ContentPageEnum.ContentStack.sidebar.ContentCard:
|
||||
if (block.content_card?.length) {
|
||||
connections.push(...block.content_card)
|
||||
}
|
||||
break
|
||||
case ContentPageEnum.ContentStack.sidebar.JoinLoyaltyContact:
|
||||
if (block.join_loyalty_contact?.button) {
|
||||
connections.push(block.join_loyalty_contact.button)
|
||||
}
|
||||
break
|
||||
case ContentPageEnum.ContentStack.sidebar.ScriptedCard:
|
||||
if (block.scripted_card?.length) {
|
||||
connections.push(...block.scripted_card)
|
||||
}
|
||||
break
|
||||
case ContentPageEnum.ContentStack.sidebar.QuickLinks:
|
||||
if (block.shortcuts.shortcuts.length) {
|
||||
connections.push(...block.shortcuts.shortcuts)
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return connections
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { z } from "zod"
|
||||
import {
|
||||
teaserCardBlockRefsSchema,
|
||||
teaserCardBlockSchema,
|
||||
transformCardBlockRefs,
|
||||
transformTeaserCardBlock,
|
||||
} from "../blocks/cardsGrid"
|
||||
|
||||
@@ -15,7 +16,7 @@ export const contentCardsSchema = z.object({
|
||||
.default(SidebarEnums.blocks.ContentCard),
|
||||
content_card: z
|
||||
.object({
|
||||
theme: z.enum(["gray", "white"]).nullable().default("gray"),
|
||||
theme: z.enum(["featured", "default"]).nullable().default("default"),
|
||||
content_cardConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
@@ -33,13 +34,21 @@ export const contentCardsSchema = z.object({
|
||||
})
|
||||
|
||||
export const contentCardRefschema = z.object({
|
||||
content_card: z.object({
|
||||
content_cardConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: teaserCardBlockRefsSchema,
|
||||
})
|
||||
),
|
||||
content_card: z
|
||||
.object({
|
||||
content_cardConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: teaserCardBlockRefsSchema,
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.transform((data) => {
|
||||
let card = null
|
||||
if (data.content_cardConnection.edges.length) {
|
||||
card = transformCardBlockRefs(data.content_cardConnection.edges[0].node)
|
||||
}
|
||||
return card
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -13,6 +13,4 @@ export const quickLinksSchema = z
|
||||
})
|
||||
.merge(shortcutsSchema)
|
||||
|
||||
export const quickLinksSRefschema = z.object({
|
||||
shortcutsRefsSchema,
|
||||
})
|
||||
export const quickLinksRefschema = shortcutsRefsSchema
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
cardBlockRefsSchema,
|
||||
cardBlockSchema,
|
||||
transformCardBlock,
|
||||
transformCardBlockRefs,
|
||||
} from "../blocks/cardsGrid"
|
||||
|
||||
import { SidebarEnums } from "@/types/enums/sidebar"
|
||||
@@ -43,13 +44,23 @@ export const scriptedCardsSchema = z.object({
|
||||
})
|
||||
|
||||
export const scriptedCardRefschema = z.object({
|
||||
scripted_card: z.object({
|
||||
scripted_cardConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: cardBlockRefsSchema,
|
||||
})
|
||||
),
|
||||
scripted_card: z
|
||||
.object({
|
||||
scripted_cardConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: cardBlockRefsSchema,
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.transform((data) => {
|
||||
let card = null
|
||||
if (data.scripted_cardConnection.edges.length) {
|
||||
card = transformCardBlockRefs(
|
||||
data.scripted_cardConnection.edges[0].node
|
||||
)
|
||||
}
|
||||
return card
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user