feat(SW-186): implemented queries and typings for menu inside header query
This commit is contained in:
@@ -297,11 +297,50 @@ export type InternalExternalLinkData = z.infer<
|
||||
typeof internalExternalLinkSchema
|
||||
>
|
||||
|
||||
const cardButtonSchema = z.object({
|
||||
cta_text: z.string(),
|
||||
external_link: z.object({
|
||||
href: z.string(),
|
||||
title: z.string(),
|
||||
}),
|
||||
is_contentstack_link: z.boolean(),
|
||||
linkConnection: linkConnectionNodeSchema,
|
||||
open_in_new_tab: z.boolean(),
|
||||
})
|
||||
|
||||
const menuItemSchema = z.object({
|
||||
title: z.string(),
|
||||
link: internalExternalLinkSchema,
|
||||
submenu: z.array(
|
||||
z.object({
|
||||
title: z.string(),
|
||||
links: z.array(internalExternalLinkSchema),
|
||||
})
|
||||
),
|
||||
see_all_link: internalExternalLinkSchema,
|
||||
// cardConnection: z.array(
|
||||
// z.object({
|
||||
// node: z.object({
|
||||
// title: z.string(),
|
||||
// heading: z.string(),
|
||||
// body_text: z.string(),
|
||||
// background_image: z.any(), // TODO: Any for now, should be Image
|
||||
// has_primary_button: z.boolean(),
|
||||
// has_secondary_button: z.boolean(),
|
||||
// scripted_top_title: z.string(),
|
||||
// primary_button: cardButtonSchema,
|
||||
// secondary_button: cardButtonSchema,
|
||||
// }),
|
||||
// })
|
||||
// ),
|
||||
})
|
||||
|
||||
export const validateHeaderSchema = z.object({
|
||||
all_header: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
top_link: internalExternalLinkSchema.optional(),
|
||||
menu_items: z.array(menuItemSchema),
|
||||
})
|
||||
),
|
||||
}),
|
||||
@@ -316,11 +355,24 @@ export type InternalExternalLink = {
|
||||
openInNewTab: boolean
|
||||
}
|
||||
|
||||
export type SubmenuItem = {
|
||||
title: string
|
||||
links: InternalExternalLink[]
|
||||
}
|
||||
|
||||
export type MenuItem = {
|
||||
title: string
|
||||
link: InternalExternalLink | null
|
||||
seeAllLink: InternalExternalLink | null
|
||||
submenu: SubmenuItem[]
|
||||
}
|
||||
|
||||
export type HeaderData = Omit<
|
||||
HeaderDataRaw["all_header"]["items"][0],
|
||||
"top_link"
|
||||
"top_link" | "menu_items"
|
||||
> & {
|
||||
topLink: InternalExternalLink | null
|
||||
menuItems: MenuItem[]
|
||||
}
|
||||
|
||||
const validateHeaderRefSchema = z.object({
|
||||
|
||||
Reference in New Issue
Block a user