refactor: infer types from zod validation

This commit is contained in:
Christel Westerberg
2024-04-29 09:53:54 +02:00
parent 00f30811cf
commit 49b7aa89f8
18 changed files with 418 additions and 217 deletions

View File

@@ -1,8 +1,7 @@
import type { RTENode } from "../rte/node"
import type { Node } from "@/types/requests/utils/edges"
import type { RenderOptions } from "../rte/option"
import type { Embeds } from "@/types/requests/embeds"
import type { Node } from "@/types/requests/utils/edges"
import type { RTENode } from "../rte/node"
import type { RenderOptions } from "../rte/option"
export type JsonToHtmlProps = {
embeds: Node<Embeds>[]

View File

@@ -1,38 +1,28 @@
import { Embeds } from "@/types/requests/embeds"
import { DynamicContentBlock } from "@/types/requests/loyaltyPage"
import { PageLink } from "@/types/requests/myPages/navigation"
import { Edges } from "@/types/requests/utils/edges"
import { RTEDocument } from "@/types/rte/node"
import {
Block,
CardGrid,
CardGridCard,
DynamicContent,
RteBlockContent,
} from "@/server/routers/contentstack/loyaltyPage/output"
export type BlocksProps = {
blocks: Block[]
}
export type DynamicContentProps = {
dynamicContent: DynamicContentBlock["dynamic_content"]
dynamicContent: DynamicContent["dynamic_content"]
}
type Card = {
referenceConnection: Edges<PageLink>
title?: string
subtitle?: string
open_in_new_tab: boolean
export type DynamicComponentProps = {
component: DynamicContent["dynamic_content"]["component"]
}
export type CardProps = { card: Card }
export type CardProps = { card: CardGridCard }
export type CardGrid = {
card_grid: {
title?: string
subtitle?: string
cards: Card[]
}
}
export type CardGridProps = Pick<CardGrid, "card_grid">
export type CardGridProps = CardGrid
export type Content = {
content: {
embedded_itemsConnection: Edges<Embeds>
json: RTEDocument
}
}
export type Content = { content: RteBlockContent["content"]["content"] }
export type LevelCardProps = {
level: {

View File

@@ -1,20 +1,16 @@
import { ContactFields } from "@/types/requests/contactConfig"
import { Embeds } from "@/types/requests/embeds"
import { JoinLoyaltyContactContact } from "@/types/requests/loyaltyPage"
import { Edges } from "@/types/requests/utils/edges"
import { RTEDocument } from "@/types/rte/node"
import {
JoinLoyaltyContact,
Sidebar,
} from "@/server/routers/contentstack/loyaltyPage/output"
export type SidebarContent = {
content: {
embedded_itemsConnection: Edges<Embeds>
json: RTEDocument
}
export type SidebarProps = {
block: Sidebar
}
export type Contact = {
contact: ContactFields
export type JoinLoyaltyContactProps = {
block: JoinLoyaltyContact["join_loyalty_contact"]
}
export type ContactProps = {
contactBlock: JoinLoyaltyContactContact[]
contactBlock: JoinLoyaltyContact["join_loyalty_contact"]["contact"]
}