import { Chip } from '@mui/material' import { CheckCircle2, AlertTriangle, XCircle } from 'lucide-react' import type { DataQualityLevel } from '../../domain/enums' import { DS_COLORS, scoreToDataQualityLevel } from '../../lib/ds' import { DATA_QUALITY_LABELS } from '../../lib/constants' interface DataQualityBadgeProps { level?: DataQualityLevel score?: number showScore?: boolean size?: 'small' | 'medium' } const ICONS: Record = { HIGH: CheckCircle2, MEDIUM: AlertTriangle, LOW: XCircle, INCOMPLETE: XCircle, } export function DataQualityBadge({ level, score, showScore = false, size = 'small' }: DataQualityBadgeProps) { const resolved: DataQualityLevel = level ?? (score !== undefined ? scoreToDataQualityLevel(score) : 'LOW') const { bg, fg } = DS_COLORS.dataQuality[resolved] const Icon = ICONS[resolved] const scoreLabel = showScore && score !== undefined ? ` ${Math.round(score * 100)}%` : '' const label = `${DATA_QUALITY_LABELS[resolved] ?? resolved}${scoreLabel}` return ( } aria-label={`Datenqualität: ${label}`} sx={{ bgcolor: bg, color: fg, border: 'none', fontWeight: 600, fontSize: '0.7rem', '& .MuiChip-icon': { ml: 0.5 }, }} /> ) }