diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx
index 34254973..0c75525a 100644
--- a/src/components/Layout.tsx
+++ b/src/components/Layout.tsx
@@ -111,7 +111,15 @@ function MenuItem(props) {
);
}
-const items = [
+export type NavbarItems = {
+ icon: React.ReactNode;
+ text: string;
+ link?: string;
+ children?: NavbarItems[];
+ if?: (user: any, props: any) => boolean;
+};
+
+const items: NavbarItems[] = [
{
icon: ,
text: 'Home',
@@ -135,27 +143,37 @@ const items = [
{
icon: ,
text: 'Upload',
- link: '/dashboard/upload/file',
+ children: [
+ {
+ icon: ,
+ text: 'File',
+ link: '/dashboard/upload/file',
+ },
+ {
+ icon: ,
+ text: 'Text',
+ link: '/dashboard/upload/text',
+ },
+ ],
},
- {
- icon: ,
- text: 'Upload Text',
- link: '/dashboard/upload/text',
- },
-];
-
-const admin_items = [
{
icon: ,
- text: 'Users',
- link: '/dashboard/users',
- if: () => true,
- },
- {
- icon: ,
- text: 'Invites',
- link: '/dashboard/invites',
- if: (props) => props.invites,
+ text: 'Administration',
+ if: (user, _) => user.administrator as boolean,
+ children: [
+ {
+ icon: ,
+ text: 'Users',
+ link: '/dashboard/users',
+ if: () => true,
+ },
+ {
+ icon: ,
+ text: 'Invites',
+ link: '/dashboard/invites',
+ if: (_, props) => props.invites,
+ },
+ ],
},
];
@@ -269,39 +287,42 @@ export default function Layout({ children, props }) {
navbar={
- {items.map(({ icon, text, link }) => (
-
-
-
- ))}
- {user.administrator && (
- }
- childrenOffset={28}
- defaultOpened={admin_items.map((x) => x.link).includes(router.pathname)}
- >
- {admin_items
- .filter((x) => x.if(props))
- .map(({ icon, text, link }) => (
-
-
-
- ))}
-
- )}
+ {items
+ .filter((x) => (x.if ? x.if(user, props) : true))
+ .map(({ icon, text, link, children }) =>
+ children ? (
+ x.link).includes(router.pathname)}
+ >
+ {children
+ .filter((x) => (x.if ? x.if(user, props) : true))
+ .map(({ icon, text, link }) => (
+
+
+
+ ))}
+
+ ) : (
+
+
+
+ )
+ )}
{external_links.length