feat(SW-66, SW-348): search functionality and ui
This commit is contained in:
@@ -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,
|
||||
})
|
||||
),
|
||||
}),
|
||||
|
||||
@@ -3,7 +3,7 @@ import { metrics } from "@opentelemetry/api"
|
||||
import {
|
||||
GetNavigationMyPages,
|
||||
GetNavigationMyPagesRefs,
|
||||
} from "@/lib/graphql/Query/NavigationMyPages.graphql"
|
||||
} from "@/lib/graphql/Query/AccountPage/Navigation.graphql"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
import { notFound } from "@/server/errors/trpc"
|
||||
import { contentstackBaseProcedure, router } from "@/server/trpc"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { removeMultipleSlashes } from "@/utils/url"
|
||||
|
||||
import { PageLinkEnum } from "@/types/requests/pageLinks"
|
||||
import { ContentEnum } from "@/types/enums/content"
|
||||
import type { Edges } from "@/types/requests/utils/edges"
|
||||
import type { NodeRefs } from "@/types/requests/utils/refs"
|
||||
import type { GetNavigationMyPagesRefsData, MenuItems } from "./output"
|
||||
@@ -32,8 +32,8 @@ export function mapMenuItems(menuItems: MenuItems) {
|
||||
const page = link.page.edges[0].node
|
||||
let originalUrl = undefined
|
||||
if (
|
||||
page.__typename === PageLinkEnum.ContentPage ||
|
||||
page.__typename === PageLinkEnum.LoyaltyPage
|
||||
page.__typename === ContentEnum.blocks.ContentPage ||
|
||||
page.__typename === ContentEnum.blocks.LoyaltyPage
|
||||
) {
|
||||
if (page.web.original_url) {
|
||||
originalUrl = page.web.original_url
|
||||
|
||||
Reference in New Issue
Block a user