All files / src/app/layout/sidebar SidebarUserProfile.tsx

100% Statements 61/61
100% Branches 5/5
100% Functions 1/1
100% Lines 61/61

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 621x 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 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x  
/**
 * @file SidebarUserProfile.tsx
 * @module app/layout/sidebar/SidebarUserProfile
 *
 * @summary
 * User profile information display component for sidebar footer.
 * Shows logged-in user's full name and role with i18n labels.
 *
 * @enterprise
 * - Clean display of user identity information
 * - Support for undefined/null user data with fallbacks
 * - i18n labels for internationalization
 * - Consistent typography and spacing
 * - Full TypeDoc coverage for user information display
 */
 
import { Box, Typography } from '@mui/material';
import { useTranslation } from 'react-i18next';
 
interface SidebarUserProfileProps {
  /** Current user information */
  user?: {
    fullName?: string;
    role?: string;
  };
}
 
/**
 * User profile information display component.
 *
 * Renders logged-in user's full name and role with fallback values.
 * Uses i18n for label translations.
 *
 * @param props - Component props
 * @returns JSX element rendering user profile section
 *
 * @example
 * ```tsx
 * <SidebarUserProfile user={{ fullName: 'John Doe', role: 'Admin' }} />
 * ```
 */
export default function SidebarUserProfile({ user }: SidebarUserProfileProps) {
  const { t } = useTranslation(['common']);
 
  return (
    <Box>
      <Typography variant="caption" sx={{ fontWeight: 600, display: 'block', mb: 0.5 }}>
        {t('common:loggedInAs', 'Logged in as:')}
      </Typography>
      <Typography variant="caption" color="text.secondary" display="block">
        {user?.fullName || 'User'}
      </Typography>
      <Typography variant="caption" sx={{ fontWeight: 600, display: 'block', mt: 0.5, mb: 0.5 }}>
        {t('common:role', 'Role:')}
      </Typography>
      <Typography variant="caption" color="text.secondary" display="block">
        {user?.role || 'user'}
      </Typography>
    </Box>
  );
}