From b3a12e4292b6177480eab2de9eaa177531df5fde Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Mon, 6 Feb 2023 08:54:19 +0100 Subject: [PATCH] fix admin in header --- components/header.tsx | 16 ++++++------- components/navigation.tsx | 49 --------------------------------------- components/user.tsx | 9 ++++++- 3 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 components/navigation.tsx diff --git a/components/header.tsx b/components/header.tsx index cc39d55..99990fa 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -44,10 +44,10 @@ export default function Header() {
- Pfadi-Bussle + Pfadi-Bussle
-
) -} +} \ No newline at end of file diff --git a/components/navigation.tsx b/components/navigation.tsx deleted file mode 100644 index a87120a..0000000 --- a/components/navigation.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { useRouter } from 'next/router' -import Link from 'next/link' - -import { useSession } from 'next-auth/react' - -import User from './user' - -const pathNameLabelMap = { - '/login': 'Login', - '/admin': 'Buchungsübersicht', - '/admin/booking/[uuid]': 'Buchung Bearbeiten', - '/admin/booking/[uuid]/bill': 'Buchung Rechnungsstellung', - '/book': 'Buchungsanfrage', - '/booking/[uuid]': 'Ihre Buchung', - '/booking/[uuid]/stored': 'Buchungsanfrage angenommen', -} - -function getPathNameMap(route: string) { - return pathNameLabelMap[route] -} - -export default function Navigation() { - const { data, status } = useSession() - const router = useRouter() - - const pathname = router.pathname - if (pathname.length === 0 || pathname === '/') { - return null - } - - const pathLabel = getPathNameMap(pathname) - - return ( -
- <> -

- {pathLabel} -

- {status === 'authenticated' && data.user.email && ( - - Buchungen - - )} -
- - -
- ) -} diff --git a/components/user.tsx b/components/user.tsx index 5740a5a..16aa416 100644 --- a/components/user.tsx +++ b/components/user.tsx @@ -1,4 +1,5 @@ import { useSession, signOut } from 'next-auth/react' +import Link from 'next/link' export default function User() { const { data, status } = useSession() @@ -9,6 +10,12 @@ export default function User() { return ( <> + + Admin +
{data.user.email}
@@ -17,4 +24,4 @@ export default function User() { ) -} +} \ No newline at end of file