Files
web/components/MyPages/Sidebar/index.tsx
Joakim Jäderberg 6f51130e48 Merged in feature/hardcoded-mypages-links (pull request #1325)
Feature/hardcoded mypages links

* feat: wip use hardcoded links

* Merge branch 'master' of bitbucket.org:scandic-swap/web into feature/hardcoded-mypages-links

* feat: use hardcoded links for my pages to support dynamic links

* cleanup

* code fixes

* refactor: restructure MyPagesMobileDropdown component for improved readability

* use util timeout function


Approved-by: Christian Andolf
Approved-by: Linus Flood
2025-02-13 09:28:30 +00:00

98 lines
2.2 KiB
TypeScript

import { logout } from "@/constants/routes/handleAuth"
import {
getPrimaryLinks,
getSecondaryLinks,
} from "@/components/MyPages/menuItems"
import Divider from "@/components/TempDesignSystem/Divider"
import Link from "@/components/TempDesignSystem/Link"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import styles from "./sidebar.module.css"
export default async function SidebarMyPages() {
const intl = await getIntl()
return (
<aside className={styles.sidebar}>
<nav className={styles.nav}>
<Subtitle type="two" color="baseTextHighContrast">
{intl.formatMessage({ id: "My pages" })}
</Subtitle>
<PrimaryLinks />
<SecondaryLinks />
</nav>
</aside>
)
}
async function PrimaryLinks() {
const lang = getLang()
const links = await getPrimaryLinks({ lang })
return (
<>
<Divider color="beige" />
<ul className={styles.list}>
{links.map((link) => (
<li key={link.href}>
<Link
color="burgundy"
href={link.href}
partialMatch
prefetch={true}
size={"regular"}
variant="sidebar"
>
{link.text}
</Link>
</li>
))}
</ul>
</>
)
}
async function SecondaryLinks() {
const lang = getLang()
const links = await getSecondaryLinks({ lang })
const intl = await getIntl()
return (
<>
<Divider color="beige" />
<ul className={styles.list}>
{links.map((link) => (
<li key={link.href}>
<Link
color="burgundy"
href={link.href}
partialMatch
prefetch={true}
size={"small"}
variant="sidebar"
>
{link.text}
</Link>
</li>
))}
<li>
<Link
color="burgundy"
href={logout[lang]}
partialMatch
prefetch={false}
size={"small"}
variant="sidebar"
>
{intl.formatMessage({ id: "Log out" })}
</Link>
</li>
</ul>
</>
)
}