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
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { tempImageVaultAssetSchema } from "../../imageVault"
|
|
import { systemSchema } from "../../system"
|
|
import { buttonSchema } from "../utils/buttonLinkSchema"
|
|
import { linkConnectionRefsSchema } from "../utils/linkConnection"
|
|
|
|
import { CardsEnum } from "@/types/enums/cards"
|
|
|
|
export const contentCardSchema = z.object({
|
|
__typename: z.literal(CardsEnum.ContentCard),
|
|
title: z.string(),
|
|
heading: z.string(),
|
|
image: tempImageVaultAssetSchema,
|
|
body_text: z.string(),
|
|
promo_text: z.string().optional(),
|
|
has_primary_button: z.boolean(),
|
|
has_secondary_button: z.boolean(),
|
|
primary_button: buttonSchema,
|
|
secondary_button: buttonSchema,
|
|
system: systemSchema,
|
|
})
|
|
|
|
export const contentCardRefSchema = z.object({
|
|
__typename: z.literal(CardsEnum.ContentCard),
|
|
primary_button: linkConnectionRefsSchema,
|
|
secondary_button: linkConnectionRefsSchema,
|
|
system: systemSchema,
|
|
})
|
|
|
|
export function transformContentCard(card: typeof contentCardSchema._type) {
|
|
return {
|
|
__typename: card.__typename,
|
|
title: card.title,
|
|
heading: card.heading,
|
|
image: card.image,
|
|
bodyText: card.body_text,
|
|
promoText: card.promo_text,
|
|
primaryButton: card.has_primary_button ? card.primary_button : undefined,
|
|
secondaryButton: card.has_secondary_button
|
|
? card.secondary_button
|
|
: undefined,
|
|
}
|
|
}
|