chore: change account page breadcrumbs to same structure as loyalty page
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
fragment AccountPageBreadcrumbs on AccountPage {
|
||||
breadcrumbs {
|
||||
title
|
||||
parentsConnection {
|
||||
edges {
|
||||
node {
|
||||
... on AccountPage {
|
||||
breadcrumbs {
|
||||
title
|
||||
web {
|
||||
breadcrumbs {
|
||||
title
|
||||
parentsConnection {
|
||||
edges {
|
||||
node {
|
||||
... on AccountPage {
|
||||
breadcrumbs {
|
||||
title
|
||||
}
|
||||
system {
|
||||
locale
|
||||
uid
|
||||
}
|
||||
url
|
||||
}
|
||||
system {
|
||||
locale
|
||||
uid
|
||||
}
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
#import "./System.graphql"
|
||||
|
||||
fragment AccountPageBreadcrumbsRefs on AccountPage {
|
||||
breadcrumbs {
|
||||
parentsConnection {
|
||||
edges {
|
||||
node {
|
||||
... on AccountPage {
|
||||
system {
|
||||
...System
|
||||
web {
|
||||
breadcrumbs {
|
||||
title
|
||||
parentsConnection {
|
||||
edges {
|
||||
node {
|
||||
... on AccountPage {
|
||||
breadcrumbs {
|
||||
title
|
||||
}
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,18 +6,20 @@ export const validateBreadcrumbsRefsConstenstackSchema = z.object({
|
||||
all_account_page: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
breadcrumbs: z.object({
|
||||
parentsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
system: z.object({
|
||||
content_type_uid: z.string(),
|
||||
uid: z.string(),
|
||||
web: z.object({
|
||||
breadcrumbs: z.object({
|
||||
parentsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
system: z.object({
|
||||
content_type_uid: z.string(),
|
||||
uid: z.string(),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
),
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
system: z.object({
|
||||
@@ -33,23 +35,25 @@ export const validateBreadcrumbsContenstackSchema = z.object({
|
||||
all_account_page: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
breadcrumbs: z.object({
|
||||
title: z.string(),
|
||||
parentsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
breadcrumbs: z.object({
|
||||
title: z.string(),
|
||||
web: z.object({
|
||||
breadcrumbs: z.object({
|
||||
title: z.string(),
|
||||
parentsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
breadcrumbs: z.object({
|
||||
title: z.string(),
|
||||
}),
|
||||
system: z.object({
|
||||
locale: z.nativeEnum(Lang),
|
||||
uid: z.string(),
|
||||
}),
|
||||
url: z.string(),
|
||||
}),
|
||||
system: z.object({
|
||||
locale: z.nativeEnum(Lang),
|
||||
uid: z.string(),
|
||||
}),
|
||||
url: z.string(),
|
||||
}),
|
||||
})
|
||||
),
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
system: z.object({
|
||||
|
||||
@@ -49,11 +49,11 @@ export const breadcrumbsQueryRouter = router({
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
console.log([generateRefsResponseTag(ctx.lang, ctx.pathname, affix)])
|
||||
if (!refsResponse.data) {
|
||||
throw notFound(refsResponse)
|
||||
}
|
||||
|
||||
console.log(refsResponse)
|
||||
const validatedRefsData =
|
||||
validateBreadcrumbsRefsConstenstackSchema.safeParse(refsResponse.data)
|
||||
if (!validatedRefsData.success) {
|
||||
@@ -82,7 +82,7 @@ export const breadcrumbsQueryRouter = router({
|
||||
}
|
||||
|
||||
const parentBreadcrumbs =
|
||||
validatedBreadcrumbsData.data.all_account_page.items[0].breadcrumbs.parentsConnection.edges.map(
|
||||
validatedBreadcrumbsData.data.all_account_page.items[0].web.breadcrumbs.parentsConnection.edges.map(
|
||||
(breadcrumb) => {
|
||||
return {
|
||||
href: removeMultipleSlashes(
|
||||
@@ -97,11 +97,11 @@ export const breadcrumbsQueryRouter = router({
|
||||
const pageBreadcrumb =
|
||||
validatedBreadcrumbsData.data.all_account_page.items.map((breadcrumb) => {
|
||||
return {
|
||||
title: breadcrumb.breadcrumbs.title,
|
||||
title: breadcrumb.web.breadcrumbs.title,
|
||||
uid: breadcrumb.system.uid,
|
||||
}
|
||||
})
|
||||
|
||||
console.log(pageBreadcrumb)
|
||||
const breadcrumbs = [
|
||||
homeBreadcrumbs[ctx.lang],
|
||||
parentBreadcrumbs,
|
||||
@@ -126,7 +126,7 @@ export const breadcrumbsQueryRouter = router({
|
||||
}
|
||||
)
|
||||
console.log(ctx.pathname)
|
||||
console.log(refsResponse.data.all_loyalty_page)
|
||||
console.log(refsResponse)
|
||||
if (!refsResponse.data) {
|
||||
throw notFound(refsResponse)
|
||||
}
|
||||
@@ -161,7 +161,7 @@ export const breadcrumbsQueryRouter = router({
|
||||
if (!validatedBreadcrumbsData.success) {
|
||||
throw internalServerError(validatedBreadcrumbsData.error)
|
||||
}
|
||||
|
||||
console.log(validatedBreadcrumbsData)
|
||||
const parentBreadcrumbs =
|
||||
validatedBreadcrumbsData.data.all_loyalty_page.items[0].web.breadcrumbs.parentsConnection.edges.map(
|
||||
(breadcrumb) => {
|
||||
@@ -182,18 +182,18 @@ export const breadcrumbsQueryRouter = router({
|
||||
uid: breadcrumb.system.uid,
|
||||
}
|
||||
})
|
||||
|
||||
const breadcrumbs = [
|
||||
homeBreadcrumbs[ctx.lang],
|
||||
parentBreadcrumbs,
|
||||
pageBreadcrumb,
|
||||
].flat()
|
||||
console.log(breadcrumbs)
|
||||
|
||||
const validatedBreadcrumbs = getBreadcrumbsSchema.safeParse(breadcrumbs)
|
||||
if (!validatedBreadcrumbs.success) {
|
||||
throw internalServerError(validatedBreadcrumbs.error)
|
||||
}
|
||||
|
||||
console.log(validatedBreadcrumbs.data)
|
||||
return validatedBreadcrumbs.data
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -10,9 +10,9 @@ import type { NodeRefs } from "@/types/requests/utils/refs"
|
||||
export function getConnections(refs: GetAccountPageBreadcrumbsRefsData) {
|
||||
const connections: Edges<NodeRefs>[] = []
|
||||
refs.all_account_page.items.forEach((ref) => {
|
||||
console.log(ref)
|
||||
console.log(ref.breadcrumbs.parentsConnection)
|
||||
connections.push(ref.breadcrumbs.parentsConnection)
|
||||
console.log(ref.web.breadcrumbs)
|
||||
console.log(ref.web.breadcrumbs.parentsConnection)
|
||||
connections.push(ref.web.breadcrumbs.parentsConnection)
|
||||
})
|
||||
|
||||
return connections
|
||||
|
||||
@@ -5,21 +5,23 @@ import type { AllRequestResponse } from "../utils/all"
|
||||
import type { Edges } from "../utils/edges"
|
||||
|
||||
interface AccountPageBreadcrumbs {
|
||||
breadcrumbs: {
|
||||
title: string
|
||||
parentsConnection: Edges<{
|
||||
breadcrumbs: {
|
||||
title: string
|
||||
}
|
||||
system: {
|
||||
locale: Lang
|
||||
uid: string
|
||||
}
|
||||
url: string
|
||||
}>
|
||||
}
|
||||
system: {
|
||||
uid: string
|
||||
web: {
|
||||
breadcrumbs: {
|
||||
title: string
|
||||
parentsConnection: Edges<{
|
||||
breadcrumbs: {
|
||||
title: string
|
||||
}
|
||||
system: {
|
||||
locale: Lang
|
||||
uid: string
|
||||
}
|
||||
url: string
|
||||
}>
|
||||
}
|
||||
system: {
|
||||
uid: string
|
||||
}
|
||||
}
|
||||
}
|
||||
interface LoyaltyPageBreadcrumbs {
|
||||
@@ -58,8 +60,10 @@ export interface GetLoyaltyPageBreadcrumbsData {
|
||||
}
|
||||
|
||||
interface AccountPageBreadcrumbRefs extends System {
|
||||
breadcrumbs: {
|
||||
parentsConnection: Edges<System>
|
||||
web: {
|
||||
breadcrumbs: {
|
||||
parentsConnection: Edges<System>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user