fix: correct acount page linking
This commit is contained in:
@@ -44,8 +44,10 @@ export default function Content({ lang, content }: ContentProps) {
|
|||||||
case ContentEntries.AccountPageContentDynamicContent:
|
case ContentEntries.AccountPageContentDynamicContent:
|
||||||
const link = item.dynamic_content.link.linkConnection.edges.length
|
const link = item.dynamic_content.link.linkConnection.edges.length
|
||||||
? {
|
? {
|
||||||
href: item.dynamic_content.link.linkConnection.edges[0].node
|
href:
|
||||||
.url,
|
item.dynamic_content.link.linkConnection.edges[0].node
|
||||||
|
.original_url ||
|
||||||
|
`/${lang}${item.dynamic_content.link.linkConnection.edges[0].node.url}`,
|
||||||
text: item.dynamic_content.link.link_text,
|
text: item.dynamic_content.link.link_text,
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
@@ -64,16 +66,9 @@ export default function Content({ lang, content }: ContentProps) {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case ContentEntries.AccountPageContentShortcuts:
|
case ContentEntries.AccountPageContentShortcuts:
|
||||||
const shortcuts = item.shortcuts.shortcuts.map((shortcut) => {
|
|
||||||
return {
|
|
||||||
text: shortcut.text,
|
|
||||||
openInNewTab: shortcut.open_in_new_tab,
|
|
||||||
...shortcut.linkConnection.edges[0].node,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return (
|
return (
|
||||||
<Shortcuts
|
<Shortcuts
|
||||||
shortcuts={shortcuts}
|
shortcuts={item.shortcuts.shortcuts}
|
||||||
subtitle={item.shortcuts.preamble}
|
subtitle={item.shortcuts.preamble}
|
||||||
title={item.shortcuts.title}
|
title={item.shortcuts.title}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const accountPageShortcuts = z.object({
|
|||||||
uid: z.string(),
|
uid: z.string(),
|
||||||
locale: z.nativeEnum(Lang),
|
locale: z.nativeEnum(Lang),
|
||||||
}),
|
}),
|
||||||
|
original_url: z.string().optional(),
|
||||||
url: z.string(),
|
url: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
}),
|
}),
|
||||||
@@ -55,6 +56,7 @@ const accountPageDynamicContent = z.object({
|
|||||||
locale: z.nativeEnum(Lang),
|
locale: z.nativeEnum(Lang),
|
||||||
}),
|
}),
|
||||||
url: z.string(),
|
url: z.string(),
|
||||||
|
original_url: z.string().optional(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -86,6 +88,17 @@ type DynamicContentRaw = z.infer<typeof accountPageDynamicContent>
|
|||||||
|
|
||||||
type ShortcutsRaw = z.infer<typeof accountPageShortcuts>
|
type ShortcutsRaw = z.infer<typeof accountPageShortcuts>
|
||||||
|
|
||||||
|
export type Shortcuts = Omit<ShortcutsRaw, "shortcuts"> & {
|
||||||
|
shortcuts: Omit<ShortcutsRaw["shortcuts"], "shortcuts"> & {
|
||||||
|
shortcuts: {
|
||||||
|
text?: string
|
||||||
|
openInNewTab: boolean
|
||||||
|
url: string
|
||||||
|
title: string
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type RteTextContent = Omit<TextContentRaw, "text_content"> & {
|
export type RteTextContent = Omit<TextContentRaw, "text_content"> & {
|
||||||
text_content: {
|
text_content: {
|
||||||
content: {
|
content: {
|
||||||
@@ -97,7 +110,7 @@ export type RteTextContent = Omit<TextContentRaw, "text_content"> & {
|
|||||||
|
|
||||||
export type AccountPageContentItem =
|
export type AccountPageContentItem =
|
||||||
| DynamicContentRaw
|
| DynamicContentRaw
|
||||||
| ShortcutsRaw
|
| Shortcuts
|
||||||
| RteTextContent
|
| RteTextContent
|
||||||
|
|
||||||
const accountPageContentItem = z.discriminatedUnion("__typename", [
|
const accountPageContentItem = z.discriminatedUnion("__typename", [
|
||||||
|
|||||||
@@ -36,8 +36,22 @@ export const accountPageQueryRouter = router({
|
|||||||
(block) => {
|
(block) => {
|
||||||
switch (block.__typename) {
|
switch (block.__typename) {
|
||||||
case ContentEntries.AccountPageContentDynamicContent:
|
case ContentEntries.AccountPageContentDynamicContent:
|
||||||
case ContentEntries.AccountPageContentShortcuts:
|
|
||||||
return block
|
return block
|
||||||
|
case ContentEntries.AccountPageContentShortcuts:
|
||||||
|
return {
|
||||||
|
...block,
|
||||||
|
shortcuts: {
|
||||||
|
...block.shortcuts,
|
||||||
|
shortcuts: block.shortcuts.shortcuts.map((shortcut) => ({
|
||||||
|
text: shortcut.text,
|
||||||
|
openInNewTab: shortcut.open_in_new_tab,
|
||||||
|
...shortcut.linkConnection.edges[0].node,
|
||||||
|
url:
|
||||||
|
shortcut.linkConnection.edges[0].node.original_url ||
|
||||||
|
`/${shortcut.linkConnection.edges[0].node.system.locale}${shortcut.linkConnection.edges[0].node.url}`,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
}
|
||||||
case ContentEntries.AccountPageContentTextContent:
|
case ContentEntries.AccountPageContentTextContent:
|
||||||
return {
|
return {
|
||||||
...block,
|
...block,
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ const loyaltyPageShortcuts = z.object({
|
|||||||
url: z.string(),
|
url: z.string(),
|
||||||
web: z
|
web: z
|
||||||
.object({
|
.object({
|
||||||
original_url: z.string(),
|
original_url: z.string().optional(),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user