import { Box, Button, CircularProgress, Divider, Typography } from '@mui/material' import { ArrowRight, Building2, Calendar, MapPin, Ruler } from 'lucide-react' import { useNavigate } from 'react-router' import { usePropertyById } from '../../hooks/useProperties' import { useAdditionalMatchesForInquiry } from '../../hooks/useMatches' import type { AdditionalPropertyMatch } from '../../domain/additionalMatch' interface RelatedPropertyCardPanelProps { propertyId: string inquiryId: string compact?: boolean } export function RelatedPropertyCardPanel({ propertyId, inquiryId, compact }: RelatedPropertyCardPanelProps) { const { data: property, isLoading } = usePropertyById(propertyId) const navigate = useNavigate() const { data: additionalMatches = [], isLoading: loadingMatches, } = useAdditionalMatchesForInquiry(inquiryId, { minScore: 80, excludePropertyId: propertyId }) if (isLoading) { return ( ) } if (!property) { return ( Objekt nicht gefunden ) } const image = property.images?.[0] const detailRows = ( {property.location.city} {property.location.district ? `, ${property.location.district}` : ''} {property.areaSqm.toLocaleString('de-CH')} m² · CHF {property.rentPricePerSqm}/m²/Jahr Verfügbar ab {new Date(property.availabilityDate).toLocaleDateString('de-CH')} ) const matchesSection = ( <> Weitere passende Objekte {loadingMatches ? ( ) : additionalMatches.length === 0 ? ( Keine weiteren Matches ) : ( {additionalMatches.map(m => ( ))} )} ) if (compact) { return ( {property.title} {detailRows} {matchesSection} ) } return ( {!image && } {property.title} {detailRows} {property.description && ( {property.description} )} {matchesSection} ) } function AdditionalMatchCard({ match }: { match: AdditionalPropertyMatch }) { const navigate = useNavigate() return ( {match.title} {match.matchScore}% {match.location} · {match.areaSqm.toLocaleString('de-CH')} m² {match.reasons[0] && ( + {match.reasons[0]} )} ) }