import { Box, Chip, Link, Paper, Typography } from '@mui/material' import type { Property } from '../../domain/property' const FRESHNESS_META: Record = { FRESH: { label: 'Aktuell (< 48h)', color: 'success' }, STALE: { label: 'Veraltet (2–14d)', color: 'warning' }, OUTDATED: { label: 'Outdated (> 14d)', color: 'error' }, } interface Props { property: Property | null } export function SourceProvenancePanel({ property }: Props) { if (!property) return null if (property.sourceType === 'DIRECT' || property.sourceMeta?.sourceType === 'DIRECT') return null const freshness = property.dataQuality?.freshness const freshnessMeta = freshness ? (FRESHNESS_META[freshness] ?? null) : null const sourceUrl = property.sourceUrl ?? property.sourceMeta?.sourceUrl const sourceLabel = property.sourceLabel ?? property.sourceMeta?.sourceLabel ?? property.sourceType ?? '–' const sourceUpdatedAt = property.sourceUpdatedAt ?? property.sourceMeta?.sourceUpdatedAt const lastVerified = property.dataQuality?.lastVerifiedAt const rows: { label: string; value: React.ReactNode }[] = [ { label: 'Quelltyp', value: property.sourceType ?? '–' }, { label: 'Quelle', value: sourceUrl ? ( {sourceLabel} ) : ( {sourceLabel} ), }, ...(sourceUpdatedAt ? [{ label: 'Letzte Aktualisierung', value: {sourceUpdatedAt} }] : []), ...(lastVerified ? [{ label: 'Letzte Verifikation', value: {lastVerified} }] : []), ...(freshnessMeta ? [{ label: 'Aktualität', value: , }] : []), ] const warnings = property.dataQuality?.warnings ?? [] return ( Quelle & Herkunft {rows.map((row, i) => ( {row.label} {row.value} ))} {warnings.length > 0 && ( {warnings.map((w, i) => ( ⚠ {w} ))} )} ) }