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.
27 lines
692 B
JavaScript
27 lines
692 B
JavaScript
import { route } from 'preact-router'
|
|
import { useEffect } from 'preact/hooks'
|
|
import { useCurrentUser } from '../hooks.jsx'
|
|
|
|
export const Admin = ({}) => {
|
|
const [user] = useCurrentUser(user => {
|
|
if (!user || user.role !== 'admin') {
|
|
route('/', true)
|
|
}
|
|
})
|
|
|
|
return (
|
|
<main class="admin">
|
|
<div class="logo">PHC / Problemi</div>
|
|
<div class="subtitle">
|
|
{user ? (
|
|
<>
|
|
Logged in as {user.role} @{user.username}
|
|
</>
|
|
) : (
|
|
<a href="/login">Login</a>
|
|
)}
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|