diff --git a/components/breadcrumbs.tsx b/components/breadcrumbs.tsx
deleted file mode 100644
index a74a9e8..0000000
--- a/components/breadcrumbs.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { useContext } from 'react'
-import { useRouter } from 'next/router'
-import Link from 'next/link'
-import UserContext from './user/context'
-
-export default function Breadcrumbs() {
- const { username, role } = useContext(UserContext)
- const router = useRouter()
-
- const path = router.asPath
- if (path.length === 0 || path === '/') {
- return null
- }
-
- const breadcrumbs = path.replace(/^\//, '').split('/')
-
- // TODO: translate routes
- // TODO: make entries linkable
- return (
-
- {role === 'admin' && (
-
- {username}
-
- )}
- <>
-
- {breadcrumbs.map((breadcrumb) => {
- return (
- <>
- {'>'}
-
- {breadcrumb}
-
- >
- )
- })}
- >
-
- )
-}
diff --git a/components/header.tsx b/components/header.tsx
index 01468bc..fd92da3 100644
--- a/components/header.tsx
+++ b/components/header.tsx
@@ -1,7 +1,7 @@
import Head from 'next/head'
import Link from 'next/link'
import Logo from './logo'
-import Breadcrumbs from './breadcrumbs'
+import Navigation from './navigation'
export default function Header() {
return (
@@ -20,7 +20,7 @@ export default function Header() {
-
+
>
)
diff --git a/components/navigation.tsx b/components/navigation.tsx
new file mode 100644
index 0000000..cb2eb32
--- /dev/null
+++ b/components/navigation.tsx
@@ -0,0 +1,62 @@
+import { useContext } from 'react'
+import { useRouter } from 'next/router'
+import Link from 'next/link'
+import User from './user'
+import UserContext from './user/context'
+import { USER_ROLE } from '../lib/session'
+
+const pathNameLabelMap = {
+ '/admin/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) {
+ const name = pathNameLabelMap[route]
+
+ return name || route
+}
+
+export default function Navigation() {
+ const router = useRouter()
+ const { role } = useContext(UserContext)
+
+ const pathname = router.pathname
+ if (pathname.length === 0 || pathname === '/') {
+ return null
+ }
+
+ const pathLabel = getPathNameMap(pathname)
+ const path = router.asPath
+
+ return (
+
+ <>
+
+ {'>'}
+
+ {role === USER_ROLE.ADMIN && (
+
+
+ Buchungen
+
+
+ )}
+
+
+ >
+
+ )
+}
diff --git a/components/user.tsx b/components/user.tsx
new file mode 100644
index 0000000..31c01fb
--- /dev/null
+++ b/components/user.tsx
@@ -0,0 +1,17 @@
+import { useContext } from 'react'
+
+import UserContext from './user/context'
+
+export default function User() {
+ const { username, role } = useContext(UserContext)
+
+ if (!username || !role) {
+ return null
+ }
+
+ return (
+
+ {username}
+
+ )
+}