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