fix: correct Shortcuts

This commit is contained in:
Arvid Norlin
2024-04-24 16:15:46 +02:00
parent dd2127749a
commit 03daf0540e
5 changed files with 23 additions and 8 deletions

View File

@@ -66,9 +66,13 @@ export default function Content({ user, lang, content }: ContentProps) {
/> />
) )
case ContentEntries.AccountPageContentShortcuts: case ContentEntries.AccountPageContentShortcuts:
const shortcuts = item.shortcuts.shortcuts.map( const shortcuts = item.shortcuts.shortcuts.map((shortcut) => {
(shortcut) => shortcut.linkConnection.edges[0].node return {
) text: shortcut.text,
openInNewTab: shortcut.open_in_new_tab,
...shortcut.linkConnection.edges[0].node,
}
})
return ( return (
<Shortcuts <Shortcuts
shortcuts={shortcuts} shortcuts={shortcuts}

View File

@@ -26,8 +26,9 @@ export default function Shortcuts({
className={styles.link} className={styles.link}
href={shortcut.url} href={shortcut.url}
key={shortcut.title} key={shortcut.title}
target={shortcut.openInNewTab ? "_blank" : undefined}
> >
<span>{shortcut.title}</span> <span>{shortcut.text ? shortcut.text : shortcut.title}</span>
<Image <Image
alt="Chevron Icon" alt="Chevron Icon"
height={20} height={20}

View File

@@ -7,6 +7,8 @@ fragment AccountPageContentShortcuts on AccountPageContentShortcuts {
title title
preamble preamble
shortcuts { shortcuts {
text
open_in_new_tab
linkConnection { linkConnection {
edges { edges {
node { node {

View File

@@ -1,7 +1,13 @@
import { ReactNode } from "react" import { ReactNode } from "react"
export type ShortcutsProps = { export type ShortcutsProps = {
shortcuts: { url: string; title: string }[] shortcuts: {
url: string
title: string
openInNewTab?: boolean
text?: string
}[]
title: string | ReactNode title: string | ReactNode
subtitle?: string subtitle?: string
openInNewTab?: boolean
} }

View File

@@ -1,8 +1,9 @@
import { AllRequestResponse } from "../utils/all" import { AllRequestResponse } from "../utils/all"
import type { Typename } from "../utils/typename"
import type { Edges } from "../utils/edges"
import { PageLink } from "../utils/pageLink" import { PageLink } from "../utils/pageLink"
import { RTEDocument } from "@/types/rte/node" import { RTEDocument } from "@/types/rte/node"
import type { Edges } from "../utils/edges"
import type { Typename } from "../utils/typename"
export enum DynamicContentComponents { export enum DynamicContentComponents {
membership_overview = "membership_overview", membership_overview = "membership_overview",
@@ -20,8 +21,9 @@ export enum ContentEntries {
} }
type Shortcut = { type Shortcut = {
text: string
linkConnection: Edges<PageLink> linkConnection: Edges<PageLink>
open_in_new_tab: boolean
text: string
} }
type DynamicContent = { type DynamicContent = {