feat(SW-572): Added support for logged in and logged out variants of the top link inside the header

This commit is contained in:
Erik Tiekstra
2024-11-11 14:03:08 +01:00
parent cc9f0509a1
commit d732138696
17 changed files with 215 additions and 68 deletions

View File

@@ -14,6 +14,7 @@ import { removeMultipleSlashes } from "@/utils/url"
import { systemSchema } from "../schemas/system"
import { IconName } from "@/types/components/icon"
import { AlertTypeEnum } from "@/types/enums/alert"
import type { Image } from "@/types/image"
@@ -514,6 +515,11 @@ const menuItemsRefsSchema = z.intersection(
})
)
const topLinkRefsSchema = z.object({
logged_in: linkRefsSchema.nullable(),
logged_out: linkRefsSchema.nullable(),
})
export const headerRefsSchema = z
.object({
all_header: z.object({
@@ -522,7 +528,7 @@ export const headerRefsSchema = z
z.object({
menu_items: z.array(menuItemsRefsSchema),
system: systemSchema,
top_link: linkRefsSchema,
top_link: topLinkRefsSchema,
})
)
.max(1),
@@ -636,6 +642,32 @@ export const menuItemSchema = z
}
})
const topLinkItemSchema = z.intersection(
linkAndTitleSchema,
z.object({
icon: z
.enum(["loyalty", "info", "offer"])
.nullable()
.transform((icon) => {
switch (icon) {
case "loyalty":
return IconName.Gift
case "info":
return IconName.InfoCircle
case "offer":
return IconName.PriceTag
default:
return null
}
}),
})
)
export const topLinkSchema = z.object({
logged_in: topLinkItemSchema.nullable(),
logged_out: topLinkItemSchema.nullable(),
})
export const headerSchema = z
.object({
all_header: z.object({
@@ -643,7 +675,7 @@ export const headerSchema = z
.array(
z.object({
menu_items: z.array(menuItemSchema),
top_link: linkAndTitleSchema,
top_link: topLinkSchema,
})
)
.max(1),