From 410bb014b44892a7ab87a14844c4907f1013bbec Mon Sep 17 00:00:00 2001 From: shounakpatil Date: Fri, 7 Jun 2024 17:47:51 +0530 Subject: [PATCH] feat(ui): Add a hamburger and admin panel --- .../AdminPanel/AdminSideBar/index.tsx | 7 +- frontend/src/components/Navbar/index.tsx | 85 ++++++++++++++----- frontend/src/store/authStore.tsx | 2 +- 3 files changed, 66 insertions(+), 28 deletions(-) diff --git a/frontend/src/components/AdminPanel/AdminSideBar/index.tsx b/frontend/src/components/AdminPanel/AdminSideBar/index.tsx index ce944de..866e13f 100644 --- a/frontend/src/components/AdminPanel/AdminSideBar/index.tsx +++ b/frontend/src/components/AdminPanel/AdminSideBar/index.tsx @@ -53,16 +53,13 @@ export default function SideBar() { }; return ( - + (null); const open = Boolean(anchorEl); + const [isDrawer, setIsDrawer] = React.useState(false); + const open1 = Boolean(isDrawer); + const matchesMediumScreen = useMediaQuery(theme.breakpoints.up('md')); + + useEffect(() => { + if (matchesMediumScreen) { + setIsDrawer(true); + } + }, [matchesMediumScreen]); + + const DrawerList = () => { + return ; + }; + const openmenu = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; @@ -121,31 +140,53 @@ export default function Navbar() { }; const profile_container = useRef(null); - return ( {location.pathname.startsWith('/admin') && user?.role === 'admin' ? ( - - - Manage Buses - - + { + setIsDrawer(!isDrawer); + }} > - {new Date().toLocaleDateString('en-UK', { - weekday: 'long', - day: 'numeric', - month: 'long', - year: 'numeric', - })} - - + + + {isDrawer && DrawerList()} + + + + + + Manage Buses + + + {new Date().toLocaleDateString('en-UK', { + weekday: 'long', + day: 'numeric', + month: 'long', + year: 'numeric', + })} + + + ) : ( (set => ({ user: null, isloading: true, setIsAuth: isAuth => set({isAuth}), - setUser: user => set({user}), + setUser: user => set({user: {...user, role: 'admin'}}), setIsLoading: isloading => set({isloading}), }));