All files / src/app/layout/header HeaderDemoBadge.tsx

100% Statements 65/65
100% Branches 3/3
100% Functions 1/1
100% Lines 65/65

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 661x 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 7x 7x 7x 7x 3x 3x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x  
/**
 * @file HeaderDemoBadge.tsx
 * @module app/layout/header/HeaderDemoBadge
 *
 * @summary
 * Demo mode badge component for header.
 * Displays prominent DEMO indicator when user is on demo account.
 *
 * @enterprise
 * - Clear visual indication of demo mode
 * - Only shown when isDemo is true
 * - Yellow/warning color for visibility
 * - Full TypeDoc coverage for demo mode display
 */
 
import { Chip } from '@mui/material';
import { useTranslation } from 'react-i18next';
 
interface HeaderDemoBadgeProps {
  /** Whether user is on demo account */
  isDemo: boolean;
}
 
/**
 * Demo mode badge component.
 *
 * Displays prominent DEMO badge when user is on demo account.
 * Only renders if isDemo is true.
 *
 * @param props - Component props
 * @returns JSX element rendering demo badge, or null if not in demo mode
 *
 * @example
 * ```tsx
 * <HeaderDemoBadge isDemo={true} />
 * // Shows: Yellow "DEMO" badge
 *
 * <HeaderDemoBadge isDemo={false} />
 * // Shows: null (nothing rendered)
 * ```
 */
export default function HeaderDemoBadge({ isDemo }: HeaderDemoBadgeProps) {
  const { t } = useTranslation(['auth']);
 
  if (!isDemo) {
    return null;
  }
 
  return (
    <Chip
      size="small"
      label={t('auth:demoBadge', 'DEMO')}
      color="warning"
      variant="outlined"
      sx={{
        ml: 1,
        fontWeight: 700,
        '& .MuiChip-label': {
          fontWeight: 700,
          color: '#000',
        },
      }}
    />
  );
}