import { Box, Button, Chip, Divider, Typography } from '@mui/material' import { Building2, CheckCircle2, } from 'lucide-react' import { useSessionStore } from '../../stores/sessionStore' import { useInquiryStore } from '../../stores/inquiryStore' import { LocationPreview } from '../shared/LocationPreview' import { HeatBadge } from '../shared/HeatBadge' import { getScoreTier, SCORE_THEME } from '../shared/scoreTheme' import { RESULT_TYPE_META } from '../../lib/ds' import type { MatchCardViewModel } from './MatchCardViewModel' import { FutureAvailabilityCard } from './FutureAvailabilityCard' // ── Main component ──────────────────────────────────────────────────────────── interface Props { vm: MatchCardViewModel imageUrl?: string lat?: number lng?: number cityLabel?: string overlayTypeLabel?: string overlayLocationLabel?: string } export function IntelligenceMatchCard({ vm, imageUrl, lat, lng, cityLabel, overlayTypeLabel, overlayLocationLabel }: Props) { const tier = getScoreTier(vm.matchScore) const theme = SCORE_THEME[tier] const { currentUser } = useSessionStore() const openInquiryDialog = useInquiryStore(s => s.openInquiryDialog) const isPortfolioOwner = currentUser?.role === 'PROPERTY_MANAGER' || currentUser?.role === 'ORGANIZATION_ADMIN' const rt = RESULT_TYPE_META[vm.resultType] ?? { label: vm.resultType, color: '#64748b' } const isFuture = vm.resultType === 'FUTURE_AVAILABILITY' // Future availability cards use the new design if (isFuture) { return } return ( {/* ── Hero zone ── */} {vm.matchScore}% {vm.resultType === 'VERIFIED_PORTFOLIO' && isPortfolioOwner && ( } label="Ihr Objekt" size="small" sx={{ bgcolor: 'rgba(30,58,95,0.85)', color: 'white', fontWeight: 700, fontSize: 9, height: 18, '& .MuiChip-icon': { ml: 0.5 } }} /> )} {/* ── Card body ── */} {/* Unit-first title (floor + street) */} {vm.title} {/* Building name as subtitle when a unit or floor range is in the title */} {vm.propertySubtitle && ( {vm.propertySubtitle} )} {[vm.locationLabel, vm.availabilityLabel].filter(Boolean).join(' · ')} {/* Unit area + rent when a specific unit is matched */} {vm.preMarketUnit && ( {vm.preMarketUnit.areaSqm.toLocaleString('de-CH')} m² {vm.preMarketUnit.rentPricePerSqm ? ` · CHF ${Math.round(vm.preMarketUnit.rentPricePerSqm / 12).toLocaleString('de-CH')}/m²/Mt.` : ''} )} {/* Regular explainability summary */} {vm.explainabilitySummary && ( <> {vm.explainabilitySummary} )} {vm.reasons.length > 0 && ( <> {vm.reasons.slice(0, 3).map((r, i) => ( {r.label} {r.explanation} ))} )} {/* Actions */} {vm.actions.map(a => ( ))} ) }