Feat(SW-3708): refactor contentstack fetching (removing all refs) and cache invalidation * Remove all REFS * Revalidate correct language * PR fixes * PR fixes * Throw when errors from contentstack api Approved-by: Joakim Jäderberg
37 lines
887 B
TypeScript
37 lines
887 B
TypeScript
import { z } from "zod"
|
|
|
|
import { SidebarEnums } from "../../../../types/sidebar"
|
|
import {
|
|
teaserCardBlockSchema,
|
|
transformTeaserCardBlock,
|
|
} from "../blocks/cards/teaserCard"
|
|
|
|
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,
|
|
})
|
|
),
|
|
}),
|
|
})
|
|
.nullish()
|
|
.transform((data) => {
|
|
if (!data?.teaser_cardConnection?.edges.length) {
|
|
return null
|
|
}
|
|
|
|
return {
|
|
...transformTeaserCardBlock(data.teaser_cardConnection.edges[0].node),
|
|
theme: data.theme,
|
|
}
|
|
}),
|
|
})
|