feat(SW-1384): add CarouselCards block to start page * feat(SW-1384): add filterable carousel cards block to start page * fix(SW-1384): remove unnecessary link prop from SectionHeader * fix(SW-1384): remove uneeded undefined * fix(SW-1384): better type safety * feat(SW-1384): Add see all link to filterable carousel cards section header * refactor(SW-1384): Replace FilterableCarouselCards with CarouselCards block * fix(SW-1384): Remove CardsEnumType type definition * fix(SW-1384):Implement code review feedback to CarouselCards * refactor(SW-1384): Convert CarouselCardFilterEnum to const enum with type Approved-by: Christian Andolf
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import {
|
|
teaserCardBlockRefsSchema,
|
|
teaserCardBlockSchema,
|
|
transformTeaserCardBlock,
|
|
} from "../blocks/cards/teaserCard"
|
|
import { transformCardBlockRefs } from "../blocks/cardsGrid"
|
|
|
|
import { SidebarEnums } from "@/types/enums/sidebar"
|
|
|
|
export const teaserCardsSchema = z.object({
|
|
typename: z
|
|
.literal(SidebarEnums.blocks.TeaserCard)
|
|
.optional()
|
|
.default(SidebarEnums.blocks.TeaserCard),
|
|
teaser_card: z
|
|
.object({
|
|
theme: z.enum(["featured", "default"]).nullable().default("default"),
|
|
teaser_cardConnection: z.object({
|
|
edges: z.array(
|
|
z.object({
|
|
node: teaserCardBlockSchema,
|
|
})
|
|
),
|
|
}),
|
|
})
|
|
.transform((data) => {
|
|
return {
|
|
...transformTeaserCardBlock(data.teaser_cardConnection.edges[0].node),
|
|
theme: data.theme,
|
|
}
|
|
}),
|
|
})
|
|
|
|
export const teaserCardRefschema = z.object({
|
|
teaser_card: z
|
|
.object({
|
|
teaser_cardConnection: z.object({
|
|
edges: z.array(
|
|
z.object({
|
|
node: teaserCardBlockRefsSchema,
|
|
})
|
|
),
|
|
}),
|
|
})
|
|
.transform((data) => {
|
|
let card = null
|
|
if (data.teaser_cardConnection.edges.length) {
|
|
card = transformCardBlockRefs(data.teaser_cardConnection.edges[0].node)
|
|
}
|
|
return card
|
|
}),
|
|
})
|