This commit is contained in:
john 2025-05-18 22:45:27 +02:00
parent 27098ec9fa
commit 4878897306
10 changed files with 268 additions and 32 deletions

View file

@ -1,9 +1,15 @@
import { PropsWithChildren } from 'react'
import { useUser } from '../app/user/userStore.ts'
import NavButton from './buttons/NavButton.tsx'
type NavBarProps = unknown
export default function NavBar({ children }: PropsWithChildren<NavBarProps>) {
const { user } = useUser()
return (
<nav className={`w-full flex flex-row justify-end gap-4 px-4 md:px-8 py-3`}>{children}</nav>
<nav className={`w-full flex flex-row justify-end gap-4 px-4 md:px-8 py-3`}>
{children}
{user?.isSuperUser && <NavButton to={'/admin/codes'}>admin</NavButton>}
</nav>
)
}

View file

@ -2,6 +2,7 @@ import { PropsWithChildren } from 'react'
import { Link } from 'react-router-dom'
interface NavLinkButtonProps {
to: string | To
className?: string
}
interface To {
@ -10,9 +11,13 @@ interface To {
hash?: string
}
export default function NavButton({ to, children }: PropsWithChildren<NavLinkButtonProps>) {
export default function NavButton({
to,
className: extraClasses = '',
children,
}: PropsWithChildren<NavLinkButtonProps>) {
return (
<Link className={`text-primary-500`} to={to}>
<Link className={`text-primary-500 hover:text-primary-600 ${extraClasses}`} to={to}>
{children}
</Link>
)