Files
property-match/src/components/supply/StrongMatchMiniCard.tsx
T
Benjamin Sutter 86bdf142b4 refactor: consolidate duplicated UI score/color/badge logic into lib/
- Add matchScoreHex(), criterionScoreColor(), criterionScoreTextColor() to lib/utils.ts
- Add RESULT_TYPE_META (labels + colors) to lib/ds.ts as single source of truth
- Remove 5 local scoreColor() functions: StrongMatchMiniCard, MatchListCard,
  pipelineUtils (re-exported as matchScoreHex), CriterionRow, ScoreBreakdownPanel,
  ScoreInlineBreakdown
- Remove local RESULT_TYPE_META/TYPE_META from MatchCardHeader, ResultTypeBadge;
  remove RESULT_TYPE_LABEL/COLOR from pipelineConstants — all now use lib/ds.ts
- Replace local confidenceColor() in MatchCardHeader, ConfidenceFieldBadge,
  ReliabilityScorePanel with confidenceHex() from lib/utils.ts
- Replace local qualityColor() in propertyHelpers, DataQualityWidget with
  dataQualityColor() from lib/utils.ts
- Fix FUTURE_AVAILABILITY label inconsistency ('Future'/'Zukunft' → 'Zukunftssignal')
- Fix EXTERNAL_MARKET label inconsistency ('Direktinserat' → 'Plattform')
- tsc --noEmit passes with zero errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-24 01:47:08 +02:00

72 lines
2.3 KiB
TypeScript

import { Box, Button, Card, CardContent, Chip, Typography } from '@mui/material'
import { useNavigate } from 'react-router'
import type { StrongMatchItem } from '../../domain/dashboard'
import { matchScoreHex } from '../../lib/utils'
interface StrongMatchMiniCardProps {
match: StrongMatchItem
}
export function StrongMatchMiniCard({ match }: StrongMatchMiniCardProps) {
const navigate = useNavigate()
return (
<Card variant="outlined" sx={{ mb: 1 }}>
<CardContent sx={{ p: 2, '&:last-child': { pb: 1.5 } }}>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', mb: 0.5 }}>
<Typography variant="body2" sx={{ fontWeight: 600, flex: 1 }}>
{match.propertyTitle}
</Typography>
<Chip
label={`${match.matchScore}`}
size="small"
sx={{
ml: 1,
fontWeight: 700,
bgcolor: matchScoreHex(match.matchScore),
color: 'white',
flexShrink: 0,
}}
/>
</Box>
<Typography variant="caption" sx={{ color: 'text.secondary', display: 'block' }}>
{match.propertyAddress}
</Typography>
<Typography variant="caption" sx={{ color: 'text.secondary', display: 'block', mt: 0.5 }}>
{match.topReason}
</Typography>
<Box sx={{ display: 'flex', gap: 0.75, mt: 1, flexWrap: 'wrap', alignItems: 'center' }}>
{match.missingDataCount > 0 && (
<Chip
label={`${match.missingDataCount} Felder fehlen`}
size="small"
color="warning"
/>
)}
</Box>
<Box sx={{ display: 'flex', gap: 0.75, mt: 1.25, flexWrap: 'wrap' }}>
<Button
size="small"
variant="contained"
sx={{ textTransform: 'none', fontSize: '0.75rem', py: 0.25 }}
onClick={() => navigate('/supply/match-center')}
>
Match Center
</Button>
<Button
size="small"
variant="outlined"
sx={{ textTransform: 'none', fontSize: '0.75rem', py: 0.25 }}
onClick={() => navigate('/ops/review-queue')}
>
Zur Prüfung
</Button>
</Box>
</CardContent>
</Card>
)
}