fix(SW-438): fix refs
This commit is contained in:
@@ -30,15 +30,12 @@ export default function Sidebar({ blocks }: SidebarProps) {
|
|||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
case SidebarEnums.blocks.ContentCard:
|
case SidebarEnums.blocks.ContentCard:
|
||||||
console.log("EEE", block.content_card)
|
|
||||||
return (
|
return (
|
||||||
<TeaserCard
|
<TeaserCard
|
||||||
{...block.content_card}
|
{...block.content_card}
|
||||||
title={block.content_card.heading}
|
title={block.content_card.heading}
|
||||||
description={block.content_card.body_text}
|
description={block.content_card.body_text}
|
||||||
style={
|
style={block.content_card.theme}
|
||||||
block.content_card.theme === "gray" ? "default" : "featured"
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -171,17 +171,30 @@ export function getConnections({ content_page }: ContentPageRefs) {
|
|||||||
connections.push(...block.content)
|
connections.push(...block.content)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case ContentPageEnum.ContentStack.sidebar.ContentCard:
|
||||||
|
if (block.content_card?.length) {
|
||||||
|
connections.push(...block.content_card)
|
||||||
|
}
|
||||||
|
break
|
||||||
case ContentPageEnum.ContentStack.sidebar.JoinLoyaltyContact:
|
case ContentPageEnum.ContentStack.sidebar.JoinLoyaltyContact:
|
||||||
if (block.join_loyalty_contact?.button) {
|
if (block.join_loyalty_contact?.button) {
|
||||||
connections.push(block.join_loyalty_contact.button)
|
connections.push(block.join_loyalty_contact.button)
|
||||||
}
|
}
|
||||||
break
|
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:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return connections
|
return connections
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { z } from "zod"
|
|||||||
import {
|
import {
|
||||||
teaserCardBlockRefsSchema,
|
teaserCardBlockRefsSchema,
|
||||||
teaserCardBlockSchema,
|
teaserCardBlockSchema,
|
||||||
|
transformCardBlockRefs,
|
||||||
transformTeaserCardBlock,
|
transformTeaserCardBlock,
|
||||||
} from "../blocks/cardsGrid"
|
} from "../blocks/cardsGrid"
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ export const contentCardsSchema = z.object({
|
|||||||
.default(SidebarEnums.blocks.ContentCard),
|
.default(SidebarEnums.blocks.ContentCard),
|
||||||
content_card: z
|
content_card: z
|
||||||
.object({
|
.object({
|
||||||
theme: z.enum(["gray", "white"]).nullable().default("gray"),
|
theme: z.enum(["featured", "default"]).nullable().default("default"),
|
||||||
content_cardConnection: z.object({
|
content_cardConnection: z.object({
|
||||||
edges: z.array(
|
edges: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
@@ -33,7 +34,8 @@ export const contentCardsSchema = z.object({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const contentCardRefschema = z.object({
|
export const contentCardRefschema = z.object({
|
||||||
content_card: z.object({
|
content_card: z
|
||||||
|
.object({
|
||||||
content_cardConnection: z.object({
|
content_cardConnection: z.object({
|
||||||
edges: z.array(
|
edges: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
@@ -41,5 +43,12 @@ export const contentCardRefschema = z.object({
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
})
|
||||||
|
.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)
|
.merge(shortcutsSchema)
|
||||||
|
|
||||||
export const quickLinksSRefschema = z.object({
|
export const quickLinksRefschema = shortcutsRefsSchema
|
||||||
shortcutsRefsSchema,
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
cardBlockRefsSchema,
|
cardBlockRefsSchema,
|
||||||
cardBlockSchema,
|
cardBlockSchema,
|
||||||
transformCardBlock,
|
transformCardBlock,
|
||||||
|
transformCardBlockRefs,
|
||||||
} from "../blocks/cardsGrid"
|
} from "../blocks/cardsGrid"
|
||||||
|
|
||||||
import { SidebarEnums } from "@/types/enums/sidebar"
|
import { SidebarEnums } from "@/types/enums/sidebar"
|
||||||
@@ -43,7 +44,8 @@ export const scriptedCardsSchema = z.object({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const scriptedCardRefschema = z.object({
|
export const scriptedCardRefschema = z.object({
|
||||||
scripted_card: z.object({
|
scripted_card: z
|
||||||
|
.object({
|
||||||
scripted_cardConnection: z.object({
|
scripted_cardConnection: z.object({
|
||||||
edges: z.array(
|
edges: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
@@ -51,5 +53,14 @@ export const scriptedCardRefschema = z.object({
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
})
|
||||||
|
.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