feat(SW-285): Ship support for ContentPageBlocksCardsGrid

This commit is contained in:
Chuma McPhoy
2024-09-02 10:23:21 +02:00
parent dd336ca4ab
commit e88e4d92bf
8 changed files with 320 additions and 5 deletions

View File

@@ -0,0 +1,52 @@
import SectionContainer from "@/components/Section/Container"
import SectionHeader from "@/components/Section/Header"
import Card from "@/components/TempDesignSystem/Card"
import Grids from "@/components/TempDesignSystem/Grids"
import LoyaltyCard from "@/components/TempDesignSystem/LoyaltyCard"
import { CardsGridProps } from "@/types/components/content/blocks"
import { CardsGridEnum } from "@/types/components/content/enums"
export default function CardsGrid({
cards_grid,
firstItem = false,
}: CardsGridProps) {
return (
<SectionContainer>
<SectionHeader
title={cards_grid.title}
subtitle={cards_grid.preamble}
topTitle={firstItem}
/>
<Grids.Stackable>
{cards_grid.cards.map((card) => {
switch (card.__typename) {
case CardsGridEnum.Card: {
return (
<Card
theme={cards_grid.theme || "one"}
key={card.system.uid}
scriptedTopTitle={card.scripted_top_title}
heading={card.heading}
bodyText={card.body_text}
secondaryButton={card.secondaryButton}
primaryButton={card.primaryButton}
/>
)
}
case CardsGridEnum.LoyaltyCard:
return (
<LoyaltyCard
key={card.system.uid}
image={card.image}
heading={card.heading}
bodyText={card.body_text}
link={card.link}
/>
)
}
})}
</Grids.Stackable>
</SectionContainer>
)
}

View File

@@ -2,7 +2,8 @@ import JsonToHtml from "@/components/JsonToHtml"
// import DynamicContentBlock from "@/components/Loyalty/Blocks/DynamicContent"
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
// import CardsGrid from "./CardsGrid"
import CardsGrid from "./CardsGrid"
import type { BlocksProps } from "@/types/components/content/blocks"
import { ContentBlocksTypenameEnum } from "@/types/components/content/enums"
@@ -29,6 +30,14 @@ export function Blocks({ blocks }: BlocksProps) {
title={block.shortcuts.title}
/>
)
case ContentBlocksTypenameEnum.ContentPageBlocksCardsGrid:
return (
<CardsGrid
cards_grid={block.cards_grid}
key={`${block.cards_grid.title}-${idx}`}
firstItem={firstItem}
/>
)
default:
return null
}