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 && !compact) {
return (
)
}
if (compact) {
return (
Weitere passende Objekte
{loadingMatches ? (
) : additionalMatches.length === 0 ? (
Keine weiteren Matches
) : (
{additionalMatches.map(m => (
))}
)}
)
}
if (!property) {
return (
Objekt nicht gefunden
)
}
const image = property.images?.[0]
return (
{image ? (
) : (
)}
{property.title}
{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')}
{property.description && (
{property.description}
)}
}
onClick={() => navigate('/supply/properties')}
sx={{ textTransform: 'none' }}
>
Objekt ansehen
Weitere passende Objekte
{loadingMatches ? (
) : additionalMatches.length === 0 ? (
Keine weiteren Matches
) : (
{additionalMatches.map(m => (
))}
)}
)
}
function MatchSliderCard({ match }: { match: AdditionalPropertyMatch }) {
const navigate = useNavigate()
return (
navigate('/supply/properties')}
sx={{
flexShrink: 0,
width: 168,
border: '1px solid #e8e7e4',
borderRadius: 1.5,
overflow: 'hidden',
cursor: 'pointer',
bgcolor: 'white',
transition: 'border-color 0.15s, box-shadow 0.15s',
'&:hover': {
borderColor: '#b0aead',
boxShadow: '0 2px 8px rgba(0,0,0,0.08)',
},
}}
>
{/* Image — 16:9 crop, compact supplementary card */}
{match.imageUrl ? (
) : (
)}
{/* Score badge overlay */}
{match.matchScore}%
{match.title}
{match.matchScore}%
{match.location}
{match.reasons[0] && (
+ {match.reasons[0]}
)}
)
}
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]}
)}
}
onClick={() => navigate('/supply/properties')}
sx={{ textTransform: 'none', fontSize: '0.7rem', p: 0, minWidth: 0, color: '#152642' }}
>
Ansehen
)
}