-
+
{book.title}
@@ -45,14 +41,16 @@ export default function BookPage(properties: BookPageProperties) {
{book.authors.join(', ')}
-
+ {user.roles.includes('ROLE_ADMIN') ? (
+
+ ) : null}
diff --git a/src/components/header/header-authenticated-menu.tsx b/src/components/header/header-authenticated-menu.tsx
index d3d8745..ffbef1c 100644
--- a/src/components/header/header-authenticated-menu.tsx
+++ b/src/components/header/header-authenticated-menu.tsx
@@ -1,6 +1,6 @@
import {
- ArrowLeftOnRectangleIcon,
- BookOpenIcon,
+ AdjustmentsHorizontalIcon,
+ ArrowLeftEndOnRectangleIcon,
PlusIcon,
UserIcon,
} from '@heroicons/react/24/outline'
@@ -21,14 +21,25 @@ interface HeaderAuthenticatedMenuProperties {
user: UserResponse
}
+const OPTIONS = [
+ { key: 'profile', roles: ['ROLE_USER'], url: '/settings/profile' },
+ { key: 'add_book', roles: ['ROLE_ADMIN'], url: '/books/new' },
+ { key: 'admin', roles: ['ROLE_ADMIN'], url: '/admin/users' },
+ { key: 'signout', roles: ['ROLE_USER'], url: '/signout' },
+]
+
export default function HeaderAuthenticatedMenu(
properties: HeaderAuthenticatedMenuProperties,
) {
const router = useRouter()
const {
- user: { email, image, name },
+ user: { email, image, name, roles },
} = properties
+ const disabledKeys = OPTIONS.filter(
+ (option) => !option.roles.some((role) => roles.includes(role)),
+ ).map((option) => option.key)
+
return (
<>