rip out all old auth data

This commit is contained in:
Thomas Ruoff
2021-10-02 01:03:02 +02:00
committed by Thomas Ruoff
parent b257bc8258
commit 0e84945ab4
8 changed files with 22 additions and 89 deletions

View File

@@ -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