import { Box, Button, Chip, Paper, Typography } from '@mui/material' import { Building2, Clock, ExternalLink, HardHat, Info, Layers, Tag, Train, TrendingUp } from 'lucide-react' import { useMatchDetail } from '../../hooks/useMatches' import { ResultType } from '../../domain/enums' import type { Property } from '../../domain/property' import { FLOOR_LABEL, ASSET_LABELS, RISK_LABELS, SOURCE_LABELS, PASSERBY_LABELS, KeyFactRow, UnitRow } from './MatchDetailPropertyDetails' import { FloorPlanSection } from './FloorPlanSection' import { DS_TEXT, DS_BG, DS_SURFACE, DS_BORDER, DS_MARKET_SIGNAL } from '../../lib/ds' type Match = NonNullable['data']> interface MatchDetailPropertySectionsProps { property: Property match: Match } export function MatchDetailPropertySections({ property, match }: MatchDetailPropertySectionsProps) { const units = property.units ?? [] const matchedUnit = units.find(u => u.id === match.unitId) const flexibleUnits = units.filter(u => u.isFlexible && u.minLettableSqm != null) const preMarketUnits = units.filter(u => u.schattenmarktRelease?.enabled) const otherUnits = units.filter(u => !u.schattenmarktRelease?.enabled) const totalMonthly = Math.round(property.areaSqm * property.rentPricePerSqm / 12) const rawMonthlyPerSqm = property.rentPricePerSqm / 12 const monthlyPerSqmLabel = Number.isInteger(rawMonthlyPerSqm) ? `CHF ${rawMonthlyPerSqm}.–` : `CHF ${rawMonthlyPerSqm.toLocaleString('de-CH', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` const minLettable = property.areaSqmMin ?? (flexibleUnits.length > 0 ? Math.min(...flexibleUnits.map(u => u.minLettableSqm!)) : undefined) const sourceLabel = property.sourceLabel ?? property.sourceMeta?.sourceLabel ?? SOURCE_LABELS[property.sourceType] ?? property.sourceType return ( <> {/* Preis */} Preis {property.ancillaryCosts != null && ( )} {/* Hauptangaben */} Hauptangaben {minLettable != null && } {property.contractDurationMonths != null && } {(property.floorLevel != null || matchedUnit) && ( )} {property.currentTenant && } {property.leaseEndDate && } {property.breakoutOption && } {property.riskLevel && } {property.expansionPotentialSqm != null && } {property.hardFacts?.fitOut && (() => { const LABELS: Record = { SHELL: 'Rohbau', BASIC: 'Basisausbau', FULL: 'Vollausbau', PREMIUM: 'Premiumausbau' } const base = LABELS[property.hardFacts!.fitOut!] ?? property.hardFacts!.fitOut! const mab = property.hardFacts!.mieterausbaubeitragPerSqm return })()} {/* Eigenschaften */} {property.softFactors && ( Eigenschaften {property.softFactors.publicTransportMinutes != null && ( } label={`ÖV: ${property.softFactors.publicTransportMinutes} Min. zu Fuss`} sx={{ bgcolor: DS_SURFACE.blue.bg, color: DS_MARKET_SIGNAL.accent, border: `1px solid ${DS_SURFACE.blue.border}`, fontWeight: 500 }} /> )} {property.softFactors.parkingSpots != null && property.softFactors.parkingSpots > 0 && ( )} {property.softFactors.prestige != null && property.softFactors.prestige >= 80 && ( )} {property.softFactors.visibilityScore != null && property.softFactors.visibilityScore >= 80 && ( )} {property.softFactors.passerbyFrequency && ( )} {property.softFactors.talentAccess != null && property.softFactors.talentAccess >= 80 && ( )} )} {/* Wegzeit */} {property.softFactors?.publicTransportMinutes != null && ( Wegzeit {property.softFactors.publicTransportMinutes} Min. zu Fuss Nächster ÖV-Anschluss — {property.location.city} Die Zeiten beziehen sich auf die Strecke zu Fuss. )} {/* Einheiten */} {units.length > 0 && ( Einheiten {['Einheit', 'Fläche', 'Miete', 'Verfügbar ab', 'Status'].map(h => ( {h} ))} {preMarketUnits.map(u => )} {otherUnits.map(u => )} )} {/* Grundriss */} {(() => { const plans: Array<{ url: string; label?: string }> = [] if (matchedUnit?.floorPlanUrl) { const lbl = matchedUnit.unitLabel ? `${FLOOR_LABEL(matchedUnit.floorLevel)} ${matchedUnit.unitLabel}` : FLOOR_LABEL(matchedUnit.floorLevel) plans.push({ url: matchedUnit.floorPlanUrl, label: units.length > 1 ? lbl : undefined }) } else { units.filter(u => u.floorPlanUrl).forEach(u => { const lbl = u.unitLabel ? `${FLOOR_LABEL(u.floorLevel)} ${u.unitLabel}` : FLOOR_LABEL(u.floorLevel) plans.push({ url: u.floorPlanUrl!, label: plans.length > 0 || units.filter(x => x.floorPlanUrl).length > 1 ? lbl : undefined }) }) } if (plans.length === 0 && property.floorPlanUrl) plans.push({ url: property.floorPlanUrl }) return })()} {/* Beschreibung */} {property.description && ( Beschreibung {property.description} )} {/* Quelle & Referenz */} Quelle & Referenz {property.propertyNumber && } {property.importedFrom && } {property.dataQuality.lastVerifiedAt && ( )} {property.sourceUrl && property.resultType === ResultType.MAISON_WORK && ( )} ) }