feat: F010 unified result feed

Replace monolithic Results.tsx with decomposed component architecture:
- 8 new components in src/components/results/ (ResultTypeBadge, ResultConfidenceSummary, FeedEmptyState, FeedSkeleton, ResultFeedHeader, ResultFilterBar, UnifiedResultCard, UnifiedResultFeed)
- Reuses existing useUnifiedResults hook and compareStore
- FUTURE_AVAILABILITY cards always display non-dismissable disclaimer
- Filter by result type + sort by score/area/rent

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Sutter
2026-05-16 13:18:58 +02:00
parent 3152de004c
commit 307b450807
10 changed files with 427 additions and 369 deletions
+14
View File
@@ -0,0 +1,14 @@
import { EmptyState } from '../ui'
export function FeedEmptyState({ filtered }: { filtered?: boolean }) {
return (
<EmptyState
title={filtered ? 'Kein Treffer für diesen Filter' : 'Keine Treffer gefunden'}
description={
filtered
? 'Wechseln Sie den Filter oder passen Sie die Suchkriterien an.'
: 'Starten Sie eine neue Suche oder erweitern Sie die Suchkriterien.'
}
/>
)
}
+22
View File
@@ -0,0 +1,22 @@
import { Card, Skeleton, Stack } from '@mui/material'
export function FeedSkeleton() {
return (
<>
{[1, 2, 3].map(i => (
<Card key={i} sx={{ p: 2.5, mb: 1.5 }}>
<Stack direction="row" sx={{ justifyContent: 'space-between', mb: 1.5 }}>
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'center' }}>
<Skeleton variant="rounded" width={110} height={22} />
<Skeleton variant="text" width={160} sx={{ fontSize: '1.25rem' }} />
</Stack>
<Skeleton variant="text" width={60} sx={{ fontSize: '2rem' }} />
</Stack>
<Skeleton variant="text" width="70%" />
<Skeleton variant="text" width="50%" />
<Skeleton variant="rounded" height={32} sx={{ mt: 1.5 }} />
</Card>
))}
</>
)
}
@@ -0,0 +1,33 @@
import { Box, LinearProgress, Stack, Typography } from '@mui/material'
interface Props {
confidenceLevel: number
dataQualityScore?: number
}
export function ResultConfidenceSummary({ confidenceLevel, dataQualityScore }: Props) {
const confColor = confidenceLevel >= 0.8 ? '#1a7a4a' : confidenceLevel >= 0.6 ? '#d97706' : '#c0392b'
return (
<Stack direction="row" spacing={2.5} sx={{ alignItems: 'center', flexWrap: 'wrap' }}>
<Typography variant="caption">
<span style={{ color: '#64748b' }}>Konfidenz </span>
<strong style={{ color: confColor }}>{Math.round(confidenceLevel * 100)}%</strong>
</Typography>
{dataQualityScore !== undefined && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Typography variant="caption" color="text.secondary">Datenqualität</Typography>
<Box sx={{ width: 80 }}>
<LinearProgress
variant="determinate"
value={dataQualityScore * 100}
sx={{ height: 6, borderRadius: 3 }}
/>
</Box>
<Typography variant="caption" color="text.secondary">
{Math.round(dataQualityScore * 100)}%
</Typography>
</Box>
)}
</Stack>
)
}
@@ -0,0 +1,21 @@
import { Box, Typography } from '@mui/material'
interface Props {
total: number
verifiedCount: number
externalCount: number
futureCount: number
}
export function ResultFeedHeader({ total, verifiedCount, externalCount, futureCount }: Props) {
return (
<Box sx={{ bgcolor: 'white', borderBottom: '1px solid #e2e8f0', px: 3, py: 2 }}>
<Typography variant="h5" sx={{ fontWeight: 700 }} color="text.primary">
{total} Treffer gefunden
</Typography>
<Typography variant="body2" color="text.secondary">
{verifiedCount} Verified · {externalCount} Extern · {futureCount} Signale
</Typography>
</Box>
)
}
@@ -0,0 +1,71 @@
import { Box, Card, Chip, Stack, Typography } from '@mui/material'
import type { ResultType } from '../../domain/enums'
type FilterSource = ResultType | 'ALL'
type SortBy = 'score' | 'rent' | 'area'
interface Props {
filterSource: FilterSource
onFilterChange: (v: FilterSource) => void
sortBy: SortBy
onSortChange: (v: SortBy) => void
}
const FILTER_OPTIONS: { value: FilterSource; label: string; color: string }[] = [
{ value: 'ALL', label: 'Alle', color: '#1e3a5f' },
{ value: 'VERIFIED_PORTFOLIO', label: 'Verified Portfolio', color: '#1e3a5f' },
{ value: 'EXTERNAL_MARKET', label: 'Marktinserate', color: '#d97706' },
{ value: 'FUTURE_AVAILABILITY', label: 'Zukunftssignale', color: '#7c3aed' },
]
const SORT_OPTIONS: { value: SortBy; label: string }[] = [
{ value: 'score', label: 'Relevanz' },
{ value: 'area', label: 'Fläche' },
{ value: 'rent', label: 'Mietpreis' },
]
export function ResultFilterBar({ filterSource, onFilterChange, sortBy, onSortChange }: Props) {
return (
<Card sx={{ p: 1.5, mb: 2 }}>
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', flexWrap: 'wrap', gap: 1 }}>
<Stack direction="row" spacing={0.5} sx={{ flexWrap: 'wrap', gap: 0.5 }}>
{FILTER_OPTIONS.map(({ value, label, color }) => {
const active = filterSource === value
return (
<Chip
key={value}
label={label}
size="small"
clickable
onClick={() => onFilterChange(value)}
sx={{
bgcolor: active ? color : 'transparent',
color: active ? 'white' : 'text.secondary',
border: `1px solid ${active ? color : '#e2e8f0'}`,
fontWeight: active ? 600 : 400,
}}
/>
)
})}
</Stack>
<Stack direction="row" spacing={0.5} sx={{ alignItems: 'center' }}>
<Typography variant="caption" color="text.secondary">Sortierung:</Typography>
{SORT_OPTIONS.map(({ value, label }) => (
<Chip
key={value}
label={label}
size="small"
clickable
onClick={() => onSortChange(value)}
sx={{
bgcolor: sortBy === value ? '#1e3a5f' : 'transparent',
color: sortBy === value ? 'white' : 'text.secondary',
border: `1px solid ${sortBy === value ? '#1e3a5f' : '#e2e8f0'}`,
}}
/>
))}
</Stack>
</Box>
</Card>
)
}
@@ -0,0 +1,19 @@
import type { ResultType } from '../../domain/enums'
import { Chip } from '@mui/material'
const TYPE_META: Record<string, { label: string; color: string }> = {
VERIFIED_PORTFOLIO: { label: 'Verified Portfolio', color: '#1e3a5f' },
EXTERNAL_MARKET: { label: 'Marktinserat', color: '#d97706' },
FUTURE_AVAILABILITY: { label: 'Zukunftssignal', color: '#7c3aed' },
}
export function ResultTypeBadge({ resultType }: { resultType: ResultType }) {
const meta = TYPE_META[resultType] ?? { label: resultType, color: '#64748b' }
return (
<Chip
label={meta.label}
size="small"
sx={{ bgcolor: meta.color, color: 'white', fontWeight: 600, fontSize: 11 }}
/>
)
}
@@ -0,0 +1,159 @@
import { Alert, Box, Button, Card, Chip, Divider, Stack, Typography } from '@mui/material'
import { Banknote, Bookmark, Calendar, Columns2, MapPin, Maximize2 } from 'lucide-react'
import type { UnifiedMatchResult } from '../../domain/unifiedResult'
import type { Property } from '../../domain/property'
import type { FutureSignal } from '../../domain/futureSignal'
import { ResultConfidenceSummary } from './ResultConfidenceSummary'
import { ResultTypeBadge } from './ResultTypeBadge'
function scoreColor(score: number): string {
if (score >= 78) return '#1a7a4a'
if (score >= 52) return '#d97706'
return '#c0392b'
}
interface Props {
result: UnifiedMatchResult
isInCompare: boolean
onCompare: (propertyId: string) => void
}
export function UnifiedResultCard({ result, isInCompare, onCompare }: Props) {
const { match, matchScore, resultType } = result
const isFuture = resultType === 'FUTURE_AVAILABILITY'
const property: Property | undefined = !isFuture ? (result as { property: Property }).property : undefined
const signal: FutureSignal | undefined = isFuture ? (result as { signal: FutureSignal }).signal : undefined
const compareId = property?.id ?? ''
const title = property?.title ?? signal?.companyName ?? signal?.locationHint ?? ''
const city = property?.location?.city ?? signal?.locationHint ?? ''
const areaSqm = property?.areaSqm ?? signal?.areaSqmEstimate
const rent = property?.rentPricePerSqm
const available = property?.availabilityDate
const dqScore = property?.dataQuality?.score
return (
<Card sx={{ p: 2.5, mb: 1.5 }}>
{/* FUTURE_AVAILABILITY disclaimer — always shown, non-dismissable */}
{isFuture && (
<Alert severity="warning" sx={{ mb: 1.5, py: 0.5 }}>
{signal?.disclaimer ?? 'Probabilistisches Signal kein bestätigtes Objekt'}
</Alert>
)}
{/* Header */}
<Box sx={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', mb: 1.5 }}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
<ResultTypeBadge resultType={resultType} />
<Typography variant="h6" sx={{ fontWeight: 600 }}>{title}</Typography>
</Box>
<Box sx={{ display: 'flex', alignItems: 'baseline', gap: 0.5 }}>
<Typography variant="h4" sx={{ fontWeight: 800, color: scoreColor(matchScore) }}>
{matchScore}
</Typography>
<Typography variant="body2" color="text.secondary">/100</Typography>
</Box>
</Box>
{/* Key facts */}
<Stack direction="row" spacing={2.5} sx={{ mb: 1.5, flexWrap: 'wrap' }}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<MapPin size={14} color="#64748b" />
<Typography variant="body2" color="text.secondary">{city}</Typography>
</Box>
{areaSqm !== undefined && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<Maximize2 size={14} color="#64748b" />
<Typography variant="body2" color="text.secondary">{areaSqm} m²</Typography>
</Box>
)}
{rent !== undefined && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<Banknote size={14} color="#64748b" />
<Typography variant="body2" color="text.secondary">CHF {rent}/m²</Typography>
</Box>
)}
{available && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<Calendar size={14} color="#64748b" />
<Typography variant="body2" color="text.secondary">{available}</Typography>
</Box>
)}
{isFuture && signal?.timeHorizonMonths && (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<Calendar size={14} color="#64748b" />
<Typography variant="body2" color="text.secondary">
~{signal.timeHorizonMonths} Monate · {Math.round(signal.probability * 100)}% Wahrscheinlichkeit
</Typography>
</Box>
)}
</Stack>
<Divider sx={{ mb: 1.5 }} />
{/* Positive factors */}
{match.positiveFactors.length > 0 && (
<Box sx={{ mb: 1 }}>
<Typography variant="caption" sx={{ fontWeight: 600, display: 'block', mb: 0.5 }} color="text.secondary">
Positive Faktoren
</Typography>
<Stack direction="row" spacing={0.5} sx={{ flexWrap: 'wrap', gap: 0.5 }}>
{match.positiveFactors.slice(0, 3).map((f, i) => (
<Chip
key={i}
label={f.criterion}
size="small"
sx={{ bgcolor: '#f0fdf4', color: '#1a7a4a', border: '1px solid #bbf7d0', fontSize: 11 }}
/>
))}
</Stack>
</Box>
)}
{/* Tradeoffs */}
{(match.tradeoffs?.length ?? 0) > 0 && (
<Alert severity="warning" sx={{ py: 0.5, px: 1.5, mb: 1, '& .MuiAlert-message': { fontSize: 12 } }}>
<Typography variant="caption" sx={{ fontWeight: 600, display: 'block', mb: 0.5 }}>Abwägungen</Typography>
{match.tradeoffs.slice(0, 2).map((t, i) => (
<Typography key={i} variant="caption" sx={{ display: 'block' }}>
{t.criterion}: {t.concern}
</Typography>
))}
</Alert>
)}
{/* Confidence + data quality */}
<Box sx={{ mb: 1.5 }}>
<ResultConfidenceSummary confidenceLevel={match.confidenceLevel} dataQualityScore={dqScore} />
</Box>
{/* Actions */}
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: 1 }}>
<Button variant="outlined" size="small" startIcon={<Bookmark size={14} />} disabled>
Shortlist
</Button>
{!isFuture && (
<Button
variant={isInCompare ? 'contained' : 'outlined'}
size="small"
startIcon={<Columns2 size={14} />}
onClick={() => onCompare(compareId)}
sx={isInCompare ? { bgcolor: '#1e3a5f' } : {}}
>
Vergleichen
</Button>
)}
<Button
variant="contained"
size="small"
disabled
sx={{ bgcolor: '#1e3a5f', '&:hover': { bgcolor: '#162d4a' } }}
>
Details
</Button>
</Box>
</Card>
)
}
@@ -0,0 +1,29 @@
import type { UnifiedMatchResult } from '../../domain/unifiedResult'
import { UnifiedResultCard } from './UnifiedResultCard'
interface Props {
results: UnifiedMatchResult[]
isInCompare: (id: string) => boolean
onCompare: (propertyId: string) => void
}
export function UnifiedResultFeed({ results, isInCompare, onCompare }: Props) {
return (
<>
{results.map(result => {
const compareId =
result.resultType !== 'FUTURE_AVAILABILITY'
? (result as { property: { id: string } }).property.id
: ''
return (
<UnifiedResultCard
key={result.matchId}
result={result}
isInCompare={compareId ? isInCompare(compareId) : false}
onCompare={onCompare}
/>
)
})}
</>
)
}
+8
View File
@@ -0,0 +1,8 @@
export { ResultTypeBadge } from './ResultTypeBadge'
export { ResultConfidenceSummary } from './ResultConfidenceSummary'
export { FeedEmptyState } from './FeedEmptyState'
export { FeedSkeleton } from './FeedSkeleton'
export { ResultFeedHeader } from './ResultFeedHeader'
export { ResultFilterBar } from './ResultFilterBar'
export { UnifiedResultCard } from './UnifiedResultCard'
export { UnifiedResultFeed } from './UnifiedResultFeed'