chore(SW-285): content page types dir

This commit is contained in:
Chuma McPhoy
2024-09-05 15:50:40 +02:00
parent b0e84dd016
commit 0f80d82eac
7 changed files with 96 additions and 92 deletions

View File

@@ -1,17 +1,84 @@
import { z } from "zod"
import {
Block,
cardBlock,
contentPageBlockTextContent,
contentPageCards,
contentPageDynamicContent,
contentPageJoinLoyaltyContact,
contentPageShortcuts,
contentPageSidebarDynamicContent,
contentPageSidebarTextContent,
loyaltyCardBlock,
validateContentPageRefsSchema,
validateContentPageSchema,
} from "@/server/routers/contentstack/contentPage/output"
import { ImageVaultAsset } from "@/types/components/imageVault"
import { Embeds } from "@/types/requests/embeds"
import { EdgesWithTotalCount } from "@/types/requests/utils/edges"
import { RTEDocument } from "@/types/rte/node"
export type ContentPageDataRaw = z.infer<typeof validateContentPageSchema>
type ContentPageRaw = ContentPageDataRaw["content_page"]
export type ContentPage = Omit<ContentPageRaw, "hero_image"> & {
export type ContentPage = Omit<
ContentPageRaw,
"blocks" | "hero_image" | "sidebar"
> & {
heroImage?: ImageVaultAsset
blocks?: Block[]
blocks: Block[]
sidebar: Sidebar[]
}
export type ContentPageRefsDataRaw = z.infer<
typeof validateContentPageRefsSchema
>
type SidebarContentRaw = z.infer<typeof contentPageSidebarTextContent>
type SideBarDynamicContent = z.infer<typeof contentPageSidebarDynamicContent>
export type JoinLoyaltyContact = z.infer<typeof contentPageJoinLoyaltyContact>
export type RteSidebarContent = Omit<SidebarContentRaw, "content"> & {
content: {
content: {
json: RTEDocument
embedded_itemsConnection: EdgesWithTotalCount<Embeds>
}
}
}
export type Sidebar =
| JoinLoyaltyContact
| RteSidebarContent
| SideBarDynamicContent
export type DynamicContent = z.infer<typeof contentPageDynamicContent>
type BlockContentRaw = z.infer<typeof contentPageBlockTextContent>
export interface RteBlockContent extends BlockContentRaw {
content: {
content: {
json: RTEDocument
embedded_itemsConnection: EdgesWithTotalCount<Embeds>
}
}
}
export type Shortcuts = z.infer<typeof contentPageShortcuts>
type LoyaltyCardRaw = z.infer<typeof loyaltyCardBlock>
type LoyaltyCard = Omit<LoyaltyCardRaw, "image"> & {
image?: ImageVaultAsset
}
type CardRaw = z.infer<typeof cardBlock>
type Card = Omit<CardRaw, "background_image"> & {
backgroundImage?: ImageVaultAsset
}
type CardsGridRaw = z.infer<typeof contentPageCards>
export type CardsGrid = Omit<CardsGridRaw, "cards"> & {
cards: (LoyaltyCard | Card)[]
}
export type CardsRaw = CardsGrid["cards_grid"]["cards"][number]
export type Block = RteBlockContent | Shortcuts | CardsGrid | DynamicContent