@bytebrand/fe-ui-core-autobahn 1.0.208 → 1.0.210

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/cards/CarCard.tsx +1 -8
  2. package/cards/CarRow.tsx +1 -5
  3. package/cards/cardParts.tsx +1363 -1368
  4. package/cards/index.ts +0 -6
  5. package/cards/types.ts +182 -182
  6. package/chrome/Footer.tsx +3 -16
  7. package/chrome/TopBar.tsx +266 -139
  8. package/compat/CookieModal/CookieModal.tsx +6 -20
  9. package/compat/CookieModal/Modal.tsx +3 -6
  10. package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +15 -43
  11. package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +3 -4
  12. package/compat/CookieModal/useModal.ts +1 -5
  13. package/compat/Loader/Loader.tsx +7 -1
  14. package/compat/MdField/MdField.tsx +4 -28
  15. package/compat/TimePicker/TimePicker.tsx +2 -12
  16. package/data/toAutobahnCar.ts +586 -600
  17. package/iconsvg/IconSVG.tsx +5 -1
  18. package/locales/de/autobahn.json +857 -891
  19. package/locales/en/autobahn.json +857 -891
  20. package/package.json +2 -2
  21. package/theme/md3.css +11743 -15678
  22. package/ui/CreditCostNotice.tsx +44 -44
  23. package/ui/CreditKeyFigures.tsx +244 -244
  24. package/ui/Dropdown.tsx +10 -29
  25. package/ui/FormCheckbox.tsx +2 -22
  26. package/ui/FormField.tsx +1 -2
  27. package/ui/Icon.tsx +0 -6
  28. package/ui/Modal.tsx +6 -84
  29. package/ui/Skeleton.tsx +20 -79
  30. package/ui/index.ts +94 -96
  31. package/ui/usePortalMenuPosition.ts +15 -27
  32. package/utils/index.ts +0 -10
  33. package/vdp/FinanceCalculator.tsx +1134 -1148
  34. package/vdp/VdpModules.tsx +4437 -3869
  35. package/vdp/index.ts +3 -0
  36. package/vdp/types.ts +17 -7
  37. package/vehiclesProps/decoratedLightProps.tsx +0 -4
  38. package/vehiclesProps/decoratedProps.tsx +0 -4
  39. package/cards/CarCardSkeleton.tsx +0 -103
  40. package/cards/CarRowSkeleton.tsx +0 -152
  41. package/chrome/AccountMenuIcon.tsx +0 -109
  42. package/ui/MfieldCheckIcon.tsx +0 -13
  43. package/ui/scrollFieldIntoView.ts +0 -41
  44. package/utils/cookieConsent.ts +0 -84
  45. package/vehiclesProps/accidentDisclosure.ts +0 -25
