feat(SW-66, SW-348): search functionality and ui

This commit is contained in:
Simon Emanuelsson
2024-08-28 10:47:57 +02:00
parent b9dbcf7d90
commit af850c90e7
437 changed files with 7663 additions and 9881 deletions
+73 -83
View File
@@ -5,6 +5,7 @@ import { Lang } from "@/constants/languages"
import { removeMultipleSlashes } from "@/utils/url"
import { imageVaultAssetTransformedSchema } from "../schemas/imageVault"
import { systemSchema } from "../schemas/system"
import { Image } from "@/types/image"
@@ -68,74 +69,81 @@ export type ContactFields = {
footnote: string | null
}
export const validateCurrentHeaderConfigSchema = z.object({
all_current_header: z.object({
items: z.array(
z.object({
frontpage_link_text: z.string(),
logoConnection: z.object({
edges: z.array(
z.object({
node: z.object({
description: z.string().optional().nullable(),
dimension: z.object({
height: z.number(),
width: z.number(),
export const validateCurrentHeaderConfigSchema = z
.object({
all_current_header: z.object({
items: z.array(
z.object({
frontpage_link_text: z.string(),
logoConnection: z.object({
edges: z.array(
z.object({
node: z.object({
description: z.string().optional().nullable(),
dimension: z.object({
height: z.number(),
width: z.number(),
}),
metadata: z.any().nullable(),
system: z.object({
uid: z.string(),
}),
title: z.string().optional().default(""),
url: z.string().optional().default(""),
}),
metadata: z.any().nullable(),
system: z.object({
uid: z.string(),
}),
title: z.string().nullable(),
url: z.string().nullable(),
}),
})
),
}),
menu: z.object({
links: z.array(
z.object({
href: z.string(),
title: z.string(),
})
),
}),
top_menu: z.object({
links: z.array(
z.object({
link: z.object({
})
),
}),
menu: z.object({
links: z.array(
z.object({
href: z.string(),
title: z.string(),
}),
show_on_mobile: z.boolean(),
sort_order_mobile: z.number(),
})
),
}),
})
),
}),
})
})
),
}),
top_menu: z.object({
links: z.array(
z.object({
link: z.object({
href: z.string(),
title: z.string(),
}),
show_on_mobile: z.boolean(),
sort_order_mobile: z.number(),
})
),
}),
})
),
}),
})
.transform((data) => {
if (!data.all_current_header.items.length) {
return {
header: null,
}
}
const header = data.all_current_header.items[0]
return {
header: {
frontpageLinkText: header.frontpage_link_text,
logo: header.logoConnection.edges[0].node,
menu: header.menu,
topMenu: header.top_menu,
},
}
})
export type CurrentHeaderDataRaw = z.infer<
typeof validateCurrentHeaderConfigSchema
>
export type CurrentHeaderData = Omit<
CurrentHeaderDataRaw["all_current_header"]["items"][0],
"logoConnection"
> & {
logo: Image
}
export interface GetCurrentHeaderData
extends z.input<typeof validateCurrentHeaderConfigSchema> {}
export type HeaderData = z.output<typeof validateCurrentHeaderConfigSchema>
const validateCurrentHeaderRefConfigSchema = z.object({
all_current_header: z.object({
items: z.array(
z.object({
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
system: systemSchema,
})
),
}),
@@ -257,10 +265,7 @@ const validateCurrentFooterRefConfigSchema = z.object({
all_current_footer: z.object({
items: z.array(
z.object({
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
system: systemSchema,
})
),
}),
@@ -387,10 +392,7 @@ const pageConnectionRefs = z.object({
.array(
z.object({
node: z.object({
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
system: systemSchema,
}),
})
)
@@ -421,10 +423,7 @@ export const validateFooterRefConfigSchema = z.object({
pageConnection: pageConnectionRefs,
})
),
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
system: systemSchema,
})
)
.length(1),
@@ -437,10 +436,7 @@ const linkConnectionNodeSchema = z
.array(
z.object({
node: z.object({
system: z.object({
uid: z.string(),
locale: z.nativeEnum(Lang),
}),
system: systemSchema,
url: z.string(),
title: z.string(),
web: z.object({
@@ -595,10 +591,7 @@ const linkConnectionRefs = z.object({
.array(
z.object({
node: z.object({
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
system: systemSchema,
}),
})
)
@@ -656,10 +649,7 @@ export const getHeaderRefSchema = z.object({
),
})
),
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
system: systemSchema,
})
)
.length(1),