From d85211a145d5302a36346c5a6d7d395495ca8a6d Mon Sep 17 00:00:00 2001 From: diced Date: Thu, 15 Dec 2022 18:41:17 -0800 Subject: [PATCH] feat: better nav bar stuff --- src/components/Layout.tsx | 125 ++++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 52 deletions(-) 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={