/** * @ai-summary Main layout component with navigation (desktop/mobile adaptive) */ import React from 'react'; import { useAuth0 } from '@auth0/auth0-react'; import { Link, useLocation } from 'react-router-dom'; import { Container, Paper, Typography, Box, IconButton, Avatar } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import DirectionsCarRoundedIcon from '@mui/icons-material/DirectionsCarRounded'; import LocalGasStationRoundedIcon from '@mui/icons-material/LocalGasStationRounded'; import BuildRoundedIcon from '@mui/icons-material/BuildRounded'; import PlaceRoundedIcon from '@mui/icons-material/PlaceRounded'; import SettingsRoundedIcon from '@mui/icons-material/SettingsRounded'; import DescriptionRoundedIcon from '@mui/icons-material/DescriptionRounded'; import MenuIcon from '@mui/icons-material/Menu'; import CloseIcon from '@mui/icons-material/Close'; import { useAppStore } from '../core/store'; import { Button } from '../shared-minimal/components/Button'; import { NotificationBell } from '../features/notifications'; interface LayoutProps { children: React.ReactNode; mobileMode?: boolean; } export const Layout: React.FC = ({ children, mobileMode = false }) => { const { user, logout } = useAuth0(); const { sidebarOpen, toggleSidebar, setSidebarOpen } = useAppStore(); const location = useLocation(); const theme = useTheme(); // Ensure desktop has a visible navigation by default (only on mount) React.useEffect(() => { if (!mobileMode && !sidebarOpen) { setSidebarOpen(true); } }, [mobileMode, setSidebarOpen]); // Removed sidebarOpen from dependencies const navigation = [ { name: 'Vehicles', href: '/garage/vehicles', icon: }, { name: 'Fuel Logs', href: '/garage/fuel-logs', icon: }, { name: 'Maintenance', href: '/garage/maintenance', icon: }, { name: 'Gas Stations', href: '/garage/stations', icon: }, { name: 'Documents', href: '/garage/documents', icon: }, { name: 'Settings', href: '/garage/settings', icon: }, ]; // Mobile layout if (mobileMode) { return (
{/* App header */}
MotoVaultPro
v1.0
{/* Content area */}
{children}
); } // Desktop layout return ( {/* Sidebar */} MotoVaultPro {navigation.map((item) => { const isActive = location.pathname.startsWith(item.href); return ( {item.icon} {item.name} ); })} {user?.name?.charAt(0) || user?.email?.charAt(0)} {user?.name || user?.email} {/* Main content */} {/* Top bar */} Welcome back, {user?.name || user?.email} {/* Page content */} {children} {/* Backdrop */} {sidebarOpen && ( )} ); };