You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.8 KiB
TypeScript

import { Link } from 'preact-router/match'
import { isAdministrator } from '../../shared/model'
import { prependBaseUrl } from '../../shared/utils'
import { useLoggedInUser } from '../hooks/useCurrentUser'
export const Header = ({}) => {
const [user] = useLoggedInUser()
return (
<header>
<div class="logo">
<a href={prependBaseUrl('/')}>PHC / Problemi</a>
</div>
<nav>
<div class="nav-left">
<div class="nav-item">
<Link activeClassName="active" href={prependBaseUrl('/scores')}>
Classifica
</Link>
</div>
</div>
<div class="nav-right">
{user ? (
<>
{isAdministrator(user.role) && (
<div class="nav-item">
<Link activeClassName="active" href={prependBaseUrl('/admin')}>
Pannello Admin
</Link>
</div>
)}
<div class="nav-item">
<Link activeClassName="active" href={prependBaseUrl('/profile')}>
@{user.id}
</Link>
</div>
</>
) : (
<div class="nav-item">
<Link activeClassName="active" href={prependBaseUrl('/login')}>
Login
</Link>
</div>
)}
</div>
</nav>
</header>
)
}