Files
web/components/Content/Blocks/CardsGrid/index.tsx
2024-09-16 09:13:00 +02:00

64 lines
2.2 KiB
TypeScript

import SectionContainer from "@/components/Section/Container"
import SectionHeader from "@/components/Section/Header"
import Card from "@/components/TempDesignSystem/Card"
import ContentCard from "@/components/TempDesignSystem/ContentCard"
import Grids from "@/components/TempDesignSystem/Grids"
import LoyaltyCard from "@/components/TempDesignSystem/LoyaltyCard"
import type { 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}
preamble={cards_grid.preamble}
topTitle={firstItem}
/>
<Grids.Stackable>
{cards_grid.cards.map((card) => {
switch (card.__typename) {
case CardsGridEnum.Card:
return card.isContentCard ? (
<ContentCard
key={card.system.uid}
title={card.heading || ""}
description={card.body_text || ""}
primaryButton={card.primaryButton}
secondaryButton={card.secondaryButton}
sidePeekButton={card.sidePeekButton}
backgroundImage={card.background_image}
style="default"
/>
) : (
<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>
)
}