import { Box, Divider, Typography } from '@mui/material' import { Building2, FileText, MapPin } from 'lucide-react' import { useOfferWizardStore } from '../../stores/offerWizardStore' import { mockProperties } from '../../mock-data/properties' import type { ReportObjectFieldKey, ReportObjectFieldSelection } from '../../domain/inquiryReport' import type { Property } from '../../domain/property' interface MockPdfPreviewProps { fields: Record fallbackFields: Record fieldSelections: ReportObjectFieldSelection[] } const FIELD_LABELS: Partial> = { areaSqm: 'Fläche', rentPricePerSqm: 'Mietpreis', availabilityDate: 'Verfügbar ab', leaseTerm: 'Mietlaufzeit', breakoutOption: 'Breakout-Option', currentTenant: 'Aktueller Mieter', propertyNumber: 'Objektnummer', assetType: 'Asset Type', floor: 'Stockwerk', parking: 'Parkplätze', fitOut: 'Ausbaugrad', isBarrierFree: 'Barrierefrei', ceilingHeightM: 'Raumhöhe', floorLoad: 'Bodenlast', loadingDocksCount: 'Anlieferung', goodsLift: 'Warenaufzug', passengerLift: 'Personenaufzug', powerSupplyKva: 'Stromanschluss', hasServerRoom: 'Serverraum', internet: 'Internet', deliveryAccess: 'Zufahrt', publicTransportScore: 'ÖV-Anbindung', prestigeScore: 'Prestige', visibilityScore: 'Sichtbarkeit', footfallScore: 'Passantenfrequenz', commuterAccessScore: 'Pendlererreichbarkeit', talentAccessScore: 'Talent Access', esgScore: 'ESG', flexibilityScore: 'Flexibilität', expansionPotentialScore: 'Expansionspotenzial', taxEnvironmentScore: 'Steuerumfeld', microLocation: 'Mikrostandort', competitionEnvironment: 'Konkurrenzumfeld', infrastructure: 'Infrastruktur', description: 'Beschreibung', } function getFieldValue(property: Property, key: ReportObjectFieldKey): string | null { switch (key) { case 'areaSqm': return property.areaSqm ? `${property.areaSqm.toLocaleString('de-CH')} m²` : null case 'rentPricePerSqm': return property.rentPricePerSqm ? `CHF ${property.rentPricePerSqm}/m²/J` : null case 'availabilityDate': return property.availabilityDate ? new Date(property.availabilityDate).toLocaleDateString('de-CH') : null case 'leaseTerm': return property.leaseTerm ?? null case 'breakoutOption': return property.breakoutOption != null ? (property.breakoutOption ? 'Ja' : 'Nein') : null case 'currentTenant': return property.currentTenant ?? null case 'propertyNumber': return property.propertyNumber ?? null case 'assetType': return property.assetType ?? null case 'floor': return property.floorLevel != null ? String(property.floorLevel) : null case 'parking': return property.softFactors?.parkingSpots != null ? `${property.softFactors.parkingSpots} Pl.` : null case 'ceilingHeightM': return property.hardFacts?.ceilingHeightM != null ? `${property.hardFacts.ceilingHeightM} m` : null case 'loadingDocksCount': return property.hardFacts?.loadingDocksCount != null ? String(property.hardFacts.loadingDocksCount) : null case 'powerSupplyKva': return property.hardFacts?.powerSupplyKva != null ? `${property.hardFacts.powerSupplyKva} kVA` : null case 'hasServerRoom': return property.hardFacts?.hasServerRoom != null ? (property.hardFacts.hasServerRoom ? 'Ja' : 'Nein') : null case 'isBarrierFree': return property.hardFacts?.isBarrierFree != null ? (property.hardFacts.isBarrierFree ? 'Ja' : 'Nein') : null case 'fitOut': return property.hardFacts?.fitOut ?? null case 'publicTransportScore': return property.softFactors?.publicTransportMinutes != null ? `${property.softFactors.publicTransportMinutes} Min.` : null case 'prestigeScore': return property.softFactors?.prestige != null ? `${property.softFactors.prestige}/100` : null case 'visibilityScore': return property.softFactors?.visibilityScore != null ? `${property.softFactors.visibilityScore}/100` : null case 'description': return property.description ?? null default: return null } } export function MockPdfPreview({ fields, fallbackFields, fieldSelections }: MockPdfPreviewProps) { const needTitle = useOfferWizardStore(s => s.needTitle) const propertyIds = useOfferWizardStore(s => s.selectedPropertyIds) const properties = mockProperties.filter(p => propertyIds.includes(p.id)) const hasPropertyPage = fieldSelections.length > 0 && properties.length > 0 const v = (id: string) => fields[id] ?? fallbackFields[id] ?? '' return ( {/* ── Page 1 — Offer letter ── */} Angebotsvorschau (PDF) Wincasa AG · Zürich {new Date().toLocaleDateString('de-CH')} Angebot: {needTitle} {v('recipient_salutation')}, {v('offer_intro')} Hervorgehobene Kriterien {v('highlighted_criteria')} Vorgeschlagene Objekte {properties.map(p => ( {p.title} — {p.location.city}, {p.areaSqm.toLocaleString('de-CH')} m², CHF {p.rentPricePerSqm}/m²/Jahr ))} {properties.length === 0 && ( Keine Objekte ausgewählt. )} {v('next_steps')} {v('closing')} {/* ── Page 2 — Property details side by side ── */} {hasPropertyPage && ( <> Seite 2 — Objektdetails {properties.map(p => { const selection = fieldSelections.find(fs => fs.propertyId === p.id) const optionalFields = selection?.selectedOptionalFields ?? [] const image = p.images?.[0] return ( {/* Photo */} {image ? ( ) : ( )} {/* Info */} {p.title} {p.location.city}{p.location.district ? ` · ${p.location.district}` : ''} {/* Selected fields */} {optionalFields.length > 0 && ( {optionalFields.map(key => { const val = getFieldValue(p, key) if (!val) return null return ( {FIELD_LABELS[key] ?? key} {val} ) })} )} ) })} )} ) }