refactor: infer types from zod validation
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import { CardGrid, Content } from "../components/loyalty/blocks"
|
||||
import { Contact, SidebarContent } from "../components/loyalty/sidebar"
|
||||
import { PageLink } from "./myPages/navigation"
|
||||
import { Edges } from "./utils/edges"
|
||||
|
||||
import type { AllRequestResponse } from "./utils/all"
|
||||
import type { JoinLoyaltyContact } from "@/server/routers/contentstack/loyaltyPage/output"
|
||||
import type { Typename } from "./utils/typename"
|
||||
|
||||
export enum JoinLoyaltyContactTypenameEnum {
|
||||
@@ -11,18 +6,10 @@ export enum JoinLoyaltyContactTypenameEnum {
|
||||
}
|
||||
|
||||
export type JoinLoyaltyContactContact = Typename<
|
||||
Contact,
|
||||
JoinLoyaltyContact["join_loyalty_contact"],
|
||||
JoinLoyaltyContactTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContactBlockContactContact
|
||||
>
|
||||
|
||||
export type JoinLoyaltyContact = {
|
||||
join_loyalty_contact: {
|
||||
title?: string
|
||||
preamble?: string
|
||||
contact: JoinLoyaltyContactContact[]
|
||||
}
|
||||
}
|
||||
|
||||
export enum SidebarTypenameEnum {
|
||||
LoyaltyPageSidebarJoinLoyaltyContact = "LoyaltyPageSidebarJoinLoyaltyContact",
|
||||
LoyaltyPageSidebarContent = "LoyaltyPageSidebarContent",
|
||||
@@ -30,13 +17,6 @@ export enum SidebarTypenameEnum {
|
||||
|
||||
export type SidebarTypename = keyof typeof SidebarTypenameEnum
|
||||
|
||||
export type Sidebar =
|
||||
| Typename<SidebarContent, SidebarTypenameEnum.LoyaltyPageSidebarContent>
|
||||
| Typename<
|
||||
JoinLoyaltyContact,
|
||||
SidebarTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContact
|
||||
>
|
||||
|
||||
export enum LoyaltyComponentEnum {
|
||||
loyalty_levels = "loyalty_levels",
|
||||
how_it_works = "how_it_works",
|
||||
@@ -45,57 +25,8 @@ export enum LoyaltyComponentEnum {
|
||||
|
||||
export type LoyaltyComponent = keyof typeof LoyaltyComponentEnum
|
||||
|
||||
export type DynamicContentBlock = {
|
||||
dynamic_content: {
|
||||
title?: string
|
||||
subtitle?: string
|
||||
component: LoyaltyComponent
|
||||
link: {
|
||||
text?: string
|
||||
pageConnection: Edges<PageLink>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export enum LoyaltyBlocksTypenameEnum {
|
||||
LoyaltyPageBlocksDynamicContent = "LoyaltyPageBlocksDynamicContent",
|
||||
LoyaltyPageBlocksCardGrid = "LoyaltyPageBlocksCardGrid",
|
||||
LoyaltyPageBlocksContent = "LoyaltyPageBlocksContent",
|
||||
}
|
||||
|
||||
export type Blocks =
|
||||
| Typename<CardGrid, LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardGrid>
|
||||
| Typename<
|
||||
DynamicContentBlock,
|
||||
LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksDynamicContent
|
||||
>
|
||||
| Typename<Content, LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent>
|
||||
|
||||
export type Breadcrumb = {
|
||||
href: string
|
||||
title: string
|
||||
}
|
||||
|
||||
export type Breadcrumbs = {
|
||||
parents: Breadcrumb[]
|
||||
title: string
|
||||
}
|
||||
|
||||
export type LoyaltyPage = {
|
||||
sidebar: Sidebar[]
|
||||
blocks: Blocks[]
|
||||
web: {
|
||||
breadcrumbs: Breadcrumbs
|
||||
}
|
||||
system: {
|
||||
created_at: string
|
||||
uid: string
|
||||
updated_at: string
|
||||
}
|
||||
title: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export type GetLoyaltyPageData = {
|
||||
all_loyalty_page: AllRequestResponse<LoyaltyPage>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user