diff --git a/app/(dashboard)/DashboardLayoutClient.tsx b/app/(dashboard)/DashboardLayoutClient.tsx index db636b86..eced2db0 100644 --- a/app/(dashboard)/DashboardLayoutClient.tsx +++ b/app/(dashboard)/DashboardLayoutClient.tsx @@ -1,9 +1,10 @@ "use client"; -import { ReactNode, useState } from "react"; +import { ReactNode, useState, useEffect } from "react"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { + AppBar, Avatar, Box, Button, @@ -14,6 +15,7 @@ import { ListItemIcon, ListItemText, Stack, + Toolbar, Typography, useTheme, useMediaQuery, @@ -49,6 +51,7 @@ const NAV_ITEMS = [ ] as const; const DRAWER_WIDTH = 260; +const APP_BAR_HEIGHT = 48; export default function DashboardLayoutClient({ user, children }: { user: User; children: ReactNode }) { const [mobileOpen, setMobileOpen] = useState(false); @@ -61,6 +64,10 @@ export default function DashboardLayoutClient({ user, children }: { user: User; setMobileOpen(!mobileOpen); }; + useEffect(() => { + if (isMobile) setMobileOpen(false); + }, [pathname, isMobile]); + const drawerContent = ( @@ -82,7 +89,6 @@ export default function DashboardLayoutClient({ user, children }: { user: User; component={Link} href={item.href} selected={selected} - onClick={() => isMobile && setMobileOpen(false)} sx={{ mb: 0.5, borderRadius: 3, @@ -111,10 +117,7 @@ export default function DashboardLayoutClient({ user, children }: { user: User; { - if (isMobile) setMobileOpen(false); - router.push("/profile"); - }} + onClick={() => router.push("/profile")} sx={{ gap: 2, px: 1, @@ -168,15 +171,31 @@ export default function DashboardLayoutClient({ user, children }: { user: User; return ( {isMobile && ( - - - + + + + + + Caddy Proxy Manager + + + )} @@ -206,9 +227,9 @@ export default function DashboardLayoutClient({ user, children }: { user: User; component="main" sx={{ flexGrow: 1, - p: { xs: 3, md: 5 }, + p: { xs: 2, md: 5 }, width: { md: `calc(100% - ${DRAWER_WIDTH}px)` }, - mt: { xs: 6, md: 0 } + mt: { xs: `${APP_BAR_HEIGHT}px`, md: 0 } }} >