feat(SW-186): implement cms data into new header
This commit is contained in:
@@ -301,11 +301,11 @@ const linkConnectionNodeSchema = z
|
||||
|
||||
const linkWithTitleSchema = z
|
||||
.object({
|
||||
title: z.string(),
|
||||
title: z.string().nullable(),
|
||||
linkConnection: linkConnectionNodeSchema,
|
||||
})
|
||||
.transform((rawData) => {
|
||||
return rawData.linkConnection
|
||||
return rawData.linkConnection && rawData.title
|
||||
? {
|
||||
title: rawData.title,
|
||||
href: rawData.linkConnection.href,
|
||||
@@ -378,7 +378,7 @@ const cardConnectionSchema = z
|
||||
}
|
||||
})
|
||||
|
||||
const menuItemSchema = z
|
||||
export const menuItemSchema = z
|
||||
.object({
|
||||
title: z.string(),
|
||||
linkConnection: linkConnectionNodeSchema,
|
||||
@@ -391,22 +391,25 @@ const menuItemSchema = z
|
||||
see_all_link: linkWithTitleSchema,
|
||||
cardConnection: cardConnectionSchema,
|
||||
})
|
||||
.transform(({ submenu, linkConnection, cardConnection, see_all_link }) => {
|
||||
return {
|
||||
link: submenu.length ? null : linkConnection,
|
||||
seeAllLink: submenu.length ? see_all_link : null,
|
||||
submenu,
|
||||
card: cardConnection,
|
||||
.transform(
|
||||
({ submenu, linkConnection, cardConnection, see_all_link, title }) => {
|
||||
return {
|
||||
title,
|
||||
link: submenu.length ? null : linkConnection,
|
||||
seeAllLink: submenu.length ? see_all_link : null,
|
||||
submenu,
|
||||
card: cardConnection,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
export const getHeaderSchema = z
|
||||
.object({
|
||||
all_header: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
top_link: linkWithTitleSchema,
|
||||
menu_items: z.array(menuItemSchema),
|
||||
top_link: linkWithTitleSchema.nullable(),
|
||||
menu_items: z.array(menuItemSchema).nullable(),
|
||||
})
|
||||
),
|
||||
}),
|
||||
|
||||
@@ -183,12 +183,12 @@ export const baseQueryRouter = router({
|
||||
|
||||
const response = await request<HeaderResponse>(
|
||||
GetHeader,
|
||||
{ locale: lang },
|
||||
{
|
||||
tags: [
|
||||
generateTag(lang, responseRef.data.all_header.items[0].system.uid),
|
||||
],
|
||||
}
|
||||
{ locale: lang }
|
||||
// {
|
||||
// tags: [
|
||||
// generateTag(lang, responseRef.data.all_header.items[0].system.uid),
|
||||
// ],
|
||||
// }
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
|
||||
Reference in New Issue
Block a user