fix: change optional to nullable in validation
This commit is contained in:
@@ -3,7 +3,7 @@ export type CardProps = {
|
||||
href: string
|
||||
title: string
|
||||
}
|
||||
title?: string
|
||||
subtitle?: string
|
||||
title?: string | null
|
||||
subtitle?: string | null
|
||||
openInNewTab?: boolean
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ query GetLoyaltyPage($locale: String!, $url: String!) {
|
||||
}
|
||||
}
|
||||
title
|
||||
heading
|
||||
sidebar {
|
||||
__typename
|
||||
... on LoyaltyPageSidebarJoinLoyaltyContact {
|
||||
|
||||
@@ -55,6 +55,6 @@ export type ContactConfigData = z.infer<typeof validateContactConfigSchema>
|
||||
export type ContactConfig = ContactConfigData["all_contact_config"]["items"][0]
|
||||
|
||||
export type ContactFields = {
|
||||
display_text?: string
|
||||
display_text: string | null
|
||||
contact_field: string
|
||||
}
|
||||
|
||||
@@ -15,18 +15,19 @@ import { RTEDocument } from "@/types/rte/node"
|
||||
const loyaltyPageBlockCardGrid = z.object({
|
||||
__typename: z.literal(LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardGrid),
|
||||
card_grid: z.object({
|
||||
title: z.string().optional(),
|
||||
subtitle: z.string().optional(),
|
||||
title: z.string().nullable(),
|
||||
subtitle: z.string().nullable(),
|
||||
cards: z.array(
|
||||
z.object({
|
||||
title: z.string().optional(),
|
||||
subtitle: z.string().optional(),
|
||||
title: z.string().nullable(),
|
||||
subtitle: z.string().nullable(),
|
||||
referenceConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
system: z.object({
|
||||
uid: z.string(),
|
||||
locale: z.nativeEnum(Lang),
|
||||
}),
|
||||
url: z.string(),
|
||||
title: z.string(),
|
||||
@@ -37,7 +38,7 @@ const loyaltyPageBlockCardGrid = z.object({
|
||||
totalCount: z.number(),
|
||||
}),
|
||||
open_in_new_tab: z.boolean(),
|
||||
cta_text: z.string().optional(),
|
||||
cta_text: z.string().nullable(),
|
||||
})
|
||||
),
|
||||
}),
|
||||
@@ -47,11 +48,11 @@ const loyaltyPageDynamicContent = z.object({
|
||||
LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksDynamicContent
|
||||
),
|
||||
dynamic_content: z.object({
|
||||
title: z.string().optional(),
|
||||
subtitle: z.string().optional(),
|
||||
title: z.string().nullable(),
|
||||
subtitle: z.string().nullable(),
|
||||
component: z.nativeEnum(LoyaltyComponentEnum),
|
||||
link: z.object({
|
||||
text: z.string().optional(),
|
||||
text: z.string().nullable(),
|
||||
pageConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
@@ -74,8 +75,8 @@ const loyaltyPageDynamicContent = z.object({
|
||||
const loyaltyPageShortcuts = z.object({
|
||||
__typename: z.literal(LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts),
|
||||
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({
|
||||
@@ -89,16 +90,16 @@ const loyaltyPageShortcuts = z.object({
|
||||
url: z.string(),
|
||||
web: z
|
||||
.object({
|
||||
original_url: z.string().optional(),
|
||||
original_url: z.string().nullable(),
|
||||
})
|
||||
.optional(),
|
||||
.nullable(),
|
||||
title: z.string(),
|
||||
}),
|
||||
})
|
||||
),
|
||||
totalCount: z.number(),
|
||||
}),
|
||||
text: z.string().optional(),
|
||||
text: z.string().nullable(),
|
||||
open_in_new_tab: z.boolean(),
|
||||
})
|
||||
),
|
||||
@@ -143,15 +144,15 @@ const loyaltyPageJoinLoyaltyContact = z.object({
|
||||
SidebarTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContact
|
||||
),
|
||||
join_loyalty_contact: z.object({
|
||||
title: z.string().optional(),
|
||||
preamble: z.string().optional(),
|
||||
title: z.string().nullable(),
|
||||
preamble: z.string().nullable(),
|
||||
contact: z.array(
|
||||
z.object({
|
||||
__typename: z.literal(
|
||||
JoinLoyaltyContactTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContactBlockContactContact
|
||||
),
|
||||
contact: z.object({
|
||||
display_text: z.string().optional(),
|
||||
display_text: z.string().nullable(),
|
||||
|
||||
contact_field: z.string(),
|
||||
}),
|
||||
@@ -170,8 +171,10 @@ export const validateLoyaltyPageSchema = z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
title: z.string(),
|
||||
heading: z.string().nullable(),
|
||||
blocks: z.array(loyaltyPageBlockItem).nullable(),
|
||||
sidebar: z.array(loyaltyPageSidebarItem).nullable(),
|
||||
system: z.object({ uid: z.string() }),
|
||||
})
|
||||
),
|
||||
}),
|
||||
|
||||
@@ -80,8 +80,7 @@ export const loyaltyPageQueryRouter = router({
|
||||
...card,
|
||||
link: card.referenceConnection.totalCount
|
||||
? {
|
||||
href: card.referenceConnection.edges[0].node
|
||||
.url,
|
||||
href: `/${card.referenceConnection.edges[0].node.system.locale}${card.referenceConnection.edges[0].node.url}`,
|
||||
title: card.cta_text || _("Read more"),
|
||||
}
|
||||
: undefined,
|
||||
@@ -97,8 +96,7 @@ export const loyaltyPageQueryRouter = router({
|
||||
link: block.dynamic_content.link.pageConnection.totalCount
|
||||
? {
|
||||
text: block.dynamic_content.link.text,
|
||||
href: block.dynamic_content.link.pageConnection
|
||||
.edges[0].node.url,
|
||||
href: `/${block.dynamic_content.link.pageConnection.edges[0].node.system.locale}${block.dynamic_content.link.pageConnection.edges[0].node.url}`,
|
||||
title:
|
||||
block.dynamic_content.link.pageConnection.edges[0]
|
||||
.node.title,
|
||||
|
||||
@@ -8,6 +8,6 @@ export type ShortcutsProps = {
|
||||
text?: string
|
||||
}[]
|
||||
title: string | ReactNode
|
||||
subtitle?: string
|
||||
subtitle?: string | null
|
||||
openInNewTab?: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user