Redesign beta Magent UI
Magent CI/CD / verify (push) Successful in 11m8s
Magent CI/CD / deploy-prod (push) Has been skipped
Magent CI/CD / deploy-beta (push) Successful in 18s

This commit is contained in:
2026-06-21 11:41:38 +12:00
parent e36da13264
commit e6b4f99ea7
12 changed files with 1891 additions and 40 deletions
+45 -13
View File
@@ -1,10 +1,13 @@
'use client'
import { useEffect, useState } from 'react'
import { usePathname } from 'next/navigation'
import { authFetch, clearToken, getApiBase, getToken } from '../lib/auth'
export default function HeaderActions() {
const [signedIn, setSignedIn] = useState(false)
const [role, setRole] = useState<string | null>(null)
const pathname = usePathname()
useEffect(() => {
const token = getToken()
@@ -19,9 +22,11 @@ export default function HeaderActions() {
if (!response.ok) {
clearToken()
setSignedIn(false)
setRole(null)
return
}
await response.json()
const data = await response.json()
setRole(data?.role ?? null)
} catch (err) {
console.error(err)
}
@@ -33,18 +38,45 @@ export default function HeaderActions() {
return null
}
const items = [
{ href: '/', label: 'Health', icon: '01', match: (path: string) => path === '/' },
{
href: '/portal/requests',
label: 'Requests',
icon: '02',
match: (path: string) => path === '/portal/requests' || path.startsWith('/requests/'),
},
{
href: '/portal/issues',
label: 'Issues',
icon: '03',
match: (path: string) => path === '/portal/issues' || path === '/admin/issues',
},
{
href: role === 'admin' ? '/users' : '/profile',
label: role === 'admin' ? 'Users' : 'Profile',
icon: '04',
match: (path: string) => path.startsWith('/users') || path.startsWith('/profile'),
},
{
href: role === 'admin' ? '/admin' : '/profile/invites',
label: role === 'admin' ? 'Config' : 'Invites',
icon: '05',
match: (path: string) => path.startsWith('/admin') || path.startsWith('/profile/invites'),
},
]
return (
<div className="header-actions">
<a className="header-cta header-cta--left" href="/feedback">Send feedback</a>
<div className="header-actions-center">
<a href="/how-it-works">How it works</a>
</div>
<div className="header-actions-right">
<a href="/">Requests</a>
<a href="/profile/invites">Invites</a>
<a href="/portal/requests">Portal</a>
<a href="/portal/issues">Issues</a>
</div>
</div>
<nav className="header-actions" aria-label="Primary">
{items.map((item) => {
const active = item.match(pathname)
return (
<a key={item.href} href={item.href} className={active ? 'is-active' : undefined}>
<span aria-hidden="true">{item.icon}</span>
{item.label}
</a>
)
})}
</nav>
)
}