Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x | /**
* @file AppSidebar.tsx
* @module app/layout/AppSidebar
*
* @summary
* Left sidebar navigation drawer with profile info, settings, and logout.
* Thin orchestrator delegating to focused sub-components for navigation, profile, and actions.
*
* @enterprise
* - Responsive drawer (temporary on mobile, permanent on desktop)
* - Navigation items via SidebarNavList sub-component
* - User profile section via SidebarUserProfile sub-component
* - Environment metadata via SidebarEnvironment sub-component
* - Theme/language toggles via SidebarActions sub-component
* - Full TypeDoc coverage for drawer layout and component coordination
*/
import {
Box,
Drawer,
Toolbar,
Typography,
Divider,
} from '@mui/material';
import { useLocation } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { getHelpTopicForRoute } from './navConfig';
import type { SupportedLocale } from '../../theme';
import {
SidebarNavList,
SidebarUserProfile,
SidebarEnvironment,
SidebarActions,
} from './sidebar';
const drawerWidth = 248;
interface AppSidebarProps {
/** Whether drawer is open on mobile */
mobileOpen: boolean;
/** Callback to close drawer on mobile */
onMobileClose: () => void;
/** Current theme mode */
themeMode: 'light' | 'dark';
/** Callback when theme mode changes */
onThemeModeChange: (mode: 'light' | 'dark') => void;
/** Current locale */
locale: SupportedLocale;
/** Callback when locale changes */
onLocaleChange: (locale: SupportedLocale) => void;
/** Callback for logout */
onLogout: () => void;
/** Callback to open settings dialog */
onSettingsOpen: () => void;
/** Current user information */
user?: {
fullName?: string;
role?: string;
};
}
/**
* Application sidebar component.
*
* Renders responsive drawer with navigation items, user profile,
* and settings/theme controls in footer.
*
* @param props - Component props
* @returns JSX element rendering sidebar navigation
*/
/**
* Application sidebar component.
*
* Thin orchestrator that delegates rendering to focused sub-components.
* Renders responsive drawer with navigation, user profile, environment info,
* and action buttons in the footer.
*
* @param props - Component props
* @returns JSX element rendering sidebar navigation
*/
export default function AppSidebar({
mobileOpen,
onMobileClose,
themeMode,
onThemeModeChange,
locale,
onLocaleChange,
onLogout,
onSettingsOpen,
user,
}: AppSidebarProps) {
const { t } = useTranslation(['common']);
const location = useLocation();
// Get current help topic based on route
const helpTopic = getHelpTopicForRoute(location.pathname);
const drawerContent = (
<Box sx={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
{/* Drawer Header - App Title */}
<Toolbar>
<Typography variant="subtitle1" fontWeight={700}>
{t('app.branding', 'Smart Supply Pro')}
</Typography>
</Toolbar>
<Divider />
{/* Navigation Items */}
<SidebarNavList onLogout={onLogout} />
{/* Footer: User Info & Settings Section */}
<Box sx={{ mt: 'auto' }}>
<Divider />
<Box
sx={{
p: 1.25,
pb: 0.75,
mt: 0.5,
display: 'flex',
flexDirection: 'column',
gap: 0.75,
}}
>
{/* User Profile Info */}
<SidebarUserProfile user={user} />
{/* Environment & Version */}
<SidebarEnvironment />
{/* Settings Actions Row: Theme, Language, Settings, Help */}
<SidebarActions
themeMode={themeMode}
onThemeModeChange={onThemeModeChange}
locale={locale}
onLocaleChange={onLocaleChange}
onSettingsOpen={onSettingsOpen}
helpTopic={helpTopic}
/>
</Box>
</Box>
</Box>
);
return (
<Box
component="nav"
sx={{
width: { md: drawerWidth },
flexShrink: { md: 0 },
minHeight: 'calc(100vh - 64px)',
display: 'flex',
flexDirection: { md: 'column' },
}}
>
{/* Mobile Drawer (temporary, hidden on md+) */}
<Drawer
variant="temporary"
open={mobileOpen}
onClose={onMobileClose}
ModalProps={{ keepMounted: true }}
sx={{
display: { xs: 'block', md: 'none' },
'& .MuiDrawer-paper': { width: drawerWidth },
}}
>
{drawerContent}
</Drawer>
{/* Desktop Drawer (permanent, hidden on xs) */}
<Drawer
variant="permanent"
open
sx={{
display: { xs: 'none', md: 'block' },
flex: 1,
'& .MuiDrawer-paper': {
width: drawerWidth,
boxSizing: 'border-box',
height: '100%',
position: 'relative',
overflowY: 'auto',
pb: 1,
},
}}
>
{drawerContent}
</Drawer>
</Box>
);
}
|