fix: add nullable values for account page

This commit is contained in:
Christel Westerberg
2024-05-14 10:27:32 +02:00
parent ed052dbfa4
commit b054fc2597
6 changed files with 18 additions and 16 deletions

View File

@@ -13,8 +13,8 @@ import { RTEDocument } from "@/types/rte/node"
const accountPageShortcuts = z.object({
__typename: z.literal(ContentEntries.AccountPageContentShortcuts),
shortcuts: z.object({
title: z.string().optional(),
preamble: z.string().optional(),
title: z.string().nullable(),
preamble: z.string().nullable(),
shortcuts: z.array(
z.object({
linkConnection: z.object({
@@ -25,7 +25,7 @@ const accountPageShortcuts = z.object({
uid: z.string(),
locale: z.nativeEnum(Lang),
}),
original_url: z.string().optional(),
original_url: z.string().nullable().optional(),
url: z.string(),
title: z.string(),
}),
@@ -33,7 +33,7 @@ const accountPageShortcuts = z.object({
),
totalCount: z.number(),
}),
text: z.string().optional(),
text: z.string().nullable(),
open_in_new_tab: z.boolean(),
})
),
@@ -43,8 +43,8 @@ const accountPageShortcuts = z.object({
const accountPageDynamicContent = z.object({
__typename: z.literal(ContentEntries.AccountPageContentDynamicContent),
dynamic_content: z.object({
title: z.string().optional(),
preamble: z.string().optional(),
title: z.string().nullable(),
preamble: z.string().nullable(),
component: z.nativeEnum(DynamicContentComponents),
link: z.object({
linkConnection: z.object({
@@ -56,7 +56,7 @@ const accountPageDynamicContent = z.object({
locale: z.nativeEnum(Lang),
}),
url: z.string(),
original_url: z.string().optional(),
original_url: z.string().nullable().optional(),
title: z.string(),
}),
})
@@ -65,7 +65,6 @@ const accountPageDynamicContent = z.object({
}),
link_text: z.string(),
}),
// .optional(),
}),
})

View File

@@ -28,6 +28,8 @@ export const accountPageQueryRouter = router({
)
if (!validatedAccountPage.success) {
console.info(`Get Account Page Validation Error`)
console.error(validatedAccountPage.error)
throw badRequestError()
}
// TODO: Make returned data nicer

View File

@@ -1,6 +1,7 @@
import { Lang } from "@/constants/languages"
import { z } from "zod"
import { Lang } from "@/constants/languages"
export const validateBreadcrumbsRefsConstenstackSchema = z.object({
all_account_page: z.object({
items: z.array(

View File

@@ -6,8 +6,8 @@ import { DynamicContentComponents } from "@/types/components/myPages/myPage/enum
export type AccountPageContentProps = {
component: DynamicContentComponents
props: {
title?: string
subtitle?: string
title: string | null
subtitle: string | null
link?: { href: string; text: string }
lang: Lang
}
@@ -15,8 +15,8 @@ export type AccountPageContentProps = {
export type AccountPageComponentProps = {
lang: Lang
title?: string
subtitle?: string
title: string | null
subtitle: string | null
link?: { href: string; text: string }
}

View File

@@ -1,5 +1,5 @@
import type { User } from "@/types/user"
export type OverviewProps = {
title?: string
title: string | null
}

View File

@@ -1,5 +1,5 @@
export type HeaderProps = {
title?: string
subtitle?: string
title: string | null
subtitle: string | null
link?: { href: string; text: string }
}