@@ -1,1368 +1,1363 @@
1
- // Autobahn (auto.de redesign) — car-card helper parts.
2
- //
3
- // Typed React 18 + TS port of the helper components from the design kit
4
- // (docs/redesign/design-source/ui_kits/website/CarCard.jsx). Pure /
5
- // presentational: every value comes from the `AutobahnCar` prop, there is no
6
- // store / API / `window` access. The design kit's `window.CO2_CLASSES` /
7
- // `window.CO2_COLORS` globals are replaced by the shared autobahn constants.
8
- //
9
- // These render correctly only inside a `<div className="md3">` subtree (the
10
- // `.pricepaths`, `.pp-*`, `.specstrip`, `.imglabel` … classes are scoped there).
11
- //
12
- // NEEDS-DATA discipline (the point of the ticket): wherever the design showed a
13
- // figure we have no real source for, these helpers render the NEEDS_DATA_LABEL
14
- // ('Daten folgt') marker instead of inventing a number — see PricePaths'
15
- // market band and PpActivity. DropChip renders nothing when there is no drop.
16
-
17
- import React, { useState } from 'react';
18
- import { TranslationFunction } from '../types';
19
- import { defaultConfig } from '@bytebrand/fe-financing';
20
-
21
- import { Icon, Button, CreditCostNotice, CreditKeyFigures, hasCreditKeyFigures } from '../ui';
22
- import type { CreditKeyFiguresData } from '../ui';
23
- import { EvalBar } from '../vdp/FinanceCalculator';
24
- import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS } from '../constants';
25
- import { AutobahnCar } from './types';
26
- // pure, non-React — shared with the Meta AIA marketing-image renderer (a plain Node service).
27
- export { ratingTone } from '../data/toAutobahnCar';
28
-
29
- // Default financing/leasing terms shown under the rate (the SRP card has no per-car selector, so
30
- // these are the same default config the displayed rate is computed with — consistent, not invented).
31
- const _finCfg = (defaultConfig as any).financing || {};
32
- const _leasCfg = (defaultConfig as any).leasing || {};
33
- /** financing terms inputs (rendered via t in PricePaths), e.g. "0 € Anzahlung · 48 Monate Laufzeit". */
34
- const _finFirstInstallment = (_finCfg.firstInstallment || 0).toLocaleString('de-DE');
35
- const _finMonths = _finCfg.rawPaybackPeriod || _finCfg.paybackPeriod || 48;
36
- /** leasing terms fallbacks (used when the car doesn't carry its own), e.g. "10.000 km/Jahr · 48 Monate". */
37
- const _leasPeriod = _leasCfg.rawPaybackPeriod || _leasCfg.paybackPeriod;
38
- const _leasMileage = _leasCfg.annualMileage || _leasCfg.mileage;
39
- const _leasFirstInstallment = (_leasCfg.firstInstallment || 0).toLocaleString('de-DE');
40
-
41
- /**
42
- * ADV-405 follow-up (PM 19.11): the car's real financing key figures (Kerndaten) — the same
43
- * price.financing values the Finanzierungsdetails layer lists (toAutobahnCar). No default-config
44
- * fallback here: a missing figure is simply omitted by CreditKeyFigures, and with none real the
45
- * hosts keep their previous conditions line.
46
- */
47
- const finKeyFigures = (car: AutobahnCar): CreditKeyFiguresData => ({
48
- months: car.finMonths,
49
- netLoan: car.finNetLoan,
50
- total: car.finTotal,
51
- nominal: car.finNominal,
52
- apr: car.finApr,
53
- finalInstallment: car.finFinal,
54
- });
55
-
56
- /**
57
- * ADV-405 follow-up (leasing confirmed 19.11): the car's real leasing key figures — computed in
58
- * toAutobahnCar from price.leasing with the Leasingdetails layer's arithmetic (leasingKeyFigures).
59
- * Sonderzahlung/term are the lease rate's own terms; nothing falls back to the default config.
60
- */
61
- const leaseKeyFigures = (car: AutobahnCar): CreditKeyFiguresData => ({
62
- kind: 'leasing',
63
- down: car.leaseFirstInstallment,
64
- months: car.leaseMonths,
65
- cashPrice: car.leaseCashPrice,
66
- total: car.leaseTotal,
67
- residual: car.leaseResidual,
68
- nominal: car.leaseNominal,
69
- apr: car.leaseApr,
70
- });
71
-
72
- /** mileage → 'X.XXX km' (de-DE grouping). */
73
- export function fmtKm(n: number): string {
74
- return n.toLocaleString('de-DE') + ' km';
75
- }
76
-
77
- /**
78
- * Monthly rate → de-DE integer euro string (e.g. 402.12 → "402"). Rates are shown as whole
79
- * euros like the legacy card ("271 €"); a raw float printed directly rendered as "402.12 €",
80
- * which a German reader parses as 402.120 — fixed here with rounding + de-DE grouping.
81
- */
82
- export function fmtRate(n: number): string {
83
- return Math.round(n).toLocaleString('de-DE');
84
- }
85
-
86
- /** strip a trailing parenthetical, e.g. '110 kW (150 PS)' → '110 kW'. */
87
- function stripParen(s: string): string {
88
- return s.replace(/\s*\(.*\)/, '');
89
- }
90
-
91
- /**
92
- * Opposite of stripParen, for car.power specifically: pull the PS value OUT of the trailing
93
- * parenthetical instead of discarding it, e.g. '145 kW (197 PS)' → '197 PS' — the card wants
94
- * PS only, no kW at all. Regex requires the paren to actually contain "N PS" (not just any
95
- * parenthetical) and falls back to the plain stripParen(kW) result when it doesn't, so a power
96
- * string without a PS conversion still renders something instead of going blank.
97
- */
98
- function extractPS(s: string): string {
99
- const m = s.match(/\((\d+\s*PS)\)\s*$/i);
100
- return m ? m[1].replace(/\s+/, ' ') : stripParen(s);
101
- }
102
-
103
- // Compact spec for cards: short fuel/gear labels so all five values fit ONE line
104
- // without clipping.
105
- const FUEL_SHORT: Record<string, string> = {
106
- 'Plug-in-Hybrid': 'Hybrid',
107
- Benzin: 'Benzin',
108
- Diesel: 'Diesel',
109
- Elektro: 'Elektro',
110
- };
111
- const GEAR_SHORT: Record<string, string> = {
112
- Automatik: 'Automatik',
113
- Schaltgetriebe: 'Manuell',
114
- };
115
-
116
- /** five compact spec values for the grid card's one-line spec strip. */
117
- export function cardSpec(car: AutobahnCar): string[] {
118
- const fuel = stripParen(car.fuel);
119
- return [
120
- fmtKm(car.km),
121
- car.reg,
122
- extractPS(car.power),
123
- FUEL_SHORT[fuel] || fuel,
124
- GEAR_SHORT[car.gear] || car.gear,
125
- ];
126
- }
127
-
128
- export interface SpecLineProps {
129
- items: string[];
130
- size?: number;
131
- /** never wrap — clip overflow with ellipsis (single line). */
132
- oneLine?: boolean;
133
- }
134
-
135
- /** Compact pipe-separated spec line (AutoScout pattern). */
136
- export const SpecLine: React.FunctionComponent<SpecLineProps> = ({ items, size = 12.5, oneLine = false }) => (
137
- <div
138
- className="cc-spec"
139
- style={{
140
- display: 'flex',
141
- flexWrap: oneLine ? 'nowrap' : 'wrap',
142
- alignItems: 'center',
143
- gap: '2px 8px',
144
- fontSize: size,
145
- color: 'var(--md-on-surface-variant)',
146
- ...(oneLine ? { overflow: 'hidden', whiteSpace: 'nowrap' } : {}),
147
- }}
148
- >
149
- {items.map((v, i) => (
150
- <React.Fragment key={i}>
151
- {i > 0 && <span style={{ color: 'var(--md-outline-variant)', flex: 'none' }}>·</span>}
152
- <span style={oneLine ? { whiteSpace: 'nowrap' } : undefined}>{v}</span>
153
- </React.Fragment>
154
- ))}
155
- </div>
156
- );
157
-
158
- export interface PriceBlockProps {
159
- car: AutobahnCar;
160
- align?: 'left' | 'right';
161
- t: TranslationFunction;
162
- }
163
-
164
- /** Price block — rate-first (monthly is the lead), purchase price secondary. */
165
- export const PriceBlock: React.FunctionComponent<PriceBlockProps> = ({ car, align = 'left', t }) => {
166
- const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
167
- return (
168
- <div style={{ textAlign: align }}>
169
- <div
170
- style={{
171
- display: 'flex',
172
- alignItems: 'baseline',
173
- gap: 5,
174
- justifyContent: align === 'right' ? 'flex-end' : 'flex-start',
175
- }}
176
- >
177
- <span
178
- className="num"
179
- style={{
180
- fontWeight: 700,
181
- fontSize: 26,
182
- color: 'var(--md-primary)',
183
- letterSpacing: '-.6px',
184
- whiteSpace: 'nowrap',
185
- }}
186
- >
187
- {fmtRate(car.monthly)} €
188
- </span>
189
- <span className="md-label-sm">{t('autobahn:card.price.perMonth')}</span>
190
- </div>
191
- <div
192
- className="md-label-sm"
193
- style={{
194
- marginTop: 1,
195
- display: 'flex',
196
- flexWrap: 'wrap',
197
- gap: '0 6px',
198
- justifyContent: align === 'right' ? 'flex-end' : 'flex-start',
199
- }}
200
- >
201
- <span style={{ whiteSpace: 'nowrap' }}>
202
- {t('autobahn:card.price.purchasePrice')}{' '}
203
- <b style={{ color: 'var(--md-on-surface)' }}>{car.price.toLocaleString('de-DE')} €</b>
204
- </span>
205
- {showStrike && (
206
- <span
207
- style={{
208
- color: 'var(--md-on-surface-variant)',
209
- textDecoration: 'line-through',
210
- whiteSpace: 'nowrap',
211
- }}
212
- >
213
- {car.listPrice!.toLocaleString('de-DE')} €
214
- </span>
215
- )}
216
- </div>
217
- </div>
218
- );
219
- };
220
-
221
- export interface DropChipProps {
222
- /** real price reduction in EUR; when undefined the chip renders nothing. */
223
- amount?: number;
224
- t: TranslationFunction;
225
- }
226
-
227
- /**
228
- * Price-drop chip — a REAL reduction on this car. White pill so it doesn't
229
- * compete with the solid green rating chip. Renders nothing when there is no
230
- * drop (we never fabricate a reduction).
231
- */
232
- export const DropChip: React.FunctionComponent<DropChipProps> = ({ amount, t }) => {
233
- if (amount == null) {
234
- return null;
235
- }
236
- return (
237
- <span
238
- className="deal-chip deal-chip--drop"
239
- style={{
240
- display: 'inline-flex',
241
- alignItems: 'center',
242
- gap: 3,
243
- height: 22,
244
- padding: '0 8px',
245
- borderRadius: 'var(--md-r-full)',
246
- background: 'rgba(255,255,255,.94)',
247
- color: 'var(--md-good)',
248
- fontSize: 10.5,
249
- fontWeight: 700,
250
- lineHeight: '14px',
251
- boxShadow: 'var(--md-e1)',
252
- whiteSpace: 'nowrap',
253
- }}
254
- >
255
- <Icon name="trending-down" size={12} stroke={2.4} color="var(--md-good)" />
256
- {t('autobahn:card.price.priceDropAmount', { amount: amount.toLocaleString('de-DE') })}
257
- </span>
258
- );
259
- };
260
-
261
- /** shared deal-badge pill style (NEU/drop/percent/zero-down all share the same compact shape). */
262
- const dealPill: React.CSSProperties = {
263
- display: 'inline-flex',
264
- alignItems: 'center',
265
- height: 22,
266
- padding: '0 8px',
267
- borderRadius: 'var(--md-r-full)',
268
- fontSize: 10.5,
269
- fontWeight: 700,
270
- boxShadow: 'var(--md-e1)',
271
- whiteSpace: 'nowrap',
272
- };
273
-
274
- /** Percent price-drop chip (−X%). Red pill — pairs with DropChip. Renders nothing without a real pct. */
275
- export const PercentChip: React.FunctionComponent<{ pct?: number }> = ({ pct }) => {
276
- if (pct == null || pct <= 0) return null;
277
- return (
278
- <span className="deal-chip deal-chip--percent" style={{ ...dealPill, background: 'var(--md-error)', color: '#fff', lineHeight: '14px' }}>
279
- −{pct}%
280
- </span>
281
- );
282
- };
283
-
284
- /**
285
- * Zero-down-payment chip (offer.showDownPayment). Cyan pill. Spells out "0 € Anzahlung" where
286
- * there is room (grid cards / wide image) and uses the compact "0 € Anz." on the narrow list-card
287
- * image, so the badge row always stays on ONE line on both desktop and mobile.
288
- */
289
- export const ZeroDownChip: React.FunctionComponent<{
290
- show?: boolean;
291
- compact?: boolean;
292
- t: TranslationFunction;
293
- className?: string;
294
- /** overrides the default pill look (e.g. the desktop "mcard" full-text badge's own blue tint/size
295
- * from the Figma export) — merged last so it wins over the shared dealPill defaults below. */
296
- style?: React.CSSProperties;
297
- }> = ({ show, compact, t, className, style }) => {
298
- if (!show) return null;
299
- return (
300
- <span
301
- className={className}
302
- style={{ ...dealPill, background: 'var(--md-accent-container)', color: 'var(--md-on-accent-container)', ...style }}
303
- >
304
- {compact ? t('autobahn:card.price.zeroDownCompact') : t('autobahn:card.price.zeroDown')}
305
- </span>
306
- );
307
- };
308
-
309
- /**
310
- * "⚡ Angebot" gray badge — NOT a separate backend flag (none exists yet). Shown whenever the
311
- * card already carries a real deal signal (NEU / price drop / meaningful savings / 0€ Anzahlung
312
- * / percent drop) — i.e. it labels the same real discount the other badges point at, rather
313
- * than inventing a new "is this an offer" field. Revisit if/when a dedicated flag exists.
314
- */
315
- export const OfferBadge: React.FunctionComponent<{ show: boolean; t: TranslationFunction }> = ({ show, t }) => {
316
- if (!show) return null;
317
- return (
318
- <span className="offer-badge">
319
- <Icon name="zap" size={13} stroke={2.2} />
320
- {t('autobahn:card.badge.offer')}
321
- </span>
322
- );
323
- };
324
-
325
- interface InlineClsProps {
326
- /** CO₂ class letter, e.g. 'B'. */
327
- c: string;
328
- }
329
-
330
- /** Small inline colored CO₂-class letter (keeps EnVKV line a fixed height). */
331
- const InlineCls: React.FunctionComponent<InlineClsProps> = ({ c }) => {
332
- const i = Math.max(0, CO2_CLASSES.indexOf(c as (typeof CO2_CLASSES)[number]));
333
- const color = CO2_COLORS[i] || 'var(--md-outline)';
334
- return (
335
- <span
336
- style={{
337
- display: 'inline-flex',
338
- width: 14,
339
- height: 14,
340
- borderRadius: 3,
341
- background: color,
342
- color: '#fff',
343
- fontSize: 9.5,
344
- fontWeight: 800,
345
- alignItems: 'center',
346
- justifyContent: 'center',
347
- verticalAlign: '-2px',
348
- margin: '0 1px',
349
- }}
350
- >
351
- {c}
352
- </span>
353
- );
354
- };
355
-
356
- export interface EcoLineProps {
357
- car: AutobahnCar;
358
- style?: React.CSSProperties;
359
- t: TranslationFunction;
360
- }
361
-
362
- /**
363
- * Pkw-EnVKV legal line — full consumption + CO₂ + class. REQUIRED on every
364
- * German car ad and must stay visible. Quiet fine-print footnote with a fixed
365
- * min-height so all cards stay the same height. Handles the PHEV dual-figure
366
- * variant when a `phev` block is present.
367
- */
368
- export const EcoLine: React.FunctionComponent<EcoLineProps> = ({ car, style, t }) => {
369
- const wrap: React.CSSProperties = {
370
- borderTop: '1px solid var(--md-outline-variant)',
371
- paddingTop: 8,
372
- minHeight: 41,
373
- fontSize: 11,
374
- lineHeight: 1.5,
375
- color: 'var(--md-on-surface-variant)',
376
- ...style,
377
- };
378
- if (car.phev) {
379
- const p = car.phev;
380
- return (
381
- <div className="eco-line" style={wrap}>
382
- {p.consEl}{' '}
383
- {t('autobahn:card.eco.phevConsumptionLine', {
384
- consFuel: p.consFuel,
385
- consDis: p.consDis,
386
- co2w: p.co2w,
387
- co2classW: p.co2classW,
388
- co2classD: p.co2classD,
389
- })}
390
- </div>
391
- );
392
- }
393
- return (
394
- <div className="eco-line" style={wrap}>
395
- {t('autobahn:card.eco.consumptionLine', { cons: car.cons, co2: car.co2, co2class: car.co2class })}
396
- </div>
397
- );
398
- };
399
-
400
- export interface SeoLineProps {
401
- car: AutobahnCar;
402
- style?: React.CSSProperties;
403
- }
404
-
405
- /**
406
- * Full spec + equipment footer line (fuel, category, gearbox, colour, condition, drive
407
- * type, then every equipment highlight) — the small gray text under the card's CTA row,
408
- * same field/format as the legacy VehicleSmallCard's SeoText. Renders nothing without
409
- * `car.seoText` (needs-data: only fe-landing currently populates it).
410
- */
411
- export const SeoLine: React.FunctionComponent<SeoLineProps> = ({ car, style }) => {
412
- if (!car.seoText) return null;
413
- return (
414
- <div
415
- style={{
416
- fontSize: 10,
417
- lineHeight: '14px',
418
- color: 'var(--md-on-surface-variant)',
419
- maxHeight: 42,
420
- overflow: 'hidden',
421
- ...style,
422
- }}
423
- >
424
- {car.seoText}
425
- </div>
426
- );
427
- };
428
-
429
- export interface PricePathsProps {
430
- car: AutobahnCar;
431
- t: TranslationFunction;
432
- /** extra class appended to the root (e.g. the SRP card's desktop-only `hide-mobile` marker). */
433
- className?: string;
434
- /** takes over the financing/leasing terms rows' own "Details" links — e.g. navigate to this
435
- * car's VDP and open its finance modal already expanded, on the tab the link was under
436
- * (financing/leasing). Optional/page-owned like CarCard's onShowFinancingDetails; when
437
- * omitted the links render as plain (non-interactive) text, same as before this prop existed. */
438
- onShowDetails?: (mode: PaymentMode) => void;
439
- }
440
-
441
- /** Map the AutobahnCar rating tone → meter segment index (0 best … 4 worst). */
442
- const TONE_TO_TIER: Record<string, number> = { top: 0, good: 1, fair: 2, raised: 3, high: 4 };
443
-
444
- /**
445
- * Discrete Preisbewertung tier bar + thumb (Figma: 5 solid segments — green/light-green/yellow/
446
- * orange/red — with a white circular marker at the car's position, same `.fin-eval-bar`/
447
- * `.fin-eval-seg` segmented treatment the grid CarCard's PriceEvalCol/EvalBar already uses; no
448
- * text label here since the tier is already named by the StatChip pill next to the price).
449
- * Renders nothing when there is no rating/band (needs-data: we never draw a fake market position).
450
- */
451
- export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car }) => {
452
- const hasMarket =
453
- car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
454
- const bar = (tier: number) => {
455
- const leftPct = Math.max(4, Math.min(96, (tier / 4) * 100));
456
- const tierIndex = Math.max(0, Math.min(4, Math.round(tier)));
457
- return (
458
- <div className="fin-eval-bar">
459
- {TIER_COLORS.map((c, i) => (
460
- <span key={i} className="fin-eval-seg" style={{ background: c }} />
461
- ))}
462
- <div
463
- className={`fin-eval-thumb${TIER_KEYS[tierIndex] === 'good' ? ' fin-eval-thumb--good' : ''}`}
464
- style={{ left: `${leftPct}%`, borderColor: TIER_COLORS[tierIndex] }}
465
- />
466
- </div>
467
- );
468
- };
469
- if (hasMarket) {
470
- const mpos = Math.max(0, Math.min(1, (car.price - car.marketLow!) / (car.marketHigh! - car.marketLow!)));
471
- return bar(mpos * 4);
472
- }
473
- if (car.rating && TONE_TO_TIER[car.rating] != null) {
474
- // No market BAND yet, but the real Preisbewertung tier (same signal as the rating chip)
475
- // drives the thumb position. Real data, not faked.
476
- return bar(TONE_TO_TIER[car.rating]);
477
- }
478
- return null;
479
- };
480
-
481
- /**
482
- * Preisbewertung pill + segmented tier bar, grouped in one column exactly like the VDP
483
- * finance-calculator's mobile .fin-eval-col (FinanceCalculator.tsx/EvalBar) — the grid card's
484
- * replacement for the old StatChip pill + full-width gradient .pp-bar pairing. Renders nothing
485
- * without a rating (needs-data: never invent a tier).
486
- */
487
- export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car, t }) => {
488
- const tier = car.rating ? TONE_TO_TIER[car.rating] : undefined;
489
- if (tier == null) return null;
490
- const hasMarket =
491
- car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
492
- // same continuous market-position math as PriceMeter's knob, reused as EvalBar's leftPct override.
493
- const leftPct = hasMarket
494
- ? Math.max(4, Math.min(96, ((car.price - car.marketLow!) / (car.marketHigh! - car.marketLow!)) * 100))
495
- : undefined;
496
- const isGood = TIER_KEYS[tier] === 'good';
497
- // each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
498
- // collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
499
- const tierLabel = t('autobahn:tier.' + car.rating);
500
- // 'good' collapses onto the 'top' tier's own color too (#168a45), matching the fixed
501
- // "Top-Preis" text above rather than tier 1's lighter TIER_COLORS[1] green.
502
- const pillColor = isGood ? TIER_COLORS[0] : TIER_COLORS[tier];
503
- return (
504
- <div className="fin-eval-col">
505
- <div className="fin-eval-pill-cell">
506
- <span
507
- className={`fin-eval-pill${isGood ? ' fin-eval-pill--good' : ''}`}
508
- style={{ color: pillColor, background: `color-mix(in srgb, ${pillColor} 16%, transparent)` }}
509
- aria-label={t('autobahn:finance.priceRatingAria', { rating: tierLabel })}
510
- >
511
- {tierLabel}
512
- {isGood && <sup>4</sup>}
513
- </span>
514
- </div>
515
- <div className="fin-eval-bar-cell">
516
- <EvalBar tier={tier} leftPct={leftPct} />
517
- </div>
518
- </div>
519
- );
520
- };
521
-
522
- export type PaymentMode = 'financing' | 'leasing' | 'buy';
523
-
524
- /** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
525
- * without a lease rate — PriceTabs has no Leasing tab for it. */
526
- export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
527
- requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
528
-
529
- export interface PriceTabsProps {
530
- car: AutobahnCar;
531
- mode: PaymentMode;
532
- onModeChange: (mode: PaymentMode) => void;
533
- t: TranslationFunction;
534
- /** extra class appended to the root (e.g. the SRP card's mobile-only `show-mobile` marker). */
535
- className?: string;
536
- }
537
-
538
- /**
539
- * Finanzierung / Leasing / Kaufen tab row — reuses the exact `.fin-tabs`/`.fin-tab` classes
540
- * the VDP's FinanceCalculator already renders (md3.css), so the card's tabs are visually
541
- * identical to the VDP's, not a second tab style. Leasing tab omitted when the car isn't
542
- * leasing-eligible (car.lease undefined) — same rule PricePaths already used.
543
- */
544
- export const PriceTabs: React.FunctionComponent<PriceTabsProps> = ({ car, mode, onModeChange, t, className }) => {
545
- const tabs: Array<[PaymentMode, string]> = [
546
- ['financing', t('autobahn:finance.mode.financing')],
547
- ...(car.lease != null ? ([['leasing', t('autobahn:finance.mode.leasing')]] as Array<[PaymentMode, string]>) : []),
548
- ['buy', t('autobahn:card.price.buy')],
549
- ];
550
- return (
551
- <div className={'fin-tabs' + (className ? ' ' + className : '')} role="tablist" onClick={(e) => e.stopPropagation()}>
552
- {tabs.map(([m, label]) => (
553
- <button
554
- key={m}
555
- type="button"
556
- role="tab"
557
- aria-selected={mode === m}
558
- className={'fin-tab' + (mode === m ? ' on' : '')}
559
- onClick={() => onModeChange(m)}
560
- >
561
- {label}
562
- </button>
563
- ))}
564
- </div>
565
- );
566
- };
567
-
568
- export interface PriceHeroProps {
569
- car: AutobahnCar;
570
- mode: PaymentMode;
571
- t: TranslationFunction;
572
- /** opt-in: render the "/mtl." unit next to the rate even without a struck old price to caption
573
- * (default false keeps every existing caller's behavior — the unit only ever showed alongside
574
- * the UVP-Rate/old-price group). The SRP desktop card wants the unit on every financing/leasing
575
- * rate, discounted or not. */
576
- alwaysShowUnit?: boolean;
577
- }
578
-
579
- /** footnote badge + click-to-open popover, shared by the Finanzierung/Leasing "UVP-Rate" (³) and
580
- * Kaufen "Hersteller-UVP" (²) captions on the hero price — same circle/popover, different digit
581
- * and body copy. */
582
- const UvpBadge: React.FunctionComponent<{
583
- n: number;
584
- open: boolean;
585
- onToggle: () => void;
586
- onClose: () => void;
587
- body: string;
588
- closeLabel: string;
589
- }> = ({ n, open, onToggle, onClose, body, closeLabel }) => (
590
- <>
591
- <span
592
- className="pp-eyebrow-badge"
593
- role="button"
594
- tabIndex={0}
595
- onClick={(e) => {
596
- e.stopPropagation();
597
- onToggle();
598
- }}
599
- >
600
- {n}
601
- </span>
602
- {open && (
603
- <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
604
- <button
605
- type="button"
606
- className="pp-uvp-tooltip-close"
607
- aria-label={closeLabel}
608
- onClick={(e) => {
609
- e.stopPropagation();
610
- onClose();
611
- }}
612
- >
613
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
614
- <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
615
- </svg>
616
- </button>
617
- <div className="pp-uvp-tooltip-body">{body}</div>
618
- </div>
619
- )}
620
- </>
621
- );
622
-
623
- /**
624
- * Hero price for the active tab — Finanzierung/Leasing show a monthly rate ("z.B. … €/mtl.")
625
- * with its own real struck-through old rate (getFinancing/getLeasing `oldMonthlyInstallment`,
626
- * same isStrikeShown gate as everywhere else); Kaufen shows the flat purchase price struck
627
- * against the real list price (car.listPrice, already used elsewhere on the card). The
628
- * superscript footnote markers (¹ price, ² struck reference, ³ "/mtl.") match the Figma card —
629
- * their legal text lives in the page's own footnote block, not duplicated per-card.
630
- */
631
- export const PriceHero: React.FunctionComponent<PriceHeroProps> = ({ car, mode, t, alwaysShowUnit }) => {
632
- const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
633
- const isMoney = mode === 'buy';
634
- const value = mode === 'financing' ? car.monthly : mode === 'leasing' ? (car.lease as number) : car.price;
635
- const oldValue = mode === 'financing' ? car.oldMonthly : mode === 'leasing' ? car.oldLease : car.listPrice;
636
- const showOld = oldValue != null && oldValue > value;
637
- // shrink the 65px hero rate for long values (e.g. 1.234 €) so it doesn't overflow the card —
638
- // same digit-length technique as FinanceCalculator's own fin-rate-hero--len4/--len5/--len6.
639
- const rateDigits = !isMoney ? String(Math.round(value)).length : 0;
640
- const rateLenClass =
641
- rateDigits >= 6 ? ' pp-hero-val--len6' : rateDigits === 5 ? ' pp-hero-val--len5' : rateDigits === 4 ? ' pp-hero-val--len4' : '';
642
- // Kaufen: 6/7-digit purchase prices (e.g. 113.249 € / 1.553.249 €) shrink on desktop only —
643
- // separate from the financing/leasing --len6 above since the desktop Kaufen sizes don't match
644
- // the shared rate-based scale.
645
- const buyDigits = isMoney ? String(Math.round(value)).length : 0;
646
- const buyLen6Class = buyDigits >= 7 ? ' pp-hero-val--buy-len7' : buyDigits === 6 ? ' pp-hero-val--buy-len6' : '';
647
- const oldDigits = showOld ? String(Math.round(oldValue as number)).length : 0;
648
- const oldLenClass = oldDigits === 5 ? ' pp-hero-old--len5' : oldDigits === 4 ? ' pp-hero-old--len4' : '';
649
- // ADV-423: the "UVP" label shrinks together with the struck price it captions
650
- const uvpLenClass = oldDigits === 5 ? ' pp-uvp-label--len5' : oldDigits === 4 ? ' pp-uvp-label--len4' : '';
651
- return (
652
- <div className={'pp-hero' + (isMoney ? ' pp-hero--buy' : '')}>
653
- <div className="pp-hero-rate">
654
- <b className={'num pp-hero-val' + rateLenClass + buyLen6Class}>
655
- {isMoney ? value.toLocaleString('de-DE') : fmtRate(value)} €{isMoney && <sup>1</sup>}
656
- </b>
657
- {/* z.B./old-rate/unit grouped in one stacked column beside the hero figure — mirrors
658
- the VDP finance-calculator's .fin-rate-unit layout (FinanceCalculator.tsx) exactly.
659
- Only shown when there's a real old price to strike through — without a discount the
660
- eyebrow/unit have nothing to caption, so the whole group stays hidden. */}
661
- {!isMoney && showOld && (
662
- <span className="pp-hero-unit-group">
663
- {/* a real (not display:contents) flex-column box, matching .pp-hero-unit-group's own
664
- column layout exactly — so the click target covers the full area INCLUDING the
665
- gap between the two stacked lines, not just their text glyphs (display:contents
666
- has no box of its own there, so clicks in that gap fell through to the card link
667
- behind it instead of opening the tooltip). stopPropagation is required here too —
668
- the whole card (CarCard.tsx) has its own onClick={() => onOpen(car)} navigation,
669
- so without it a click on this block both opened the tooltip AND navigated away. */}
670
- <span
671
- style={{ display: 'flex', flexDirection: 'column' }}
672
- role="button"
673
- tabIndex={0}
674
- onClick={(e) => {
675
- e.stopPropagation();
676
- setUvpTooltipOpen((v) => !v);
677
- }}
678
- >
679
- <span className="pp-eyebrow">
680
- {t('autobahn:card.price.uvpRateLabel')}
681
- <UvpBadge
682
- n={3}
683
- open={uvpTooltipOpen}
684
- onToggle={() => setUvpTooltipOpen((v) => !v)}
685
- onClose={() => setUvpTooltipOpen(false)}
686
- closeLabel={t('autobahn:modal.close')}
687
- body={t(
688
- mode === 'leasing'
689
- ? 'autobahn:card.price.uvpRateTooltipBodyLeasing'
690
- : 'autobahn:card.price.uvpRateTooltipBody',
691
- )}
692
- />
693
- </span>
694
- <span className={'pp-hero-old' + oldLenClass}>{Math.round(oldValue as number).toLocaleString('de-DE')} €</span>
695
- </span>
696
- <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>
697
- </span>
698
- )}
699
- {/* opt-in (alwaysShowUnit): no discount to caption, so just the plain unit next to the
700
- rate instead of the full UVP-Rate/old-price group — existing callers that don't pass
701
- this prop keep showing nothing here, exactly as before. */}
702
- {!isMoney && !showOld && alwaysShowUnit && <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>}
703
- {/* Kaufen: no rate/unit to caption, just the real list price struck through — same
704
- car.listPrice already used by DropChip/PpRow. */}
705
- {isMoney && showOld && (
706
- <span className="pp-hero-unit-group">
707
- {/* ADV-423: "UVP" label right before the struck list price, same size as that price
708
- (md3.css); same tooltip toggle as the price itself. */}
709
- <span
710
- className={'pp-uvp-label' + uvpLenClass}
711
- onClick={(e) => {
712
- e.stopPropagation();
713
- setUvpTooltipOpen((v) => !v);
714
- }}
715
- >
716
- {t('autobahn:finance.uvp')}
717
- </span>
718
- <span
719
- className={'pp-hero-old' + oldLenClass}
720
- role="button"
721
- tabIndex={0}
722
- onClick={(e) => {
723
- e.stopPropagation();
724
- setUvpTooltipOpen((v) => !v);
725
- }}
726
- >
727
- {Math.round(oldValue as number).toLocaleString('de-DE')} €
728
- <UvpBadge
729
- n={2}
730
- open={uvpTooltipOpen}
731
- onToggle={() => setUvpTooltipOpen((v) => !v)}
732
- onClose={() => setUvpTooltipOpen(false)}
733
- closeLabel={t('autobahn:modal.close')}
734
- body={t('autobahn:card.price.uvpListTooltipBody')}
735
- />
736
- </span>
737
- </span>
738
- )}
739
- </div>
740
- </div>
741
- );
742
- };
743
-
744
- /**
745
- * Financing/leasing terms line ("0 € Anzahlung · 48 Monate Laufzeit" / "0 € Sonderzahlung ·
746
- * 48 Mon. · 10.000 km/Jahr") + a "Finanzierungsdetails"/"Details" link, full-width under the
747
- * price/rating row — same real per-car (falling back to the default config) figures as
748
- * PricePaths' own terms line, just also wired to the page's rate-adjust sheet. Renders nothing
749
- * for the Kaufen tab (a cash purchase has no financing terms) or when neither a terms line nor
750
- * a details link end up with anything real to show.
751
- */
752
- export const PriceTerms: React.FunctionComponent<{
753
- car: AutobahnCar;
754
- mode: PaymentMode;
755
- onOpenRateAdjust?: (mode: PaymentMode) => void;
756
- /** takes over the "Finanzierungsdetails"/"Details" link's click (e.g. navigate to the VDP and
757
- * open the finance modal already expanded, scrolled to the breakdown) — when given, it wins
758
- * over onOpenRateAdjust for THIS link only; the mobile CTA row's own "Rate anpassen" button
759
- * keeps using onOpenRateAdjust regardless. */
760
- onShowDetails?: () => void;
761
- t: TranslationFunction;
762
- }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
763
- // Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
764
- // here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
765
- // real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
766
- // every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
767
- // FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
768
- if (mode === 'buy') return <div className="cc-terms" />;
769
- const finFirstInstallment =
770
- car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
771
- const finMonths = car.finMonths ?? _finMonths;
772
- const leasFirstInstallment =
773
- car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
774
- const leasMileage = car.leaseMileage ?? _leasMileage;
775
- const leasMonths = car.leaseMonths ?? _leasPeriod;
776
- const hasLeasTerms = Boolean(leasMileage && leasMonths);
777
- const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
778
- const termsText =
779
- mode === 'leasing'
780
- ? hasLeasTerms
781
- ? t('autobahn:card.price.leaseTerms', { firstInstallment: leasFirstInstallment, months: leasMonths, mileage: leasMileageStr })
782
- : ''
783
- : t('autobahn:card.price.financeTerms', { firstInstallment: finFirstInstallment, months: finMonths, count: finMonths });
784
- if (!termsText && !onOpenRateAdjust && !onShowDetails) return null;
785
- const detailsLabel = mode === 'leasing' ? t('autobahn:card.price.detailsLink') : t('autobahn:modal.financingDetails');
786
- const detailsButton =
787
- onOpenRateAdjust || onShowDetails ? (
788
- <button
789
- type="button"
790
- className="cc-terms-link"
791
- onClick={(e) => {
792
- e.stopPropagation();
793
- if (onShowDetails) onShowDetails();
794
- else onOpenRateAdjust!(mode);
795
- }}
796
- >
797
- {detailsLabel}
798
- </button>
799
- ) : null;
800
- // ADV-405 follow-up (PM 19.11): on the Finanzierung tab the conditions line under the rate shows
801
- // the financing key figures instead ("60 Mon. · … Nettokredit · Gesamtbetrag: …" / "… Sollzins
802
- // fest · … eff. Jahreszins · Finanzierungsdetails"), inside the same .cc-terms so its 12px
803
- // #0e2238 typography applies; the block grows to 2+ lines (the stack cell takes the tallest
804
- // slot). Leasing keeps its line; with no real figure the old financing terms line stays.
805
- // Leasing (19.11): the leasing key figures the same way ("0 € Anzahlung · 60 Mon. · … € Barpreis ·
806
- // … € Gesamtbetrag" / "Kaufpflicht · … Sollzins fest · … eff. Jahreszins · Details").
807
- const kf = mode === 'leasing' ? leaseKeyFigures(car) : finKeyFigures(car);
808
- if (car.lease != null && hasCreditKeyFigures(kf) && mode === 'leasing') {
809
- return (
810
- <div className="cc-terms">
811
- <CreditKeyFigures t={t} figures={kf} details={detailsButton || undefined} cls="cc-ckf" />
812
- </div>
813
- );
814
- }
815
- if (mode === 'financing' && hasCreditKeyFigures(kf)) {
816
- return (
817
- <div className="cc-terms">
818
- <CreditKeyFigures t={t} figures={kf} details={detailsButton || undefined} cls="cc-ckf" />
819
- </div>
820
- );
821
- }
822
- // split on the translation's own ' · ' separator so the dot can be styled lighter than the
823
- // two figures around it (same literal separator convention as FinanceCalculator's condParts).
824
- const termsParts = termsText ? termsText.split(' · ') : [];
825
- return (
826
- <div className="cc-terms">
827
- {termsParts.map((part, i) => (
828
- <React.Fragment key={i}>
829
- {i > 0 && <span className="cc-terms-dot"> · </span>}
830
- {part}
831
- </React.Fragment>
832
- ))}
833
- {detailsButton && (
834
- <>
835
- {termsText && <span className="cc-terms-dot"> · </span>}
836
- {detailsButton}
837
- </>
838
- )}
839
- </div>
840
- );
841
- };
842
-
843
- // Same real sales number VehicleDetailedNextPage.tsx (VDP) already dials via its own onCall —
844
- // duplicated here (not imported) because that page doesn't export it; both should eventually
845
- // read from one shared constant.
846
- export const DEALER_SALES_PHONE = '0800 40 30 182';
847
-
848
- /** default onCall — dials the real sales number directly, same tel: pattern VDP uses. */
849
- export function callDealerSalesPhone(): void {
850
- if (typeof window !== 'undefined') window.location.href = `tel:${DEALER_SALES_PHONE.replace(/\s/g, '')}`;
851
- }
852
-
853
- export interface CardCtaRowProps {
854
- car: AutobahnCar;
855
- /** which payment tab is currently active on the card — forwarded to onOpenRateAdjust so the
856
- * sheet opens on the SAME tab the user was looking at (the tab itself is CarCard-internal
857
- * state, so this is the only way the page learns it). */
858
- mode: PaymentMode;
859
- /** primary CTA — mirrors FinanceCalculator's onSecure ("Angebot anfragen"). */
860
- onRequestOffer: () => void;
861
- /** phone CTA — mirrors FinanceCalculator's onCall. */
862
- onCall: () => void;
863
- /**
864
- * opens the SAME "Rate anpassen" bottom-sheet FinanceDetailsModal already used on VDP mobile
865
- * (VdpModules.tsx) — the page mounts one shared modal instance and passes this car's data,
866
- * this button never builds its own sheet.
867
- */
868
- onOpenRateAdjust: (mode: PaymentMode) => void;
869
- t: TranslationFunction;
870
- }
871
-
872
- /**
873
- * Mobile-only 3-button CTA row (Figma: Angebot anfragen / phone / Rate anpassen). Desktop card
874
- * has no CTA row at all (confirmed: mobile-only, per explicit user correction). "Rate anpassen"
875
- * keeps its text label — only the phone button is icon-only, matching the mockup.
876
- */
877
- export const CardCtaRow: React.FunctionComponent<CardCtaRowProps> = ({ car, mode, onRequestOffer, onCall, onOpenRateAdjust, t }) => (
878
- <div
879
- className="card-cta-row show-mobile"
880
- style={{ display: 'flex', gap: 6, borderTop: '1px solid var(--md-outline-variant)', paddingTop: 8 }}
881
- >
882
- <Button
883
- variant="filled"
884
- style={{
885
- // Figma width (157px) as a STARTING size, not a hard fixed one — flex-grow:1 so this
886
- // button (and "Adjust rate" below) still fill extra row width on wider cards instead of
887
- // leaving dead space next to the fixed 40px phone button; flex-shrink:1 lets it narrow
888
- // gracefully (text ellipsizes via the existing .card-cta-row .mbtn overflow rule) rather
889
- // than overflow on very narrow cards.
890
- flex: '1 1 157px',
891
- height: 40,
892
- background: '#005cff',
893
- borderRadius: 16,
894
- padding: '0 8px',
895
- fontFamily: 'Arial, Arimo, sans-serif',
896
- fontStyle: 'normal',
897
- fontWeight: 700,
898
- fontSize: 13,
899
- lineHeight: '15px',
900
- color: '#ffffff',
901
- }}
902
- onClick={(e) => {
903
- e.stopPropagation();
904
- onRequestOffer();
905
- }}
906
- >
907
- {/* exact design icon (single self-contained SVG) — replaces the composed lucide
908
- file-text + check-circle badge (DocCheckIcon), which is still used as-is on VDP's own
909
- "Angebot anfragen" buttons; this swap is scoped to the search-card CTA only.
910
- flex:none for the same shrink reason as the "Adjust rate" icon above. */}
911
- <svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
912
- <path
913
- d="M6.90625 3.65625H15.275L19.9062 8.2875V20.7188C19.9062 21.6162 19.1787 22.3438 18.2812 22.3438H6.90625C6.00879 22.3438 5.28125 21.6162 5.28125 20.7188V5.28125C5.28125 4.38379 6.00879 3.65625 6.90625 3.65625Z"
914
- stroke="white"
915
- strokeLinecap="round"
916
- strokeLinejoin="round"
917
- />
918
- <path d="M15.0312 3.85938V8.53125H19.7031" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
919
- <path d="M8.9375 11.375H14.625" stroke="white" strokeLinecap="round" />
920
- <path d="M8.9375 14.625H13.4062" stroke="white" strokeLinecap="round" />
921
- <path d="M8.9375 17.875H12.5938" stroke="white" strokeLinecap="round" />
922
- <path
923
- d="M18.4844 23.1562C20.8402 23.1562 22.75 21.2465 22.75 18.8906C22.75 16.5348 20.8402 14.625 18.4844 14.625C16.1285 14.625 14.2188 16.5348 14.2188 18.8906C14.2188 21.2465 16.1285 23.1562 18.4844 23.1562Z"
924
- fill="#005CFF"
925
- stroke="white"
926
- />
927
- <path d="M17.0625 18.3219L18.5656 19.825L23.7656 14.625" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
928
- <path d="M21.6533 17.875L23.2783 16.25" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
929
- <path d="M20.1904 17.0625L21.8154 15.4375" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
930
- </svg>
931
- {t('autobahn:finance.secureOffer')}
932
- </Button>
933
- <Button
934
- variant="outlined"
935
- style={{
936
- flex: '0 0 auto',
937
- width: 40,
938
- height: 40,
939
- background: '#ffffff',
940
- border: '1.6px solid #005cff',
941
- borderRadius: 16,
942
- padding: 0,
943
- }}
944
- onClick={(e) => {
945
- e.stopPropagation();
946
- onCall();
947
- }}
948
- >
949
- {/* exact design icon (not lucide's "phone") — no class="lucide", so the
950
- .card-cta-row .mbtn .lucide 15px override doesn't touch it; the rect-clip from the
951
- source SVG was a full-viewBox no-op (already inside 0-20/0-20) and dropped, since a
952
- static clipPath id would collide across the many CarCard instances on one search page. */}
953
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
954
- <path
955
- d="M18.3332 14.1004V16.6004C18.3341 16.8325 18.2866 17.0622 18.1936 17.2749C18.1006 17.4875 17.9643 17.6784 17.7933 17.8353C17.6222 17.9922 17.4203 18.1116 17.2005 18.186C16.9806 18.2603 16.7477 18.288 16.5165 18.2671C13.9523 17.9881 11.4892 17.1119 9.32486 15.7087C7.31139 14.4293 5.60431 12.7222 4.32486 10.7087C2.91679 8.5346 2.04037 6.0595 1.76653 3.48374C1.7457 3.2533 1.77309 3.02104 1.84695 2.80176C1.9208 2.58248 2.03951 2.38098 2.1955 2.21009C2.3515 2.0392 2.54137 1.90266 2.75302 1.80917C2.96468 1.71569 3.19348 1.66729 3.42486 1.66707H5.92486C6.32928 1.66309 6.72136 1.80631 7.028 2.07002C7.33464 2.33373 7.53493 2.69995 7.59153 3.10041C7.69153 3.85041 7.86653 4.57541 8.11653 5.26707C8.22865 5.56534 8.25291 5.8895 8.18645 6.20114C8.11999 6.51278 7.96558 6.79883 7.74153 7.02541L6.74153 8.03374C7.95617 10.2329 9.76739 12.0441 11.9665 13.2587L12.9749 12.2587C13.2014 12.0347 13.4875 11.8803 13.7991 11.8138C14.1108 11.7474 14.4349 11.7716 14.7332 11.8837C15.4249 12.1337 16.1499 12.3087 16.8999 12.4087C17.3047 12.4658 17.6744 12.6697 17.9386 12.9817C18.2029 13.2936 18.3433 13.6917 18.3332 14.1004Z"
956
- stroke="#005cff"
957
- strokeWidth={1.66667}
958
- strokeLinecap="round"
959
- strokeLinejoin="round"
960
- />
961
- </svg>
962
- </Button>
963
- <Button
964
- variant="outlined"
965
- style={{
966
- // same "starting size that can still grow/shrink" reasoning as "Request offer" above.
967
- flex: '1 1 125px',
968
- height: 40,
969
- background: '#ffffff',
970
- border: '1.6px solid #5b6b7f',
971
- borderRadius: 16,
972
- padding: '0 6px',
973
- fontFamily: 'Arial, Arimo, sans-serif',
974
- fontStyle: 'normal',
975
- fontWeight: 700,
976
- fontSize: 13,
977
- lineHeight: '15px',
978
- color: '#5b6b7f',
979
- }}
980
- onClick={(e) => {
981
- e.stopPropagation();
982
- onOpenRateAdjust(mode);
983
- }}
984
- >
985
- {/* exact design icon (not lucide's "sliders-horizontal") — colors are baked into the SVG
986
- itself (matches the button's #5b6b7f border/text), not currentColor. flex:none is
987
- load-bearing: this button is a flex row (icon + the "Adjust rate" label) inside a fixed
988
- 125px width, and without it the icon was a shrinkable flex item — flexbox squeezed its
989
- WIDTH down to fit the text (rendering ~12.94x18, squashed) while its literal height
990
- attribute stayed 18. Lucide icons here dodge this via the unrelated .card-cta-row .mbtn
991
- .lucide CSS rule (flex: none), which doesn't match a plain <svg> with no lucide class. */}
992
- <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
993
- <path d="M3 5.25H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
994
- <path
995
- d="M6 6.75C6.82843 6.75 7.5 6.07843 7.5 5.25C7.5 4.42157 6.82843 3.75 6 3.75C5.17157 3.75 4.5 4.42157 4.5 5.25C4.5 6.07843 5.17157 6.75 6 6.75Z"
996
- fill="#FFFEFE"
997
- stroke="#5B6B7F"
998
- strokeLinecap="round"
999
- strokeLinejoin="round"
1000
- />
1001
- <path d="M3 9H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
1002
- <path
1003
- d="M12.4565 10.5C13.285 10.5 13.9565 9.82843 13.9565 9C13.9565 8.17157 13.285 7.5 12.4565 7.5C11.6281 7.5 10.9565 8.17157 10.9565 9C10.9565 9.82843 11.6281 10.5 12.4565 10.5Z"
1004
- fill="white"
1005
- stroke="#5B6B7F"
1006
- strokeLinecap="round"
1007
- strokeLinejoin="round"
1008
- />
1009
- <path d="M3 12.75H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
1010
- <path
1011
- d="M9.81543 14.25C10.6439 14.25 11.3154 13.5784 11.3154 12.75C11.3154 11.9216 10.6439 11.25 9.81543 11.25C8.987 11.25 8.31543 11.9216 8.31543 12.75C8.31543 13.5784 8.987 14.25 9.81543 14.25Z"
1012
- fill="white"
1013
- stroke="#5B6B7F"
1014
- strokeLinecap="round"
1015
- strokeLinejoin="round"
1016
- />
1017
- </svg>
1018
- {t('autobahn:finance.adjustRate')}
1019
- </Button>
1020
- </div>
1021
- );
1022
-
1023
- export interface GalleryCounterProps {
1024
- /** 1-based index of the currently shown photo. */
1025
- current: number;
1026
- total: number;
1027
- /** Figma "Vehicle Gallery / Photos Button" light-pill treatment (Car Card, node 281:1016) —
1028
- * CarRow keeps the original dark `.imglabel` pill until it gets the same design pass. */
1029
- light?: boolean;
1030
- /** makes the light pill a real button (opens the full VdpViewer lightbox on the grid card) —
1031
- * the dark `.imglabel` variant stays a plain, non-interactive span either way. */
1032
- onClick?: () => void;
1033
- }
1034
-
1035
- /**
1036
- * Bottom-left gallery overlay: expand icon + "current|total" (Figma). Reuses the existing
1037
- * `.imglabel` pill style (already used for the list-card's photo-count badge) rather than a new
1038
- * class — same dark translucent pill, just with the maximize icon instead of the image icon.
1039
- *
1040
- * States (shared policy across GalleryCounter, the carousel's own arrows/dots in CardCarousel,
1041
- * and GalleryActivityPill below — see its own doc comment for the other two):
1042
- * - single-image: `total` is the car's REAL, eagerly-known photo count (car.photos, from the
1043
- * search payload — not the lazily-loaded gallery array length), so this is accurate even
1044
- * before any image beyond the first has actually loaded. total<=1 → hidden: nothing to expand
1045
- * into. Never a "1|1" placeholder.
1046
- * - loading: while `total` itself is still unknown (car not yet resolved) the caller simply
1047
- * hasn't rendered this component yet — there is no separate in-between skeleton state here.
1048
- */
1049
- export const GalleryCounter: React.FunctionComponent<GalleryCounterProps> = ({ current, total, light, onClick }) => {
1050
- if (total <= 1) return null;
1051
- if (light) {
1052
- return (
1053
- <button type="button" className="cc-photo-pill" onClick={onClick}>
1054
- <Icon name="maximize" size={18} stroke={2} color="#111820" />
1055
- {current} | {total}
1056
- </button>
1057
- );
1058
- }
1059
- return (
1060
- <span className="imglabel">
1061
- <Icon name="maximize" size={13} stroke={2} />
1062
- {current}|{total}
1063
- </span>
1064
- );
1065
- };
1066
-
1067
- export interface GalleryActivityPillProps {
1068
- /** total detail-page views (stats totalCarImpCount) — real data only, never fabricated. */
1069
- viewsCount?: number;
1070
- /** total merkliste adds (stats totalFavCount) — real data only, never fabricated. */
1071
- favoritesCount?: number;
1072
- }
1073
-
1074
- /**
1075
- * Bottom-right gallery overlay: eye + views, heart + favorites, in ONE pill (Figma "Push Chips /
1076
- * Likes", node 297:1037). Each half renders independently.
1077
- *
1078
- * States (chosen ONE policy, applied identically to both halves):
1079
- * - loading: `viewsCount`/`favoritesCount` are `undefined` until the async stats call
1080
- * (UserActionsAPI 'stats/viewers') resolves for this car. No skeleton — the half (or the
1081
- * whole pill, if both are still pending) simply doesn't render yet, same "hidden, not a
1082
- * placeholder" discipline as GalleryCounter/CardCarousel's arrows above.
1083
- * - zero-value: a REAL `0` is treated the same as "not there" — hidden, not shown as "👁 0".
1084
- * Deliberate choice over spelling out "0" (the other option the ticket allows): on a dense
1085
- * grid of fresh listings a "👁 0 ❤ 0" pill on every card is noise, not signal. `!viewsCount`/
1086
- * `!favoritesCount` below intentionally don't distinguish real-0 from not-yet-loaded — both
1087
- * read as "nothing worth showing (yet)", which is the same outcome either way.
1088
- */
1089
- export const GalleryActivityPill: React.FunctionComponent<GalleryActivityPillProps> = ({ viewsCount, favoritesCount }) => {
1090
- if (!viewsCount && !favoritesCount) return null;
1091
- return (
1092
- <span className="cc-activity-pill">
1093
- {!!viewsCount && (
1094
- <span className="cc-activity-pill-item">
1095
- <Icon name="eye" size={16} stroke={1.9} color="#1D2A38" />
1096
- {viewsCount}
1097
- </span>
1098
- )}
1099
- {!!favoritesCount && (
1100
- <span className="cc-activity-pill-item">
1101
- <Icon name="heart" size={16} stroke={1.9} color="#1D2A38" />
1102
- {favoritesCount}
1103
- </span>
1104
- )}
1105
- </span>
1106
- );
1107
- };
1108
-
1109
- interface PpRowProps {
1110
- /** payment-path label (Finanzierung / Leasing / Kaufen). */
1111
- label: string;
1112
- /** the figure to show — a monthly rate (money=false) or a full price (money=true). */
1113
- value: number;
1114
- /** small unit before the figure, e.g. 'mtl.'. */
1115
- unit?: string;
1116
- /** real previous price to strike through (only ever the genuine list price). */
1117
- old?: number | null;
1118
- /** the financing row — kept visually dominant (larger). */
1119
- focus?: boolean;
1120
- /** format as a full euro price (Kaufen) instead of a rounded rate. */
1121
- money?: boolean;
1122
- t: TranslationFunction;
1123
- }
1124
-
1125
- /**
1126
- * One payment-path row: label (+ a quiet info marker) on the left, the price right-aligned
1127
- * with an optional struck-through previous price above it. Even row spacing reproduces the
1128
- * production "Finanzierung / Leasing / Kaufen" price table the design references. The struck
1129
- * `old` price gets the same "²" UvpBadge + click-to-open popover as PriceHero's own Kaufen
1130
- * old-price (same n, same body/close copy) — one-to-one, not a re-styled variant.
1131
- */
1132
- const PpRow: React.FunctionComponent<PpRowProps> = ({ label, value, unit, old, focus, money, t }) => {
1133
- const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
1134
- // 5-plus-digit prices (e.g. 60.248 €) shrink to keep the row from crowding — 4-digit values
1135
- // stay at the base size. Same digit-length technique as PriceHero's buyLen6Class.
1136
- const valDigits = String(Math.round(value)).length;
1137
- const valLenClass = valDigits >= 5 ? ' pp-val--len5' : '';
1138
- return (
1139
- <div className={'pp-row' + (focus ? ' pp-row--focus' : '')}>
1140
- <span className="pp-row-label">
1141
- {label}
1142
- <Icon name="info" size={13} stroke={1.9} cls="pp-row-i" />
1143
- </span>
1144
- <span className="pp-row-price">
1145
- {old != null && (
1146
- // ADV-423: "UVP" label for the struck list price (PpRow only renders in the desktop SRL
1147
- // column, and `old` is only ever the Kaufen list price). md3.css places it above the
1148
- // struck amount there — the fixed-width row has no room for it inline.
1149
- <span className="pp-uvp-strike">
1150
- <span
1151
- className="pp-uvp-label"
1152
- onClick={(e) => {
1153
- e.stopPropagation();
1154
- setUvpTooltipOpen((v) => !v);
1155
- }}
1156
- >
1157
- {t('autobahn:finance.uvp')}
1158
- </span>
1159
- <span
1160
- className="pp-old"
1161
- role="button"
1162
- tabIndex={0}
1163
- onClick={(e) => {
1164
- e.stopPropagation();
1165
- setUvpTooltipOpen((v) => !v);
1166
- }}
1167
- >
1168
- {old.toLocaleString('de-DE')} €
1169
- <UvpBadge
1170
- n={2}
1171
- open={uvpTooltipOpen}
1172
- onToggle={() => setUvpTooltipOpen((v) => !v)}
1173
- onClose={() => setUvpTooltipOpen(false)}
1174
- closeLabel={t('autobahn:modal.close')}
1175
- body={t('autobahn:card.price.uvpListTooltipBody')}
1176
- />
1177
- </span>
1178
- </span>
1179
- )}
1180
- <span className="pp-now">
1181
- {unit && <span className="pp-unit">{unit}</span>}
1182
- <b className={'num pp-val' + valLenClass}>
1183
- {money ? value.toLocaleString('de-DE') : fmtRate(value)} €{money && <sup>1</sup>}
1184
- </b>
1185
- </span>
1186
- </span>
1187
- </div>
1188
- );
1189
- };
1190
-
1191
- /**
1192
- * Monthly-rate payment paths (SRP price column, TOP group) — modelled on the legacy design:
1193
- * Finanzierung is the hero (eyebrow + big blue rate + its terms line), which both keeps the
1194
- * financing focus and FILLS the upper gap with real default-config info (Anzahlung · Laufzeit).
1195
- * Leasing follows as a quiet neutral row (with its own terms when the config carries them) and
1196
- * is omitted entirely when leasing isn't active. The Kaufen row is rendered separately
1197
- * (PriceKauf) below a divider so only the financing rate stands out — no wall of blue prices.
1198
- */
1199
- export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t, className, onShowDetails }) => {
1200
- const hasLease = car.lease != null;
1201
- // Terms of the config the displayed rate was actually computed with (per-car:
1202
- // dealer rate + the user's saved localStorage adjustments) — default config
1203
- // terms only when the car doesn't carry its own.
1204
- const finFirstInstallment =
1205
- car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
1206
- const finMonths = car.finMonths ?? _finMonths;
1207
- const finKf = finKeyFigures(car);
1208
- const leaseKf = leaseKeyFigures(car);
1209
- const leasFirstInstallment =
1210
- car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
1211
- const leasMileage = car.leaseMileage ?? _leasMileage;
1212
- const leasMonths = car.leaseMonths ?? _leasPeriod;
1213
- const hasLeasTerms = Boolean(leasMileage && leasMonths);
1214
- const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
1215
- const detailsLink = (mode: PaymentMode): React.ReactNode =>
1216
- onShowDetails ? (
1217
- <button
1218
- type="button"
1219
- className="pp-details-link"
1220
- onClick={(e) => {
1221
- e.stopPropagation();
1222
- onShowDetails(mode);
1223
- }}
1224
- >
1225
- {t('autobahn:card.price.details')}
1226
- </button>
1227
- ) : (
1228
- <span className="pp-details-link">{t('autobahn:card.price.details')}</span>
1229
- );
1230
- return (
1231
- <div className={'pricepaths' + (className ? ' ' + className : '')}>
1232
- <div className="pp-eyebrow">{t('autobahn:card.price.financingFrom')}</div>
1233
- {/* reuses PriceHero's own financing rendering — the exact same stacked "UVP-Rate ⓘ /
1234
- struck price / mtl." group beside the rate that .cc-price and mobile's tab switcher
1235
- already use, so the rate + unit never fight for room in one flat row (the earlier
1236
- hand-rolled version here put them side by side and wrapped for any 4+-digit rate). */}
1237
- <PriceHero car={car} mode="financing" t={t} alwaysShowUnit />
1238
- <div className="pp-hero-terms">
1239
- {/* ADV-405 follow-up (PM 19.11): the financing key figures replace the "Anzahlung ·
1240
- Laufzeit" terms here (.pp-hero-terms colour) in exactly two lines, the font fitted to
1241
- the narrow column (client call 19.11: "2 lines, the font size doesn't matter"); without
1242
- any real figure the old terms line stays. */}
1243
- {hasCreditKeyFigures(finKf) ? (
1244
- <CreditKeyFigures t={t} figures={finKf} details={detailsLink('financing')} cls="pp-ckf" />
1245
- ) : (
1246
- <>
1247
- {t('autobahn:card.price.financeTerms', {
1248
- firstInstallment: finFirstInstallment,
1249
- months: finMonths,
1250
- count: finMonths,
1251
- })}{' '}
1252
- · {detailsLink('financing')}
1253
- </>
1254
- )}
1255
- </div>
1256
- {/* ADV-405/408/411 Kreditkosten-Hinweis: one per card, under the financing conditions and
1257
- above the Leasing row. Financing is always shown in this column, so it is unconditional. */}
1258
- <CreditCostNotice t={t} size="small" cls="pp-ccn" />
1259
- {hasLease && (
1260
- <div className="pp-lease-row">
1261
- <PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." t={t} />
1262
- {/* ADV-405 follow-up (leasing, 19.11): the leasing key figures replace the compact
1263
- terms — exactly two lines like everywhere else (client call 19.11: "2 lines, the font
1264
- size doesn't matter"), the font fitted to the column; without any real figure the
1265
- old terms stay. */}
1266
- {hasCreditKeyFigures(leaseKf) ? (
1267
- <div className="pp-sub-terms">
1268
- <CreditKeyFigures t={t} figures={leaseKf} details={detailsLink('leasing')} cls="pp-ckf" />
1269
- </div>
1270
- ) : hasLeasTerms && (
1271
- <div className="pp-sub-terms">
1272
- {/* dedicated keys (not a rework of leaseTerms) so mobile/VDP's own reviewed
1273
- wording there stays untouched, but includes the same Sonderzahlung figure.
1274
- Split across two lines with an explicit <br/> (column is too narrow for all
1275
- three figures + Details on one line) — forced right after km/Jahr so "36" and
1276
- "Mon." always land on the same line instead of an awkward mid-number wrap. */}
1277
- {t('autobahn:card.price.leaseTermsCompactLine1', {
1278
- firstInstallment: leasFirstInstallment,
1279
- mileage: leasMileageStr,
1280
- })}{' · '}
1281
- <br />
1282
- {t('autobahn:card.price.leaseTermsCompactLine2', { months: leasMonths })}{' '}
1283
- · {detailsLink('leasing')}
1284
- </div>
1285
- )}
1286
- </div>
1287
- )}
1288
- </div>
1289
- );
1290
- };
1291
-
1292
- /**
1293
- * Kaufen (outright purchase) row — the BOTTOM group, separated from the monthly-rate paths by a
1294
- * divider. Quiet/neutral (not blue) and strikes the previous price only on a real list-price
1295
- * saving (never a fabricated "was" price).
1296
- */
1297
- export const PriceKauf: React.FunctionComponent<PricePathsProps> = ({ car, t }) => {
1298
- const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
1299
- return (
1300
- <PpRow label={t('autobahn:card.price.buy')} value={car.price} old={showStrike ? (car.listPrice as number) : null} money t={t} />
1301
- );
1302
- };
1303
-
1304
- export interface PpActivityProps {
1305
- car: AutobahnCar;
1306
- t: TranslationFunction;
1307
- }
1308
-
1309
- /**
1310
- * Buyer-activity cue rendered below the CTA in the listing card.
1311
- *
1312
- * NEEDS-DATA: needs watchers + views. When either is missing we show the
1313
- * 'Daten folgt' marker instead of inventing interest figures.
1314
- */
1315
- export const PpActivity: React.FunctionComponent<PpActivityProps> = ({ car, t }) => {
1316
- // No real watcher/view data (no backend yet) → render nothing rather than a "Daten folgt"
1317
- // placeholder that reads as perpetual loading. Wire when UserActionsAPI stats are available.
1318
- if (car.watchers == null || car.views == null) return null;
1319
- const hrs = 1 + (car.views % 6);
1320
- return (
1321
- <div className="pp-activity">
1322
- <Icon name="eye" size={12} stroke={1.9} />
1323
- {t('autobahn:card.activity.watchers', { watchers: car.watchers, hrs, count: car.watchers })}
1324
- </div>
1325
- );
1326
- };
1327
-
1328
- export interface GalleryBadgesProps {
1329
- car: AutobahnCar;
1330
- t: TranslationFunction;
1331
- }
1332
-
1333
- /**
1334
- * Trust/activity badges overlaid on the photo itself, bottom-right (PM reference, 2026-07-10),
1335
- * Figma pill styling (border/radius/height — see .gallery-pill in md3.css). Mirrors the mobile
1336
- * VDP gallery header (availability · views · favorites · Geprüft).
1337
- *
1338
- * Each pill is independent, not all-or-nothing: a missing or zero view/favorite count just omits
1339
- * THAT pill (never shown as "0×") — availability and Geprüft still render on their own terms.
1340
- * .gallery-badges is anchored via `right`, not `left` (md3.css), so however many pills survive
1341
- * they stay stuck to the right edge instead of drifting to wherever the row happens to start.
1342
- */
1343
- export const GalleryBadges: React.FunctionComponent<GalleryBadgesProps> = ({ car, t }) => (
1344
- <div className="gallery-badges">
1345
- {car.availability && (
1346
- <span className="gallery-pill">
1347
- <Icon name="circle-check" size={15} stroke={2} color="var(--md-good)" />
1348
- {car.availability}
1349
- </span>
1350
- )}
1351
- {!!car.viewsCount && (
1352
- <span className="gallery-pill">
1353
- <Icon name="eye" size={15} stroke={1.9} />
1354
- {t('autobahn:card.activity.viewsCount', { count: car.viewsCount })}
1355
- </span>
1356
- )}
1357
- {!!car.favoritesCount && (
1358
- <span className="gallery-pill">
1359
- <Icon name="heart" size={15} stroke={1.9} />
1360
- {t('autobahn:card.activity.favoritesCount', { count: car.favoritesCount })}
1361
- </span>
1362
- )}
1363
- <span className="gallery-pill">
1364
- <Icon name="shield-check" size={15} stroke={1.9} />
1365
- {t('autobahn:card.trust.checked')}
1366
- </span>
1367
- </div>
1368
- );
1
+ // Autobahn (auto.de redesign) — car-card helper parts.
2
+ //
3
+ // Typed React 18 + TS port of the helper components from the design kit
4
+ // (docs/redesign/design-source/ui_kits/website/CarCard.jsx). Pure /
5
+ // presentational: every value comes from the `AutobahnCar` prop, there is no
6
+ // store / API / `window` access. The design kit's `window.CO2_CLASSES` /
7
+ // `window.CO2_COLORS` globals are replaced by the shared autobahn constants.
8
+ //
9
+ // These render correctly only inside a `<div className="md3">` subtree (the
10
+ // `.pricepaths`, `.pp-*`, `.specstrip`, `.imglabel` … classes are scoped there).
11
+ //
12
+ // NEEDS-DATA discipline (the point of the ticket): wherever the design showed a
13
+ // figure we have no real source for, these helpers render the NEEDS_DATA_LABEL
14
+ // ('Daten folgt') marker instead of inventing a number — see PricePaths'
15
+ // market band and PpActivity. DropChip renders nothing when there is no drop.
16
+
17
+ import React, { useState } from 'react';
18
+ import { TranslationFunction } from '../types';
19
+ import { defaultConfig } from '@bytebrand/fe-financing';
20
+
21
+ import { Icon, Button, CreditCostNotice, CreditKeyFigures, hasCreditKeyFigures } from '../ui';
22
+ import type { CreditKeyFiguresData } from '../ui';
23
+ import { EvalBar } from '../vdp/FinanceCalculator';
24
+ import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS } from '../constants';
25
+ import { AutobahnCar } from './types';
26
+ // pure, non-React — shared with the Meta AIA marketing-image renderer (a plain Node service).
27
+ export { ratingTone } from '../data/toAutobahnCar';
28
+
29
+ // Default financing/leasing terms shown under the rate (the SRP card has no per-car selector, so
30
+ // these are the same default config the displayed rate is computed with — consistent, not invented).
31
+ const _finCfg = (defaultConfig as any).financing || {};
32
+ const _leasCfg = (defaultConfig as any).leasing || {};
33
+ /** financing terms inputs (rendered via t in PricePaths), e.g. "0 € Anzahlung · 48 Monate Laufzeit". */
34
+ const _finFirstInstallment = (_finCfg.firstInstallment || 0).toLocaleString('de-DE');
35
+ const _finMonths = _finCfg.rawPaybackPeriod || _finCfg.paybackPeriod || 48;
36
+ /** leasing terms fallbacks (used when the car doesn't carry its own), e.g. "10.000 km/Jahr · 48 Monate". */
37
+ const _leasPeriod = _leasCfg.rawPaybackPeriod || _leasCfg.paybackPeriod;
38
+ const _leasMileage = _leasCfg.annualMileage || _leasCfg.mileage;
39
+ const _leasFirstInstallment = (_leasCfg.firstInstallment || 0).toLocaleString('de-DE');
40
+
41
+ /**
42
+ * ADV-405 follow-up (PM 19.11): the car's real financing key figures (Kerndaten) — the same
43
+ * price.financing values the Finanzierungsdetails layer lists (toAutobahnCar). No default-config
44
+ * fallback here: a missing figure is simply omitted by CreditKeyFigures, and with none real the
45
+ * hosts keep their previous conditions line.
46
+ */
47
+ const finKeyFigures = (car: AutobahnCar): CreditKeyFiguresData => ({
48
+ months: car.finMonths,
49
+ netLoan: car.finNetLoan,
50
+ total: car.finTotal,
51
+ nominal: car.finNominal,
52
+ apr: car.finApr,
53
+ finalInstallment: car.finFinal,
54
+ });
55
+
56
+ /**
57
+ * ADV-405 follow-up (leasing confirmed 19.11): the car's real leasing key figures — computed in
58
+ * toAutobahnCar from price.leasing with the Leasingdetails layer's arithmetic (leasingKeyFigures).
59
+ * Sonderzahlung/term are the lease rate's own terms; nothing falls back to the default config.
60
+ */
61
+ const leaseKeyFigures = (car: AutobahnCar): CreditKeyFiguresData => ({
62
+ kind: 'leasing',
63
+ down: car.leaseFirstInstallment,
64
+ months: car.leaseMonths,
65
+ cashPrice: car.leaseCashPrice,
66
+ total: car.leaseTotal,
67
+ residual: car.leaseResidual,
68
+ nominal: car.leaseNominal,
69
+ apr: car.leaseApr,
70
+ });
71
+
72
+ /** mileage → 'X.XXX km' (de-DE grouping). */
73
+ export function fmtKm(n: number): string {
74
+ return n.toLocaleString('de-DE') + ' km';
75
+ }
76
+
77
+ /**
78
+ * Monthly rate → de-DE integer euro string (e.g. 402.12 → "402"). Rates are shown as whole
79
+ * euros like the legacy card ("271 €"); a raw float printed directly rendered as "402.12 €",
80
+ * which a German reader parses as 402.120 — fixed here with rounding + de-DE grouping.
81
+ */
82
+ export function fmtRate(n: number): string {
83
+ return Math.round(n).toLocaleString('de-DE');
84
+ }
85
+
86
+ /** strip a trailing parenthetical, e.g. '110 kW (150 PS)' → '110 kW'. */
87
+ function stripParen(s: string): string {
88
+ return s.replace(/\s*\(.*\)/, '');
89
+ }
90
+
91
+ /**
92
+ * Opposite of stripParen, for car.power specifically: pull the PS value OUT of the trailing
93
+ * parenthetical instead of discarding it, e.g. '145 kW (197 PS)' → '197 PS' — the card wants
94
+ * PS only, no kW at all. Regex requires the paren to actually contain "N PS" (not just any
95
+ * parenthetical) and falls back to the plain stripParen(kW) result when it doesn't, so a power
96
+ * string without a PS conversion still renders something instead of going blank.
97
+ */
98
+ function extractPS(s: string): string {
99
+ const m = s.match(/\((\d+\s*PS)\)\s*$/i);
100
+ return m ? m[1].replace(/\s+/, ' ') : stripParen(s);
101
+ }
102
+
103
+ // Compact spec for cards: short fuel/gear labels so all five values fit ONE line
104
+ // without clipping.
105
+ const FUEL_SHORT: Record<string, string> = {
106
+ 'Plug-in-Hybrid': 'Hybrid',
107
+ Benzin: 'Benzin',
108
+ Diesel: 'Diesel',
109
+ Elektro: 'Elektro',
110
+ };
111
+ const GEAR_SHORT: Record<string, string> = {
112
+ Automatik: 'Automatik',
113
+ Schaltgetriebe: 'Manuell',
114
+ };
115
+
116
+ /** five compact spec values for the grid card's one-line spec strip. */
117
+ export function cardSpec(car: AutobahnCar): string[] {
118
+ const fuel = stripParen(car.fuel);
119
+ return [
120
+ fmtKm(car.km),
121
+ car.reg,
122
+ extractPS(car.power),
123
+ FUEL_SHORT[fuel] || fuel,
124
+ GEAR_SHORT[car.gear] || car.gear,
125
+ ];
126
+ }
127
+
128
+ export interface SpecLineProps {
129
+ items: string[];
130
+ size?: number;
131
+ /** never wrap — clip overflow with ellipsis (single line). */
132
+ oneLine?: boolean;
133
+ }
134
+
135
+ /** Compact pipe-separated spec line (AutoScout pattern). */
136
+ export const SpecLine: React.FunctionComponent<SpecLineProps> = ({ items, size = 12.5, oneLine = false }) => (
137
+ <div
138
+ className="cc-spec"
139
+ style={{
140
+ display: 'flex',
141
+ flexWrap: oneLine ? 'nowrap' : 'wrap',
142
+ alignItems: 'center',
143
+ gap: '2px 8px',
144
+ fontSize: size,
145
+ color: 'var(--md-on-surface-variant)',
146
+ ...(oneLine ? { overflow: 'hidden', whiteSpace: 'nowrap' } : {}),
147
+ }}
148
+ >
149
+ {items.map((v, i) => (
150
+ <React.Fragment key={i}>
151
+ {i > 0 && <span style={{ color: 'var(--md-outline-variant)', flex: 'none' }}>·</span>}
152
+ <span style={oneLine ? { whiteSpace: 'nowrap' } : undefined}>{v}</span>
153
+ </React.Fragment>
154
+ ))}
155
+ </div>
156
+ );
157
+
158
+ export interface PriceBlockProps {
159
+ car: AutobahnCar;
160
+ align?: 'left' | 'right';
161
+ t: TranslationFunction;
162
+ }
163
+
164
+ /** Price block — rate-first (monthly is the lead), purchase price secondary. */
165
+ export const PriceBlock: React.FunctionComponent<PriceBlockProps> = ({ car, align = 'left', t }) => {
166
+ const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
167
+ return (
168
+ <div style={{ textAlign: align }}>
169
+ <div
170
+ style={{
171
+ display: 'flex',
172
+ alignItems: 'baseline',
173
+ gap: 5,
174
+ justifyContent: align === 'right' ? 'flex-end' : 'flex-start',
175
+ }}
176
+ >
177
+ <span
178
+ className="num"
179
+ style={{
180
+ fontWeight: 700,
181
+ fontSize: 26,
182
+ color: 'var(--md-primary)',
183
+ letterSpacing: '-.6px',
184
+ whiteSpace: 'nowrap',
185
+ }}
186
+ >
187
+ {fmtRate(car.monthly)} €
188
+ </span>
189
+ <span className="md-label-sm">{t('autobahn:card.price.perMonth')}</span>
190
+ </div>
191
+ <div
192
+ className="md-label-sm"
193
+ style={{
194
+ marginTop: 1,
195
+ display: 'flex',
196
+ flexWrap: 'wrap',
197
+ gap: '0 6px',
198
+ justifyContent: align === 'right' ? 'flex-end' : 'flex-start',
199
+ }}
200
+ >
201
+ <span style={{ whiteSpace: 'nowrap' }}>
202
+ {t('autobahn:card.price.purchasePrice')}{' '}
203
+ <b style={{ color: 'var(--md-on-surface)' }}>{car.price.toLocaleString('de-DE')} €</b>
204
+ </span>
205
+ {showStrike && (
206
+ <span
207
+ style={{
208
+ color: 'var(--md-on-surface-variant)',
209
+ textDecoration: 'line-through',
210
+ whiteSpace: 'nowrap',
211
+ }}
212
+ >
213
+ {car.listPrice!.toLocaleString('de-DE')} €
214
+ </span>
215
+ )}
216
+ </div>
217
+ </div>
218
+ );
219
+ };
220
+
221
+ export interface DropChipProps {
222
+ /** real price reduction in EUR; when undefined the chip renders nothing. */
223
+ amount?: number;
224
+ t: TranslationFunction;
225
+ }
226
+
227
+ /**
228
+ * Price-drop chip — a REAL reduction on this car. White pill so it doesn't
229
+ * compete with the solid green rating chip. Renders nothing when there is no
230
+ * drop (we never fabricate a reduction).
231
+ */
232
+ export const DropChip: React.FunctionComponent<DropChipProps> = ({ amount, t }) => {
233
+ if (amount == null) {
234
+ return null;
235
+ }
236
+ return (
237
+ <span
238
+ className="deal-chip deal-chip--drop"
239
+ style={{
240
+ display: 'inline-flex',
241
+ alignItems: 'center',
242
+ gap: 3,
243
+ height: 22,
244
+ padding: '0 8px',
245
+ borderRadius: 'var(--md-r-full)',
246
+ background: 'rgba(255,255,255,.94)',
247
+ color: 'var(--md-good)',
248
+ fontSize: 10.5,
249
+ fontWeight: 700,
250
+ lineHeight: '14px',
251
+ boxShadow: 'var(--md-e1)',
252
+ whiteSpace: 'nowrap',
253
+ }}
254
+ >
255
+ <Icon name="trending-down" size={12} stroke={2.4} color="var(--md-good)" />
256
+ {t('autobahn:card.price.priceDropAmount', { amount: amount.toLocaleString('de-DE') })}
257
+ </span>
258
+ );
259
+ };
260
+
261
+ /** shared deal-badge pill style (NEU/drop/percent/zero-down all share the same compact shape). */
262
+ const dealPill: React.CSSProperties = {
263
+ display: 'inline-flex',
264
+ alignItems: 'center',
265
+ height: 22,
266
+ padding: '0 8px',
267
+ borderRadius: 'var(--md-r-full)',
268
+ fontSize: 10.5,
269
+ fontWeight: 700,
270
+ boxShadow: 'var(--md-e1)',
271
+ whiteSpace: 'nowrap',
272
+ };
273
+
274
+ /** Percent price-drop chip (−X%). Red pill — pairs with DropChip. Renders nothing without a real pct. */
275
+ export const PercentChip: React.FunctionComponent<{ pct?: number }> = ({ pct }) => {
276
+ if (pct == null || pct <= 0) return null;
277
+ return (
278
+ <span className="deal-chip deal-chip--percent" style={{ ...dealPill, background: 'var(--md-error)', color: '#fff', lineHeight: '14px' }}>
279
+ −{pct}%
280
+ </span>
281
+ );
282
+ };
283
+
284
+ /**
285
+ * Zero-down-payment chip (offer.showDownPayment). Cyan pill. Spells out "0 € Anzahlung" where
286
+ * there is room (grid cards / wide image) and uses the compact "0 € Anz." on the narrow list-card
287
+ * image, so the badge row always stays on ONE line on both desktop and mobile.
288
+ */
289
+ export const ZeroDownChip: React.FunctionComponent<{
290
+ show?: boolean;
291
+ compact?: boolean;
292
+ t: TranslationFunction;
293
+ className?: string;
294
+ /** overrides the default pill look (e.g. the desktop "mcard" full-text badge's own blue tint/size
295
+ * from the Figma export) — merged last so it wins over the shared dealPill defaults below. */
296
+ style?: React.CSSProperties;
297
+ }> = ({ show, compact, t, className, style }) => {
298
+ if (!show) return null;
299
+ return (
300
+ <span
301
+ className={className}
302
+ style={{ ...dealPill, background: 'var(--md-accent-container)', color: 'var(--md-on-accent-container)', ...style }}
303
+ >
304
+ {compact ? t('autobahn:card.price.zeroDownCompact') : t('autobahn:card.price.zeroDown')}
305
+ </span>
306
+ );
307
+ };
308
+
309
+ /**
310
+ * "⚡ Angebot" gray badge — NOT a separate backend flag (none exists yet). Shown whenever the
311
+ * card already carries a real deal signal (NEU / price drop / meaningful savings / 0€ Anzahlung
312
+ * / percent drop) — i.e. it labels the same real discount the other badges point at, rather
313
+ * than inventing a new "is this an offer" field. Revisit if/when a dedicated flag exists.
314
+ */
315
+ export const OfferBadge: React.FunctionComponent<{ show: boolean; t: TranslationFunction }> = ({ show, t }) => {
316
+ if (!show) return null;
317
+ return (
318
+ <span className="offer-badge">
319
+ <Icon name="zap" size={13} stroke={2.2} />
320
+ {t('autobahn:card.badge.offer')}
321
+ </span>
322
+ );
323
+ };
324
+
325
+ interface InlineClsProps {
326
+ /** CO₂ class letter, e.g. 'B'. */
327
+ c: string;
328
+ }
329
+
330
+ /** Small inline colored CO₂-class letter (keeps EnVKV line a fixed height). */
331
+ const InlineCls: React.FunctionComponent<InlineClsProps> = ({ c }) => {
332
+ const i = Math.max(0, CO2_CLASSES.indexOf(c as (typeof CO2_CLASSES)[number]));
333
+ const color = CO2_COLORS[i] || 'var(--md-outline)';
334
+ return (
335
+ <span
336
+ style={{
337
+ display: 'inline-flex',
338
+ width: 14,
339
+ height: 14,
340
+ borderRadius: 3,
341
+ background: color,
342
+ color: '#fff',
343
+ fontSize: 9.5,
344
+ fontWeight: 800,
345
+ alignItems: 'center',
346
+ justifyContent: 'center',
347
+ verticalAlign: '-2px',
348
+ margin: '0 1px',
349
+ }}
350
+ >
351
+ {c}
352
+ </span>
353
+ );
354
+ };
355
+
356
+ export interface EcoLineProps {
357
+ car: AutobahnCar;
358
+ style?: React.CSSProperties;
359
+ t: TranslationFunction;
360
+ }
361
+
362
+ /**
363
+ * Pkw-EnVKV legal line — full consumption + CO₂ + class. REQUIRED on every
364
+ * German car ad and must stay visible. Quiet fine-print footnote with a fixed
365
+ * min-height so all cards stay the same height. Handles the PHEV dual-figure
366
+ * variant when a `phev` block is present.
367
+ */
368
+ export const EcoLine: React.FunctionComponent<EcoLineProps> = ({ car, style, t }) => {
369
+ const wrap: React.CSSProperties = {
370
+ borderTop: '1px solid var(--md-outline-variant)',
371
+ paddingTop: 8,
372
+ minHeight: 41,
373
+ fontSize: 11,
374
+ lineHeight: 1.5,
375
+ color: 'var(--md-on-surface-variant)',
376
+ ...style,
377
+ };
378
+ if (car.phev) {
379
+ const p = car.phev;
380
+ return (
381
+ <div className="eco-line" style={wrap}>
382
+ {p.consEl}{' '}
383
+ {t('autobahn:card.eco.phevConsumptionLine', {
384
+ consFuel: p.consFuel,
385
+ consDis: p.consDis,
386
+ co2w: p.co2w,
387
+ co2classW: p.co2classW,
388
+ co2classD: p.co2classD,
389
+ })}
390
+ </div>
391
+ );
392
+ }
393
+ return (
394
+ <div className="eco-line" style={wrap}>
395
+ {t('autobahn:card.eco.consumptionLine', { cons: car.cons, co2: car.co2, co2class: car.co2class })}
396
+ </div>
397
+ );
398
+ };
399
+
400
+ export interface SeoLineProps {
401
+ car: AutobahnCar;
402
+ style?: React.CSSProperties;
403
+ }
404
+
405
+ /**
406
+ * Full spec + equipment footer line (fuel, category, gearbox, colour, condition, drive
407
+ * type, then every equipment highlight) — the small gray text under the card's CTA row,
408
+ * same field/format as the legacy VehicleSmallCard's SeoText. Renders nothing without
409
+ * `car.seoText` (needs-data: only fe-landing currently populates it).
410
+ */
411
+ export const SeoLine: React.FunctionComponent<SeoLineProps> = ({ car, style }) => {
412
+ if (!car.seoText) return null;
413
+ return (
414
+ <div
415
+ style={{
416
+ fontSize: 10,
417
+ lineHeight: '14px',
418
+ color: 'var(--md-on-surface-variant)',
419
+ maxHeight: 42,
420
+ overflow: 'hidden',
421
+ ...style,
422
+ }}
423
+ >
424
+ {car.seoText}
425
+ </div>
426
+ );
427
+ };
428
+
429
+ export interface PricePathsProps {
430
+ car: AutobahnCar;
431
+ t: TranslationFunction;
432
+ /** extra class appended to the root (e.g. the SRP card's desktop-only `hide-mobile` marker). */
433
+ className?: string;
434
+ /** takes over the financing/leasing terms rows' own "Details" links — e.g. navigate to this
435
+ * car's VDP and open its finance modal already expanded, on the tab the link was under
436
+ * (financing/leasing). Optional/page-owned like CarCard's onShowFinancingDetails; when
437
+ * omitted the links render as plain (non-interactive) text, same as before this prop existed. */
438
+ onShowDetails?: (mode: PaymentMode) => void;
439
+ }
440
+
441
+ /** Map the AutobahnCar rating tone → meter segment index (0 best … 4 worst). */
442
+ const TONE_TO_TIER: Record<string, number> = { top: 0, good: 1, fair: 2, raised: 3, high: 4 };
443
+
444
+ /**
445
+ * Discrete Preisbewertung tier bar + thumb (Figma: 5 solid segments — green/light-green/yellow/
446
+ * orange/red — with a white circular marker at the car's position, same `.fin-eval-bar`/
447
+ * `.fin-eval-seg` segmented treatment the grid CarCard's PriceEvalCol/EvalBar already uses; no
448
+ * text label here since the tier is already named by the StatChip pill next to the price).
449
+ * Renders nothing when there is no rating/band (needs-data: we never draw a fake market position).
450
+ */
451
+ export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car }) => {
452
+ const hasMarket =
453
+ car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
454
+ const bar = (tier: number) => {
455
+ const leftPct = Math.max(4, Math.min(96, (tier / 4) * 100));
456
+ const tierIndex = Math.max(0, Math.min(4, Math.round(tier)));
457
+ return (
458
+ <div className="fin-eval-bar">
459
+ {TIER_COLORS.map((c, i) => (
460
+ <span key={i} className="fin-eval-seg" style={{ background: c }} />
461
+ ))}
462
+ <div
463
+ className={`fin-eval-thumb${TIER_KEYS[tierIndex] === 'good' ? ' fin-eval-thumb--good' : ''}`}
464
+ style={{ left: `${leftPct}%`, borderColor: TIER_COLORS[tierIndex] }}
465
+ />
466
+ </div>
467
+ );
468
+ };
469
+ if (hasMarket) {
470
+ const mpos = Math.max(0, Math.min(1, (car.price - car.marketLow!) / (car.marketHigh! - car.marketLow!)));
471
+ return bar(mpos * 4);
472
+ }
473
+ if (car.rating && TONE_TO_TIER[car.rating] != null) {
474
+ // No market BAND yet, but the real Preisbewertung tier (same signal as the rating chip)
475
+ // drives the thumb position. Real data, not faked.
476
+ return bar(TONE_TO_TIER[car.rating]);
477
+ }
478
+ return null;
479
+ };
480
+
481
+ /**
482
+ * Preisbewertung pill + segmented tier bar, grouped in one column exactly like the VDP
483
+ * finance-calculator's mobile .fin-eval-col (FinanceCalculator.tsx/EvalBar) — the grid card's
484
+ * replacement for the old StatChip pill + full-width gradient .pp-bar pairing. Renders nothing
485
+ * without a rating (needs-data: never invent a tier).
486
+ */
487
+ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car, t }) => {
488
+ const tier = car.rating ? TONE_TO_TIER[car.rating] : undefined;
489
+ if (tier == null) return null;
490
+ const hasMarket =
491
+ car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
492
+ // same continuous market-position math as PriceMeter's knob, reused as EvalBar's leftPct override.
493
+ const leftPct = hasMarket
494
+ ? Math.max(4, Math.min(96, ((car.price - car.marketLow!) / (car.marketHigh! - car.marketLow!)) * 100))
495
+ : undefined;
496
+ const isGood = TIER_KEYS[tier] === 'good';
497
+ // each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
498
+ // collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
499
+ const tierLabel = t('autobahn:tier.' + car.rating);
500
+ // 'good' collapses onto the 'top' tier's own color too (#168a45), matching the fixed
501
+ // "Top-Preis" text above rather than tier 1's lighter TIER_COLORS[1] green.
502
+ const pillColor = isGood ? TIER_COLORS[0] : TIER_COLORS[tier];
503
+ return (
504
+ <div className="fin-eval-col">
505
+ <div className="fin-eval-pill-cell">
506
+ <span
507
+ className={`fin-eval-pill${isGood ? ' fin-eval-pill--good' : ''}`}
508
+ style={{ color: pillColor, background: `color-mix(in srgb, ${pillColor} 16%, transparent)` }}
509
+ aria-label={t('autobahn:finance.priceRatingAria', { rating: tierLabel })}
510
+ >
511
+ {tierLabel}
512
+ {isGood && <sup>4</sup>}
513
+ </span>
514
+ </div>
515
+ <div className="fin-eval-bar-cell">
516
+ <EvalBar tier={tier} leftPct={leftPct} />
517
+ </div>
518
+ </div>
519
+ );
520
+ };
521
+
522
+ export type PaymentMode = 'financing' | 'leasing' | 'buy';
523
+
524
+ export interface PriceTabsProps {
525
+ car: AutobahnCar;
526
+ mode: PaymentMode;
527
+ onModeChange: (mode: PaymentMode) => void;
528
+ t: TranslationFunction;
529
+ /** extra class appended to the root (e.g. the SRP card's mobile-only `show-mobile` marker). */
530
+ className?: string;
531
+ }
532
+
533
+ /**
534
+ * Finanzierung / Leasing / Kaufen tab row — reuses the exact `.fin-tabs`/`.fin-tab` classes
535
+ * the VDP's FinanceCalculator already renders (md3.css), so the card's tabs are visually
536
+ * identical to the VDP's, not a second tab style. Leasing tab omitted when the car isn't
537
+ * leasing-eligible (car.lease undefined) — same rule PricePaths already used.
538
+ */
539
+ export const PriceTabs: React.FunctionComponent<PriceTabsProps> = ({ car, mode, onModeChange, t, className }) => {
540
+ const tabs: Array<[PaymentMode, string]> = [
541
+ ['financing', t('autobahn:finance.mode.financing')],
542
+ ...(car.lease != null ? ([['leasing', t('autobahn:finance.mode.leasing')]] as Array<[PaymentMode, string]>) : []),
543
+ ['buy', t('autobahn:card.price.buy')],
544
+ ];
545
+ return (
546
+ <div className={'fin-tabs' + (className ? ' ' + className : '')} role="tablist" onClick={(e) => e.stopPropagation()}>
547
+ {tabs.map(([m, label]) => (
548
+ <button
549
+ key={m}
550
+ type="button"
551
+ role="tab"
552
+ aria-selected={mode === m}
553
+ className={'fin-tab' + (mode === m ? ' on' : '')}
554
+ onClick={() => onModeChange(m)}
555
+ >
556
+ {label}
557
+ </button>
558
+ ))}
559
+ </div>
560
+ );
561
+ };
562
+
563
+ export interface PriceHeroProps {
564
+ car: AutobahnCar;
565
+ mode: PaymentMode;
566
+ t: TranslationFunction;
567
+ /** opt-in: render the "/mtl." unit next to the rate even without a struck old price to caption
568
+ * (default false keeps every existing caller's behavior — the unit only ever showed alongside
569
+ * the UVP-Rate/old-price group). The SRP desktop card wants the unit on every financing/leasing
570
+ * rate, discounted or not. */
571
+ alwaysShowUnit?: boolean;
572
+ }
573
+
574
+ /** footnote badge + click-to-open popover, shared by the Finanzierung/Leasing "UVP-Rate" (³) and
575
+ * Kaufen "Hersteller-UVP" (²) captions on the hero price — same circle/popover, different digit
576
+ * and body copy. */
577
+ const UvpBadge: React.FunctionComponent<{
578
+ n: number;
579
+ open: boolean;
580
+ onToggle: () => void;
581
+ onClose: () => void;
582
+ body: string;
583
+ closeLabel: string;
584
+ }> = ({ n, open, onToggle, onClose, body, closeLabel }) => (
585
+ <>
586
+ <span
587
+ className="pp-eyebrow-badge"
588
+ role="button"
589
+ tabIndex={0}
590
+ onClick={(e) => {
591
+ e.stopPropagation();
592
+ onToggle();
593
+ }}
594
+ >
595
+ {n}
596
+ </span>
597
+ {open && (
598
+ <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
599
+ <button
600
+ type="button"
601
+ className="pp-uvp-tooltip-close"
602
+ aria-label={closeLabel}
603
+ onClick={(e) => {
604
+ e.stopPropagation();
605
+ onClose();
606
+ }}
607
+ >
608
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
609
+ <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
610
+ </svg>
611
+ </button>
612
+ <div className="pp-uvp-tooltip-body">{body}</div>
613
+ </div>
614
+ )}
615
+ </>
616
+ );
617
+
618
+ /**
619
+ * Hero price for the active tab — Finanzierung/Leasing show a monthly rate ("z.B. … €/mtl.")
620
+ * with its own real struck-through old rate (getFinancing/getLeasing `oldMonthlyInstallment`,
621
+ * same isStrikeShown gate as everywhere else); Kaufen shows the flat purchase price struck
622
+ * against the real list price (car.listPrice, already used elsewhere on the card). The
623
+ * superscript footnote markers (¹ price, ² struck reference, ³ "/mtl.") match the Figma card —
624
+ * their legal text lives in the page's own footnote block, not duplicated per-card.
625
+ */
626
+ export const PriceHero: React.FunctionComponent<PriceHeroProps> = ({ car, mode, t, alwaysShowUnit }) => {
627
+ const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
628
+ const isMoney = mode === 'buy';
629
+ const value = mode === 'financing' ? car.monthly : mode === 'leasing' ? (car.lease as number) : car.price;
630
+ const oldValue = mode === 'financing' ? car.oldMonthly : mode === 'leasing' ? car.oldLease : car.listPrice;
631
+ const showOld = oldValue != null && oldValue > value;
632
+ // shrink the 65px hero rate for long values (e.g. 1.234 €) so it doesn't overflow the card —
633
+ // same digit-length technique as FinanceCalculator's own fin-rate-hero--len4/--len5/--len6.
634
+ const rateDigits = !isMoney ? String(Math.round(value)).length : 0;
635
+ const rateLenClass =
636
+ rateDigits >= 6 ? ' pp-hero-val--len6' : rateDigits === 5 ? ' pp-hero-val--len5' : rateDigits === 4 ? ' pp-hero-val--len4' : '';
637
+ // Kaufen: 6/7-digit purchase prices (e.g. 113.249 € / 1.553.249 €) shrink on desktop only —
638
+ // separate from the financing/leasing --len6 above since the desktop Kaufen sizes don't match
639
+ // the shared rate-based scale.
640
+ const buyDigits = isMoney ? String(Math.round(value)).length : 0;
641
+ const buyLen6Class = buyDigits >= 7 ? ' pp-hero-val--buy-len7' : buyDigits === 6 ? ' pp-hero-val--buy-len6' : '';
642
+ const oldDigits = showOld ? String(Math.round(oldValue as number)).length : 0;
643
+ const oldLenClass = oldDigits === 5 ? ' pp-hero-old--len5' : oldDigits === 4 ? ' pp-hero-old--len4' : '';
644
+ // ADV-423: the "UVP" label shrinks together with the struck price it captions
645
+ const uvpLenClass = oldDigits === 5 ? ' pp-uvp-label--len5' : oldDigits === 4 ? ' pp-uvp-label--len4' : '';
646
+ return (
647
+ <div className={'pp-hero' + (isMoney ? ' pp-hero--buy' : '')}>
648
+ <div className="pp-hero-rate">
649
+ <b className={'num pp-hero-val' + rateLenClass + buyLen6Class}>
650
+ {isMoney ? value.toLocaleString('de-DE') : fmtRate(value)} €{isMoney && <sup>1</sup>}
651
+ </b>
652
+ {/* z.B./old-rate/unit grouped in one stacked column beside the hero figure — mirrors
653
+ the VDP finance-calculator's .fin-rate-unit layout (FinanceCalculator.tsx) exactly.
654
+ Only shown when there's a real old price to strike through — without a discount the
655
+ eyebrow/unit have nothing to caption, so the whole group stays hidden. */}
656
+ {!isMoney && showOld && (
657
+ <span className="pp-hero-unit-group">
658
+ {/* a real (not display:contents) flex-column box, matching .pp-hero-unit-group's own
659
+ column layout exactly — so the click target covers the full area INCLUDING the
660
+ gap between the two stacked lines, not just their text glyphs (display:contents
661
+ has no box of its own there, so clicks in that gap fell through to the card link
662
+ behind it instead of opening the tooltip). stopPropagation is required here too —
663
+ the whole card (CarCard.tsx) has its own onClick={() => onOpen(car)} navigation,
664
+ so without it a click on this block both opened the tooltip AND navigated away. */}
665
+ <span
666
+ style={{ display: 'flex', flexDirection: 'column' }}
667
+ role="button"
668
+ tabIndex={0}
669
+ onClick={(e) => {
670
+ e.stopPropagation();
671
+ setUvpTooltipOpen((v) => !v);
672
+ }}
673
+ >
674
+ <span className="pp-eyebrow">
675
+ {t('autobahn:card.price.uvpRateLabel')}
676
+ <UvpBadge
677
+ n={3}
678
+ open={uvpTooltipOpen}
679
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
680
+ onClose={() => setUvpTooltipOpen(false)}
681
+ closeLabel={t('autobahn:modal.close')}
682
+ body={t(
683
+ mode === 'leasing'
684
+ ? 'autobahn:card.price.uvpRateTooltipBodyLeasing'
685
+ : 'autobahn:card.price.uvpRateTooltipBody',
686
+ )}
687
+ />
688
+ </span>
689
+ <span className={'pp-hero-old' + oldLenClass}>{Math.round(oldValue as number).toLocaleString('de-DE')} €</span>
690
+ </span>
691
+ <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>
692
+ </span>
693
+ )}
694
+ {/* opt-in (alwaysShowUnit): no discount to caption, so just the plain unit next to the
695
+ rate instead of the full UVP-Rate/old-price group — existing callers that don't pass
696
+ this prop keep showing nothing here, exactly as before. */}
697
+ {!isMoney && !showOld && alwaysShowUnit && <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>}
698
+ {/* Kaufen: no rate/unit to caption, just the real list price struck through — same
699
+ car.listPrice already used by DropChip/PpRow. */}
700
+ {isMoney && showOld && (
701
+ <span className="pp-hero-unit-group">
702
+ {/* ADV-423: "UVP" label right before the struck list price, same size as that price
703
+ (md3.css); same tooltip toggle as the price itself. */}
704
+ <span
705
+ className={'pp-uvp-label' + uvpLenClass}
706
+ onClick={(e) => {
707
+ e.stopPropagation();
708
+ setUvpTooltipOpen((v) => !v);
709
+ }}
710
+ >
711
+ {t('autobahn:finance.uvp')}
712
+ </span>
713
+ <span
714
+ className={'pp-hero-old' + oldLenClass}
715
+ role="button"
716
+ tabIndex={0}
717
+ onClick={(e) => {
718
+ e.stopPropagation();
719
+ setUvpTooltipOpen((v) => !v);
720
+ }}
721
+ >
722
+ {Math.round(oldValue as number).toLocaleString('de-DE')} €
723
+ <UvpBadge
724
+ n={2}
725
+ open={uvpTooltipOpen}
726
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
727
+ onClose={() => setUvpTooltipOpen(false)}
728
+ closeLabel={t('autobahn:modal.close')}
729
+ body={t('autobahn:card.price.uvpListTooltipBody')}
730
+ />
731
+ </span>
732
+ </span>
733
+ )}
734
+ </div>
735
+ </div>
736
+ );
737
+ };
738
+
739
+ /**
740
+ * Financing/leasing terms line ("0 € Anzahlung · 48 Monate Laufzeit" / "0 € Sonderzahlung ·
741
+ * 48 Mon. · 10.000 km/Jahr") + a "Finanzierungsdetails"/"Details" link, full-width under the
742
+ * price/rating row — same real per-car (falling back to the default config) figures as
743
+ * PricePaths' own terms line, just also wired to the page's rate-adjust sheet. Renders nothing
744
+ * for the Kaufen tab (a cash purchase has no financing terms) or when neither a terms line nor
745
+ * a details link end up with anything real to show.
746
+ */
747
+ export const PriceTerms: React.FunctionComponent<{
748
+ car: AutobahnCar;
749
+ mode: PaymentMode;
750
+ onOpenRateAdjust?: (mode: PaymentMode) => void;
751
+ /** takes over the "Finanzierungsdetails"/"Details" link's click (e.g. navigate to the VDP and
752
+ * open the finance modal already expanded, scrolled to the breakdown) — when given, it wins
753
+ * over onOpenRateAdjust for THIS link only; the mobile CTA row's own "Rate anpassen" button
754
+ * keeps using onOpenRateAdjust regardless. */
755
+ onShowDetails?: () => void;
756
+ t: TranslationFunction;
757
+ }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
758
+ // Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
759
+ // here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
760
+ // real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
761
+ // every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
762
+ // FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
763
+ if (mode === 'buy') return <div className="cc-terms" />;
764
+ const finFirstInstallment =
765
+ car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
766
+ const finMonths = car.finMonths ?? _finMonths;
767
+ const leasFirstInstallment =
768
+ car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
769
+ const leasMileage = car.leaseMileage ?? _leasMileage;
770
+ const leasMonths = car.leaseMonths ?? _leasPeriod;
771
+ const hasLeasTerms = Boolean(leasMileage && leasMonths);
772
+ const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
773
+ const termsText =
774
+ mode === 'leasing'
775
+ ? hasLeasTerms
776
+ ? t('autobahn:card.price.leaseTerms', { firstInstallment: leasFirstInstallment, months: leasMonths, mileage: leasMileageStr })
777
+ : ''
778
+ : t('autobahn:card.price.financeTerms', { firstInstallment: finFirstInstallment, months: finMonths, count: finMonths });
779
+ if (!termsText && !onOpenRateAdjust && !onShowDetails) return null;
780
+ const detailsLabel = mode === 'leasing' ? t('autobahn:card.price.detailsLink') : t('autobahn:modal.financingDetails');
781
+ const detailsButton =
782
+ onOpenRateAdjust || onShowDetails ? (
783
+ <button
784
+ type="button"
785
+ className="cc-terms-link"
786
+ onClick={(e) => {
787
+ e.stopPropagation();
788
+ if (onShowDetails) onShowDetails();
789
+ else onOpenRateAdjust!(mode);
790
+ }}
791
+ >
792
+ {detailsLabel}
793
+ </button>
794
+ ) : null;
795
+ // ADV-405 follow-up (PM 19.11): on the Finanzierung tab the conditions line under the rate shows
796
+ // the financing key figures instead ("60 Mon. · … Nettokredit · Gesamtbetrag: …" / "… Sollzins
797
+ // fest · … eff. Jahreszins · Finanzierungsdetails"), inside the same .cc-terms so its 12px
798
+ // #0e2238 typography applies; the block grows to 2+ lines (the stack cell takes the tallest
799
+ // slot). Leasing keeps its line; with no real figure the old financing terms line stays.
800
+ // Leasing (19.11): the leasing key figures the same way ("0 € Anzahlung · 60 Mon. · … € Barpreis ·
801
+ // … € Gesamtbetrag" / "Kaufpflicht · … Sollzins fest · … eff. Jahreszins · Details").
802
+ const kf = mode === 'leasing' ? leaseKeyFigures(car) : finKeyFigures(car);
803
+ if (car.lease != null && hasCreditKeyFigures(kf) && mode === 'leasing') {
804
+ return (
805
+ <div className="cc-terms">
806
+ <CreditKeyFigures t={t} figures={kf} details={detailsButton || undefined} cls="cc-ckf" />
807
+ </div>
808
+ );
809
+ }
810
+ if (mode === 'financing' && hasCreditKeyFigures(kf)) {
811
+ return (
812
+ <div className="cc-terms">
813
+ <CreditKeyFigures t={t} figures={kf} details={detailsButton || undefined} cls="cc-ckf" />
814
+ </div>
815
+ );
816
+ }
817
+ // split on the translation's own ' · ' separator so the dot can be styled lighter than the
818
+ // two figures around it (same literal separator convention as FinanceCalculator's condParts).
819
+ const termsParts = termsText ? termsText.split(' · ') : [];
820
+ return (
821
+ <div className="cc-terms">
822
+ {termsParts.map((part, i) => (
823
+ <React.Fragment key={i}>
824
+ {i > 0 && <span className="cc-terms-dot"> · </span>}
825
+ {part}
826
+ </React.Fragment>
827
+ ))}
828
+ {detailsButton && (
829
+ <>
830
+ {termsText && <span className="cc-terms-dot"> · </span>}
831
+ {detailsButton}
832
+ </>
833
+ )}
834
+ </div>
835
+ );
836
+ };
837
+
838
+ // Same real sales number VehicleDetailedNextPage.tsx (VDP) already dials via its own onCall —
839
+ // duplicated here (not imported) because that page doesn't export it; both should eventually
840
+ // read from one shared constant.
841
+ export const DEALER_SALES_PHONE = '0800 40 30 182';
842
+
843
+ /** default onCall — dials the real sales number directly, same tel: pattern VDP uses. */
844
+ export function callDealerSalesPhone(): void {
845
+ if (typeof window !== 'undefined') window.location.href = `tel:${DEALER_SALES_PHONE.replace(/\s/g, '')}`;
846
+ }
847
+
848
+ export interface CardCtaRowProps {
849
+ car: AutobahnCar;
850
+ /** which payment tab is currently active on the card — forwarded to onOpenRateAdjust so the
851
+ * sheet opens on the SAME tab the user was looking at (the tab itself is CarCard-internal
852
+ * state, so this is the only way the page learns it). */
853
+ mode: PaymentMode;
854
+ /** primary CTA — mirrors FinanceCalculator's onSecure ("Angebot anfragen"). */
855
+ onRequestOffer: () => void;
856
+ /** phone CTA — mirrors FinanceCalculator's onCall. */
857
+ onCall: () => void;
858
+ /**
859
+ * opens the SAME "Rate anpassen" bottom-sheet FinanceDetailsModal already used on VDP mobile
860
+ * (VdpModules.tsx) — the page mounts one shared modal instance and passes this car's data,
861
+ * this button never builds its own sheet.
862
+ */
863
+ onOpenRateAdjust: (mode: PaymentMode) => void;
864
+ t: TranslationFunction;
865
+ }
866
+
867
+ /**
868
+ * Mobile-only 3-button CTA row (Figma: Angebot anfragen / phone / Rate anpassen). Desktop card
869
+ * has no CTA row at all (confirmed: mobile-only, per explicit user correction). "Rate anpassen"
870
+ * keeps its text label — only the phone button is icon-only, matching the mockup.
871
+ */
872
+ export const CardCtaRow: React.FunctionComponent<CardCtaRowProps> = ({ car, mode, onRequestOffer, onCall, onOpenRateAdjust, t }) => (
873
+ <div
874
+ className="card-cta-row show-mobile"
875
+ style={{ display: 'flex', gap: 6, borderTop: '1px solid var(--md-outline-variant)', paddingTop: 8 }}
876
+ >
877
+ <Button
878
+ variant="filled"
879
+ style={{
880
+ // Figma width (157px) as a STARTING size, not a hard fixed one — flex-grow:1 so this
881
+ // button (and "Adjust rate" below) still fill extra row width on wider cards instead of
882
+ // leaving dead space next to the fixed 40px phone button; flex-shrink:1 lets it narrow
883
+ // gracefully (text ellipsizes via the existing .card-cta-row .mbtn overflow rule) rather
884
+ // than overflow on very narrow cards.
885
+ flex: '1 1 157px',
886
+ height: 40,
887
+ background: '#005cff',
888
+ borderRadius: 16,
889
+ padding: '0 8px',
890
+ fontFamily: 'Arial, Arimo, sans-serif',
891
+ fontStyle: 'normal',
892
+ fontWeight: 700,
893
+ fontSize: 13,
894
+ lineHeight: '15px',
895
+ color: '#ffffff',
896
+ }}
897
+ onClick={(e) => {
898
+ e.stopPropagation();
899
+ onRequestOffer();
900
+ }}
901
+ >
902
+ {/* exact design icon (single self-contained SVG) — replaces the composed lucide
903
+ file-text + check-circle badge (DocCheckIcon), which is still used as-is on VDP's own
904
+ "Angebot anfragen" buttons; this swap is scoped to the search-card CTA only.
905
+ flex:none for the same shrink reason as the "Adjust rate" icon above. */}
906
+ <svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
907
+ <path
908
+ d="M6.90625 3.65625H15.275L19.9062 8.2875V20.7188C19.9062 21.6162 19.1787 22.3438 18.2812 22.3438H6.90625C6.00879 22.3438 5.28125 21.6162 5.28125 20.7188V5.28125C5.28125 4.38379 6.00879 3.65625 6.90625 3.65625Z"
909
+ stroke="white"
910
+ strokeLinecap="round"
911
+ strokeLinejoin="round"
912
+ />
913
+ <path d="M15.0312 3.85938V8.53125H19.7031" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
914
+ <path d="M8.9375 11.375H14.625" stroke="white" strokeLinecap="round" />
915
+ <path d="M8.9375 14.625H13.4062" stroke="white" strokeLinecap="round" />
916
+ <path d="M8.9375 17.875H12.5938" stroke="white" strokeLinecap="round" />
917
+ <path
918
+ d="M18.4844 23.1562C20.8402 23.1562 22.75 21.2465 22.75 18.8906C22.75 16.5348 20.8402 14.625 18.4844 14.625C16.1285 14.625 14.2188 16.5348 14.2188 18.8906C14.2188 21.2465 16.1285 23.1562 18.4844 23.1562Z"
919
+ fill="#005CFF"
920
+ stroke="white"
921
+ />
922
+ <path d="M17.0625 18.3219L18.5656 19.825L23.7656 14.625" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
923
+ <path d="M21.6533 17.875L23.2783 16.25" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
924
+ <path d="M20.1904 17.0625L21.8154 15.4375" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
925
+ </svg>
926
+ {t('autobahn:finance.secureOffer')}
927
+ </Button>
928
+ <Button
929
+ variant="outlined"
930
+ style={{
931
+ flex: '0 0 auto',
932
+ width: 40,
933
+ height: 40,
934
+ background: '#ffffff',
935
+ border: '1.6px solid #005cff',
936
+ borderRadius: 16,
937
+ padding: 0,
938
+ }}
939
+ onClick={(e) => {
940
+ e.stopPropagation();
941
+ onCall();
942
+ }}
943
+ >
944
+ {/* exact design icon (not lucide's "phone") — no class="lucide", so the
945
+ .card-cta-row .mbtn .lucide 15px override doesn't touch it; the rect-clip from the
946
+ source SVG was a full-viewBox no-op (already inside 0-20/0-20) and dropped, since a
947
+ static clipPath id would collide across the many CarCard instances on one search page. */}
948
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
949
+ <path
950
+ d="M18.3332 14.1004V16.6004C18.3341 16.8325 18.2866 17.0622 18.1936 17.2749C18.1006 17.4875 17.9643 17.6784 17.7933 17.8353C17.6222 17.9922 17.4203 18.1116 17.2005 18.186C16.9806 18.2603 16.7477 18.288 16.5165 18.2671C13.9523 17.9881 11.4892 17.1119 9.32486 15.7087C7.31139 14.4293 5.60431 12.7222 4.32486 10.7087C2.91679 8.5346 2.04037 6.0595 1.76653 3.48374C1.7457 3.2533 1.77309 3.02104 1.84695 2.80176C1.9208 2.58248 2.03951 2.38098 2.1955 2.21009C2.3515 2.0392 2.54137 1.90266 2.75302 1.80917C2.96468 1.71569 3.19348 1.66729 3.42486 1.66707H5.92486C6.32928 1.66309 6.72136 1.80631 7.028 2.07002C7.33464 2.33373 7.53493 2.69995 7.59153 3.10041C7.69153 3.85041 7.86653 4.57541 8.11653 5.26707C8.22865 5.56534 8.25291 5.8895 8.18645 6.20114C8.11999 6.51278 7.96558 6.79883 7.74153 7.02541L6.74153 8.03374C7.95617 10.2329 9.76739 12.0441 11.9665 13.2587L12.9749 12.2587C13.2014 12.0347 13.4875 11.8803 13.7991 11.8138C14.1108 11.7474 14.4349 11.7716 14.7332 11.8837C15.4249 12.1337 16.1499 12.3087 16.8999 12.4087C17.3047 12.4658 17.6744 12.6697 17.9386 12.9817C18.2029 13.2936 18.3433 13.6917 18.3332 14.1004Z"
951
+ stroke="#005cff"
952
+ strokeWidth={1.66667}
953
+ strokeLinecap="round"
954
+ strokeLinejoin="round"
955
+ />
956
+ </svg>
957
+ </Button>
958
+ <Button
959
+ variant="outlined"
960
+ style={{
961
+ // same "starting size that can still grow/shrink" reasoning as "Request offer" above.
962
+ flex: '1 1 125px',
963
+ height: 40,
964
+ background: '#ffffff',
965
+ border: '1.6px solid #5b6b7f',
966
+ borderRadius: 16,
967
+ padding: '0 6px',
968
+ fontFamily: 'Arial, Arimo, sans-serif',
969
+ fontStyle: 'normal',
970
+ fontWeight: 700,
971
+ fontSize: 13,
972
+ lineHeight: '15px',
973
+ color: '#5b6b7f',
974
+ }}
975
+ onClick={(e) => {
976
+ e.stopPropagation();
977
+ onOpenRateAdjust(mode);
978
+ }}
979
+ >
980
+ {/* exact design icon (not lucide's "sliders-horizontal") — colors are baked into the SVG
981
+ itself (matches the button's #5b6b7f border/text), not currentColor. flex:none is
982
+ load-bearing: this button is a flex row (icon + the "Adjust rate" label) inside a fixed
983
+ 125px width, and without it the icon was a shrinkable flex item — flexbox squeezed its
984
+ WIDTH down to fit the text (rendering ~12.94x18, squashed) while its literal height
985
+ attribute stayed 18. Lucide icons here dodge this via the unrelated .card-cta-row .mbtn
986
+ .lucide CSS rule (flex: none), which doesn't match a plain <svg> with no lucide class. */}
987
+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
988
+ <path d="M3 5.25H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
989
+ <path
990
+ d="M6 6.75C6.82843 6.75 7.5 6.07843 7.5 5.25C7.5 4.42157 6.82843 3.75 6 3.75C5.17157 3.75 4.5 4.42157 4.5 5.25C4.5 6.07843 5.17157 6.75 6 6.75Z"
991
+ fill="#FFFEFE"
992
+ stroke="#5B6B7F"
993
+ strokeLinecap="round"
994
+ strokeLinejoin="round"
995
+ />
996
+ <path d="M3 9H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
997
+ <path
998
+ d="M12.4565 10.5C13.285 10.5 13.9565 9.82843 13.9565 9C13.9565 8.17157 13.285 7.5 12.4565 7.5C11.6281 7.5 10.9565 8.17157 10.9565 9C10.9565 9.82843 11.6281 10.5 12.4565 10.5Z"
999
+ fill="white"
1000
+ stroke="#5B6B7F"
1001
+ strokeLinecap="round"
1002
+ strokeLinejoin="round"
1003
+ />
1004
+ <path d="M3 12.75H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
1005
+ <path
1006
+ d="M9.81543 14.25C10.6439 14.25 11.3154 13.5784 11.3154 12.75C11.3154 11.9216 10.6439 11.25 9.81543 11.25C8.987 11.25 8.31543 11.9216 8.31543 12.75C8.31543 13.5784 8.987 14.25 9.81543 14.25Z"
1007
+ fill="white"
1008
+ stroke="#5B6B7F"
1009
+ strokeLinecap="round"
1010
+ strokeLinejoin="round"
1011
+ />
1012
+ </svg>
1013
+ {t('autobahn:finance.adjustRate')}
1014
+ </Button>
1015
+ </div>
1016
+ );
1017
+
1018
+ export interface GalleryCounterProps {
1019
+ /** 1-based index of the currently shown photo. */
1020
+ current: number;
1021
+ total: number;
1022
+ /** Figma "Vehicle Gallery / Photos Button" light-pill treatment (Car Card, node 281:1016) —
1023
+ * CarRow keeps the original dark `.imglabel` pill until it gets the same design pass. */
1024
+ light?: boolean;
1025
+ /** makes the light pill a real button (opens the full VdpViewer lightbox on the grid card) —
1026
+ * the dark `.imglabel` variant stays a plain, non-interactive span either way. */
1027
+ onClick?: () => void;
1028
+ }
1029
+
1030
+ /**
1031
+ * Bottom-left gallery overlay: expand icon + "current|total" (Figma). Reuses the existing
1032
+ * `.imglabel` pill style (already used for the list-card's photo-count badge) rather than a new
1033
+ * class — same dark translucent pill, just with the maximize icon instead of the image icon.
1034
+ *
1035
+ * States (shared policy across GalleryCounter, the carousel's own arrows/dots in CardCarousel,
1036
+ * and GalleryActivityPill below — see its own doc comment for the other two):
1037
+ * - single-image: `total` is the car's REAL, eagerly-known photo count (car.photos, from the
1038
+ * search payload — not the lazily-loaded gallery array length), so this is accurate even
1039
+ * before any image beyond the first has actually loaded. total<=1 → hidden: nothing to expand
1040
+ * into. Never a "1|1" placeholder.
1041
+ * - loading: while `total` itself is still unknown (car not yet resolved) the caller simply
1042
+ * hasn't rendered this component yet — there is no separate in-between skeleton state here.
1043
+ */
1044
+ export const GalleryCounter: React.FunctionComponent<GalleryCounterProps> = ({ current, total, light, onClick }) => {
1045
+ if (total <= 1) return null;
1046
+ if (light) {
1047
+ return (
1048
+ <button type="button" className="cc-photo-pill" onClick={onClick}>
1049
+ <Icon name="maximize" size={18} stroke={2} color="#111820" />
1050
+ {current} | {total}
1051
+ </button>
1052
+ );
1053
+ }
1054
+ return (
1055
+ <span className="imglabel">
1056
+ <Icon name="maximize" size={13} stroke={2} />
1057
+ {current}|{total}
1058
+ </span>
1059
+ );
1060
+ };
1061
+
1062
+ export interface GalleryActivityPillProps {
1063
+ /** total detail-page views (stats totalCarImpCount) — real data only, never fabricated. */
1064
+ viewsCount?: number;
1065
+ /** total merkliste adds (stats totalFavCount) — real data only, never fabricated. */
1066
+ favoritesCount?: number;
1067
+ }
1068
+
1069
+ /**
1070
+ * Bottom-right gallery overlay: eye + views, heart + favorites, in ONE pill (Figma "Push Chips /
1071
+ * Likes", node 297:1037). Each half renders independently.
1072
+ *
1073
+ * States (chosen ONE policy, applied identically to both halves):
1074
+ * - loading: `viewsCount`/`favoritesCount` are `undefined` until the async stats call
1075
+ * (UserActionsAPI 'stats/viewers') resolves for this car. No skeleton — the half (or the
1076
+ * whole pill, if both are still pending) simply doesn't render yet, same "hidden, not a
1077
+ * placeholder" discipline as GalleryCounter/CardCarousel's arrows above.
1078
+ * - zero-value: a REAL `0` is treated the same as "not there" — hidden, not shown as "👁 0".
1079
+ * Deliberate choice over spelling out "0" (the other option the ticket allows): on a dense
1080
+ * grid of fresh listings a "👁 0 ❤ 0" pill on every card is noise, not signal. `!viewsCount`/
1081
+ * `!favoritesCount` below intentionally don't distinguish real-0 from not-yet-loaded — both
1082
+ * read as "nothing worth showing (yet)", which is the same outcome either way.
1083
+ */
1084
+ export const GalleryActivityPill: React.FunctionComponent<GalleryActivityPillProps> = ({ viewsCount, favoritesCount }) => {
1085
+ if (!viewsCount && !favoritesCount) return null;
1086
+ return (
1087
+ <span className="cc-activity-pill">
1088
+ {!!viewsCount && (
1089
+ <span className="cc-activity-pill-item">
1090
+ <Icon name="eye" size={16} stroke={1.9} color="#1D2A38" />
1091
+ {viewsCount}
1092
+ </span>
1093
+ )}
1094
+ {!!favoritesCount && (
1095
+ <span className="cc-activity-pill-item">
1096
+ <Icon name="heart" size={16} stroke={1.9} color="#1D2A38" />
1097
+ {favoritesCount}
1098
+ </span>
1099
+ )}
1100
+ </span>
1101
+ );
1102
+ };
1103
+
1104
+ interface PpRowProps {
1105
+ /** payment-path label (Finanzierung / Leasing / Kaufen). */
1106
+ label: string;
1107
+ /** the figure to show — a monthly rate (money=false) or a full price (money=true). */
1108
+ value: number;
1109
+ /** small unit before the figure, e.g. 'mtl.'. */
1110
+ unit?: string;
1111
+ /** real previous price to strike through (only ever the genuine list price). */
1112
+ old?: number | null;
1113
+ /** the financing row — kept visually dominant (larger). */
1114
+ focus?: boolean;
1115
+ /** format as a full euro price (Kaufen) instead of a rounded rate. */
1116
+ money?: boolean;
1117
+ t: TranslationFunction;
1118
+ }
1119
+
1120
+ /**
1121
+ * One payment-path row: label (+ a quiet info marker) on the left, the price right-aligned
1122
+ * with an optional struck-through previous price above it. Even row spacing reproduces the
1123
+ * production "Finanzierung / Leasing / Kaufen" price table the design references. The struck
1124
+ * `old` price gets the same "²" UvpBadge + click-to-open popover as PriceHero's own Kaufen
1125
+ * old-price (same n, same body/close copy) — one-to-one, not a re-styled variant.
1126
+ */
1127
+ const PpRow: React.FunctionComponent<PpRowProps> = ({ label, value, unit, old, focus, money, t }) => {
1128
+ const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
1129
+ // 5-plus-digit prices (e.g. 60.248 €) shrink to keep the row from crowding — 4-digit values
1130
+ // stay at the base size. Same digit-length technique as PriceHero's buyLen6Class.
1131
+ const valDigits = String(Math.round(value)).length;
1132
+ const valLenClass = valDigits >= 5 ? ' pp-val--len5' : '';
1133
+ return (
1134
+ <div className={'pp-row' + (focus ? ' pp-row--focus' : '')}>
1135
+ <span className="pp-row-label">
1136
+ {label}
1137
+ <Icon name="info" size={13} stroke={1.9} cls="pp-row-i" />
1138
+ </span>
1139
+ <span className="pp-row-price">
1140
+ {old != null && (
1141
+ // ADV-423: "UVP" label for the struck list price (PpRow only renders in the desktop SRL
1142
+ // column, and `old` is only ever the Kaufen list price). md3.css places it above the
1143
+ // struck amount there — the fixed-width row has no room for it inline.
1144
+ <span className="pp-uvp-strike">
1145
+ <span
1146
+ className="pp-uvp-label"
1147
+ onClick={(e) => {
1148
+ e.stopPropagation();
1149
+ setUvpTooltipOpen((v) => !v);
1150
+ }}
1151
+ >
1152
+ {t('autobahn:finance.uvp')}
1153
+ </span>
1154
+ <span
1155
+ className="pp-old"
1156
+ role="button"
1157
+ tabIndex={0}
1158
+ onClick={(e) => {
1159
+ e.stopPropagation();
1160
+ setUvpTooltipOpen((v) => !v);
1161
+ }}
1162
+ >
1163
+ {old.toLocaleString('de-DE')} €
1164
+ <UvpBadge
1165
+ n={2}
1166
+ open={uvpTooltipOpen}
1167
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
1168
+ onClose={() => setUvpTooltipOpen(false)}
1169
+ closeLabel={t('autobahn:modal.close')}
1170
+ body={t('autobahn:card.price.uvpListTooltipBody')}
1171
+ />
1172
+ </span>
1173
+ </span>
1174
+ )}
1175
+ <span className="pp-now">
1176
+ {unit && <span className="pp-unit">{unit}</span>}
1177
+ <b className={'num pp-val' + valLenClass}>
1178
+ {money ? value.toLocaleString('de-DE') : fmtRate(value)} €{money && <sup>1</sup>}
1179
+ </b>
1180
+ </span>
1181
+ </span>
1182
+ </div>
1183
+ );
1184
+ };
1185
+
1186
+ /**
1187
+ * Monthly-rate payment paths (SRP price column, TOP group) — modelled on the legacy design:
1188
+ * Finanzierung is the hero (eyebrow + big blue rate + its terms line), which both keeps the
1189
+ * financing focus and FILLS the upper gap with real default-config info (Anzahlung · Laufzeit).
1190
+ * Leasing follows as a quiet neutral row (with its own terms when the config carries them) and
1191
+ * is omitted entirely when leasing isn't active. The Kaufen row is rendered separately
1192
+ * (PriceKauf) below a divider so only the financing rate stands out — no wall of blue prices.
1193
+ */
1194
+ export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t, className, onShowDetails }) => {
1195
+ const hasLease = car.lease != null;
1196
+ // Terms of the config the displayed rate was actually computed with (per-car:
1197
+ // dealer rate + the user's saved localStorage adjustments) — default config
1198
+ // terms only when the car doesn't carry its own.
1199
+ const finFirstInstallment =
1200
+ car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
1201
+ const finMonths = car.finMonths ?? _finMonths;
1202
+ const finKf = finKeyFigures(car);
1203
+ const leaseKf = leaseKeyFigures(car);
1204
+ const leasFirstInstallment =
1205
+ car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
1206
+ const leasMileage = car.leaseMileage ?? _leasMileage;
1207
+ const leasMonths = car.leaseMonths ?? _leasPeriod;
1208
+ const hasLeasTerms = Boolean(leasMileage && leasMonths);
1209
+ const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
1210
+ const detailsLink = (mode: PaymentMode): React.ReactNode =>
1211
+ onShowDetails ? (
1212
+ <button
1213
+ type="button"
1214
+ className="pp-details-link"
1215
+ onClick={(e) => {
1216
+ e.stopPropagation();
1217
+ onShowDetails(mode);
1218
+ }}
1219
+ >
1220
+ {t('autobahn:card.price.details')}
1221
+ </button>
1222
+ ) : (
1223
+ <span className="pp-details-link">{t('autobahn:card.price.details')}</span>
1224
+ );
1225
+ return (
1226
+ <div className={'pricepaths' + (className ? ' ' + className : '')}>
1227
+ <div className="pp-eyebrow">{t('autobahn:card.price.financingFrom')}</div>
1228
+ {/* reuses PriceHero's own financing rendering — the exact same stacked "UVP-Rate ⓘ /
1229
+ struck price / mtl." group beside the rate that .cc-price and mobile's tab switcher
1230
+ already use, so the rate + unit never fight for room in one flat row (the earlier
1231
+ hand-rolled version here put them side by side and wrapped for any 4+-digit rate). */}
1232
+ <PriceHero car={car} mode="financing" t={t} alwaysShowUnit />
1233
+ <div className="pp-hero-terms">
1234
+ {/* ADV-405 follow-up (PM 19.11): the financing key figures replace the "Anzahlung ·
1235
+ Laufzeit" terms here (.pp-hero-terms colour) in exactly two lines, the font fitted to
1236
+ the narrow column (client call 19.11: "2 lines, the font size doesn't matter"); without
1237
+ any real figure the old terms line stays. */}
1238
+ {hasCreditKeyFigures(finKf) ? (
1239
+ <CreditKeyFigures t={t} figures={finKf} details={detailsLink('financing')} cls="pp-ckf" />
1240
+ ) : (
1241
+ <>
1242
+ {t('autobahn:card.price.financeTerms', {
1243
+ firstInstallment: finFirstInstallment,
1244
+ months: finMonths,
1245
+ count: finMonths,
1246
+ })}{' '}
1247
+ · {detailsLink('financing')}
1248
+ </>
1249
+ )}
1250
+ </div>
1251
+ {/* ADV-405/408/411 Kreditkosten-Hinweis: one per card, under the financing conditions and
1252
+ above the Leasing row. Financing is always shown in this column, so it is unconditional. */}
1253
+ <CreditCostNotice t={t} size="small" cls="pp-ccn" />
1254
+ {hasLease && (
1255
+ <div className="pp-lease-row">
1256
+ <PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." t={t} />
1257
+ {/* ADV-405 follow-up (leasing, 19.11): the leasing key figures replace the compact
1258
+ terms — exactly two lines like everywhere else (client call 19.11: "2 lines, the font
1259
+ size doesn't matter"), the font fitted to the column; without any real figure the
1260
+ old terms stay. */}
1261
+ {hasCreditKeyFigures(leaseKf) ? (
1262
+ <div className="pp-sub-terms">
1263
+ <CreditKeyFigures t={t} figures={leaseKf} details={detailsLink('leasing')} cls="pp-ckf" />
1264
+ </div>
1265
+ ) : hasLeasTerms && (
1266
+ <div className="pp-sub-terms">
1267
+ {/* dedicated keys (not a rework of leaseTerms) so mobile/VDP's own reviewed
1268
+ wording there stays untouched, but includes the same Sonderzahlung figure.
1269
+ Split across two lines with an explicit <br/> (column is too narrow for all
1270
+ three figures + Details on one line) — forced right after km/Jahr so "36" and
1271
+ "Mon." always land on the same line instead of an awkward mid-number wrap. */}
1272
+ {t('autobahn:card.price.leaseTermsCompactLine1', {
1273
+ firstInstallment: leasFirstInstallment,
1274
+ mileage: leasMileageStr,
1275
+ })}{' · '}
1276
+ <br />
1277
+ {t('autobahn:card.price.leaseTermsCompactLine2', { months: leasMonths })}{' '}
1278
+ · {detailsLink('leasing')}
1279
+ </div>
1280
+ )}
1281
+ </div>
1282
+ )}
1283
+ </div>
1284
+ );
1285
+ };
1286
+
1287
+ /**
1288
+ * Kaufen (outright purchase) row — the BOTTOM group, separated from the monthly-rate paths by a
1289
+ * divider. Quiet/neutral (not blue) and strikes the previous price only on a real list-price
1290
+ * saving (never a fabricated "was" price).
1291
+ */
1292
+ export const PriceKauf: React.FunctionComponent<PricePathsProps> = ({ car, t }) => {
1293
+ const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
1294
+ return (
1295
+ <PpRow label={t('autobahn:card.price.buy')} value={car.price} old={showStrike ? (car.listPrice as number) : null} money t={t} />
1296
+ );
1297
+ };
1298
+
1299
+ export interface PpActivityProps {
1300
+ car: AutobahnCar;
1301
+ t: TranslationFunction;
1302
+ }
1303
+
1304
+ /**
1305
+ * Buyer-activity cue rendered below the CTA in the listing card.
1306
+ *
1307
+ * NEEDS-DATA: needs watchers + views. When either is missing we show the
1308
+ * 'Daten folgt' marker instead of inventing interest figures.
1309
+ */
1310
+ export const PpActivity: React.FunctionComponent<PpActivityProps> = ({ car, t }) => {
1311
+ // No real watcher/view data (no backend yet) → render nothing rather than a "Daten folgt"
1312
+ // placeholder that reads as perpetual loading. Wire when UserActionsAPI stats are available.
1313
+ if (car.watchers == null || car.views == null) return null;
1314
+ const hrs = 1 + (car.views % 6);
1315
+ return (
1316
+ <div className="pp-activity">
1317
+ <Icon name="eye" size={12} stroke={1.9} />
1318
+ {t('autobahn:card.activity.watchers', { watchers: car.watchers, hrs, count: car.watchers })}
1319
+ </div>
1320
+ );
1321
+ };
1322
+
1323
+ export interface GalleryBadgesProps {
1324
+ car: AutobahnCar;
1325
+ t: TranslationFunction;
1326
+ }
1327
+
1328
+ /**
1329
+ * Trust/activity badges overlaid on the photo itself, bottom-right (PM reference, 2026-07-10),
1330
+ * Figma pill styling (border/radius/height — see .gallery-pill in md3.css). Mirrors the mobile
1331
+ * VDP gallery header (availability · views · favorites · Geprüft).
1332
+ *
1333
+ * Each pill is independent, not all-or-nothing: a missing or zero view/favorite count just omits
1334
+ * THAT pill (never shown as "0×") — availability and Geprüft still render on their own terms.
1335
+ * .gallery-badges is anchored via `right`, not `left` (md3.css), so however many pills survive
1336
+ * they stay stuck to the right edge instead of drifting to wherever the row happens to start.
1337
+ */
1338
+ export const GalleryBadges: React.FunctionComponent<GalleryBadgesProps> = ({ car, t }) => (
1339
+ <div className="gallery-badges">
1340
+ {car.availability && (
1341
+ <span className="gallery-pill">
1342
+ <Icon name="circle-check" size={15} stroke={2} color="var(--md-good)" />
1343
+ {car.availability}
1344
+ </span>
1345
+ )}
1346
+ {!!car.viewsCount && (
1347
+ <span className="gallery-pill">
1348
+ <Icon name="eye" size={15} stroke={1.9} />
1349
+ {t('autobahn:card.activity.viewsCount', { count: car.viewsCount })}
1350
+ </span>
1351
+ )}
1352
+ {!!car.favoritesCount && (
1353
+ <span className="gallery-pill">
1354
+ <Icon name="heart" size={15} stroke={1.9} />
1355
+ {t('autobahn:card.activity.favoritesCount', { count: car.favoritesCount })}
1356
+ </span>
1357
+ )}
1358
+ <span className="gallery-pill">
1359
+ <Icon name="shield-check" size={15} stroke={1.9} />
1360
+ {t('autobahn:card.trust.checked')}
1361
+ </span>
1362
+ </div>
1363
+ );