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

View File

@@ -1,49 +1,17 @@
import { z } from "zod"
import { Lang } from "@/constants/languages"
import * as pageLinks from "@/server/routers/contentstack/schemas/pageLinks"
import { PageLinkEnum } from "@/types/requests/pageLinks"
const node = z.object({
system: z.object({
locale: z.nativeEnum(Lang),
uid: z.string(),
}),
title: z.string(),
url: z.string(),
})
const web = z.object({
original_url: z.string().optional(),
})
const accountPageLink = z
.object({
__typename: z.literal(PageLinkEnum.AccountPage),
})
.merge(node)
const contentPageLink = z
.object({
__typename: z.literal(PageLinkEnum.ContentPage),
web,
})
.merge(node)
const loyaltyPageLink = z
.object({
__typename: z.literal(PageLinkEnum.LoyaltyPage),
web,
})
.merge(node)
import { systemSchema } from "../../schemas/system"
const pageConnection = z.object({
edges: z.array(
z.object({
node: z.discriminatedUnion("__typename", [
accountPageLink,
contentPageLink,
loyaltyPageLink,
pageLinks.accountPageSchema,
pageLinks.contentPageSchema,
pageLinks.loyaltyPageSchema,
]),
})
),
@@ -52,13 +20,11 @@ const pageConnection = z.object({
const pageConnectionRefs = z.object({
edges: z.array(
z.object({
node: z.object({
__typename: z.nativeEnum(PageLinkEnum),
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
}),
node: z.discriminatedUnion("__typename", [
pageLinks.accountPageRefSchema,
pageLinks.contentPageRefSchema,
pageLinks.loyaltyPageRefSchema,
]),
})
),
})
@@ -76,10 +42,7 @@ export const navigationRefsPayloadSchema = z.object({
),
})
),
system: z.object({
content_type_uid: z.string(),
uid: z.string(),
}),
system: systemSchema,
})
),
}),