import { Chip } from '@mui/material'
import { AlertTriangle, Shield } from 'lucide-react'
import type { RiskLevel } from '../../domain/enums'
import { DS_COLORS } from '../../lib/ds'
import { RISK_LABELS } from '../../lib/constants'

interface RiskBadgeProps {
  level: RiskLevel
  size?: 'small' | 'medium'
}

export function RiskBadge({ level, size = 'small' }: RiskBadgeProps) {
  const { bg, fg } = DS_COLORS.risk[level]
  const Icon = level === 'LOW' || level === 'MEDIUM' ? Shield : AlertTriangle
  return (
    <Chip
      size={size}
      label={RISK_LABELS[level] ?? level}
      icon={<Icon size={11} color={fg} />}
      aria-label={`Risiko: ${RISK_LABELS[level] ?? level}`}
      sx={{
        bgcolor: bg,
        color: fg,
        border: 'none',
        fontWeight: 600,
        fontSize: '0.7rem',
        '& .MuiChip-icon': { ml: 0.5 },
      }}
    />
  )
}
