import { Chip } from '@mui/material'
import { ShieldCheck, AlertTriangle, ShieldAlert, ShieldOff, HelpCircle } from 'lucide-react'
import type { LucideIcon } from 'lucide-react'
import type { TermsStatus } from '../../domain/dataSource'
import { TERMS_STATUS_LABELS, TERMS_STATUS_COLORS } from '../../domain/dataSource'

const TERMS_ICONS: Record<TermsStatus, LucideIcon> = {
  APPROVED: ShieldCheck,
  NEEDS_LEGAL_REVIEW: AlertTriangle,
  RESTRICTED: ShieldAlert,
  BLOCKED: ShieldOff,
  UNKNOWN: HelpCircle,
}

interface TermsStatusBadgeProps {
  status: TermsStatus
}

export function TermsStatusBadge({ status }: TermsStatusBadgeProps) {
  const Icon = TERMS_ICONS[status]
  const { bg, fg, border } = TERMS_STATUS_COLORS[status]
  return (
    <Chip
      size="small"
      icon={<Icon size={11} color={fg} />}
      label={TERMS_STATUS_LABELS[status]}
      sx={{
        bgcolor: bg,
        color: fg,
        border: '1px solid',
        borderColor: border,
        fontSize: '0.7rem',
        fontWeight: 600,
        '& .MuiChip-icon': { ml: 0.75 },
      }}
    />
  )
}
