mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
rip out all old auth data
This commit is contained in:
committed by
Thomas Ruoff
parent
b257bc8258
commit
0e84945ab4
@@ -1,9 +1,10 @@
|
||||
import { useContext } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { useSession } from 'next-auth/react'
|
||||
|
||||
import User from './user'
|
||||
import UserContext from '../context/user'
|
||||
import { USER_ROLE } from '../lib/session'
|
||||
|
||||
|
||||
const pathNameLabelMap = {
|
||||
'/login': 'Login',
|
||||
@@ -20,8 +21,8 @@ function getPathNameMap(route: string) {
|
||||
}
|
||||
|
||||
export default function Navigation() {
|
||||
const { data, status } = useSession();
|
||||
const router = useRouter()
|
||||
const { role } = useContext(UserContext)
|
||||
|
||||
const pathname = router.pathname
|
||||
if (pathname.length === 0 || pathname === '/') {
|
||||
@@ -30,17 +31,13 @@ export default function Navigation() {
|
||||
|
||||
const pathLabel = getPathNameMap(pathname)
|
||||
|
||||
if (!pathLabel && role !== USER_ROLE.ADMIN) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-row items-center px-3 py-1 text-white text-base bg-blue-400 rounded-b-sm">
|
||||
<>
|
||||
<h2 className="mx-1">
|
||||
<span className="font-extrabold">{pathLabel}</span>
|
||||
</h2>
|
||||
{role === USER_ROLE.ADMIN && (
|
||||
{status === 'authenticated' && data.user.email && (
|
||||
<Link href="/admin">
|
||||
<a className="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">
|
||||
Buchungen
|
||||
|
||||
Reference in New Issue
Block a user