feat: F014 compare view — side-by-side decision table with AI summary
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
import { useNavigate } from 'react-router'
|
||||
import { MatchCardCompact } from '../match-card/MatchCardCompact'
|
||||
import { buildMatchCardViewModel } from '../../features/matching/matchCardAdapter'
|
||||
import { useCompareStore } from '../../stores/compareStore'
|
||||
import type { UnifiedMatchResult } from '../../domain/unifiedResult'
|
||||
import type { MatchCardAction } from '../match-card/MatchCardViewModel'
|
||||
|
||||
interface Props {
|
||||
result: UnifiedMatchResult
|
||||
isInCompare: boolean
|
||||
onCompare: (propertyId: string) => void
|
||||
}
|
||||
|
||||
export function UnifiedResultCard({ result, isInCompare, onCompare }: Props) {
|
||||
export function UnifiedResultCard({ result }: Props) {
|
||||
const navigate = useNavigate()
|
||||
const isFuture = result.resultType === 'FUTURE_AVAILABILITY'
|
||||
const compareId = !isFuture
|
||||
? (result as { property: { id: string } }).property.id
|
||||
: ''
|
||||
const { addToCompare, removeFromCompare, isInCompare, isFull } = useCompareStore()
|
||||
const inCompare = isInCompare(result.matchId)
|
||||
|
||||
const actions: MatchCardAction[] = [
|
||||
{
|
||||
@@ -26,17 +23,17 @@ export function UnifiedResultCard({ result, isInCompare, onCompare }: Props) {
|
||||
disabled: true,
|
||||
onClick: () => {},
|
||||
},
|
||||
...(!isFuture
|
||||
? [
|
||||
{
|
||||
id: 'compare',
|
||||
label: 'Vergleichen',
|
||||
actionType: 'ADD_COMPARE' as const,
|
||||
variant: (isInCompare ? 'primary' : 'secondary') as 'primary' | 'secondary',
|
||||
onClick: () => onCompare(compareId),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: 'compare',
|
||||
label: inCompare ? 'Im Vergleich' : 'Vergleichen',
|
||||
actionType: 'ADD_COMPARE',
|
||||
variant: inCompare ? 'primary' : 'secondary',
|
||||
disabled: !inCompare && isFull(),
|
||||
onClick: () => {
|
||||
if (inCompare) removeFromCompare(result.matchId)
|
||||
else addToCompare(result)
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'details',
|
||||
label: 'Details',
|
||||
|
||||
@@ -3,27 +3,14 @@ import { UnifiedResultCard } from './UnifiedResultCard'
|
||||
|
||||
interface Props {
|
||||
results: UnifiedMatchResult[]
|
||||
isInCompare: (id: string) => boolean
|
||||
onCompare: (propertyId: string) => void
|
||||
}
|
||||
|
||||
export function UnifiedResultFeed({ results, isInCompare, onCompare }: Props) {
|
||||
export function UnifiedResultFeed({ results }: 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}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
{results.map(result => (
|
||||
<UnifiedResultCard key={result.matchId} result={result} />
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user