@bytebrand/fe-ui-core-autobahn 1.0.189 → 1.0.191

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.
@@ -1,1090 +1,1095 @@
1
- // Autobahn (auto.de redesign) — VDP offer / finance card (Finanzierung / Leasing /
2
- // Barzahlung).
3
- //
4
- // Structure (desktop rethink, tabs-on-top): payment-type TABS at the top (MD3 underline tabs),
5
- // then the rate (with any discount), then the "Rate anpassen" rate-editor, then the primary
6
- // "Angebot sichern" request CTA, and finally the Finanzierungs-/Leasingdetails info + popup link
7
- // at the foot. Laufzeit is chosen via chips (discrete terms), not a slider.
8
- //
9
- // CONTROLLED / PRESENTATIONAL — computes NOTHING financial: `mode`, `monthly`, `down`, `term` and
10
- // the slider/chip bounds all arrive as props; segment/slider/chip changes are reported back via
11
- // `onModeChange` / `onDownChange` / `onTermChange`. The real numbers come from `financingStore`.
12
- // The only local state is the `adjust` expander (pure view state).
13
- //
14
- // Renders correctly only inside a `<div className="md3">` subtree.
15
-
16
- import React, { useState, useEffect } from 'react';
17
- import { TranslationFunction } from '../types';
18
-
19
- import { Button, Icon, Switch } from '../ui';
20
- import { TIER_LABELS, TIER_KEYS, TIER_COLORS } from '../constants';
21
-
22
- /** Payment mode segment keys. Mirrors the design's ['fin','leasing','cash']. */
23
- export type FinanceMode = 'fin' | 'leasing' | 'cash';
24
-
25
- export interface SliderProps {
26
- min: number;
27
- max: number;
28
- step?: number;
29
- value: number;
30
- onChange: (value: number) => void;
31
- /** formats the min/max end labels (and is reused by callers for the value). */
32
- fmt?: (v: number) => React.ReactNode;
33
- /** render the current value in a floating bubble above the thumb (Figma sheet sliders). */
34
- bubble?: boolean;
35
- /** space reserved below the rail for the bubble's tail (Figma differs per sheet: fin vs leasing). */
36
- bubblePaddingBottom?: number;
37
- }
38
-
39
- /**
40
- * Range slider with a filled track and min/max end labels. The track fill is a
41
- * linear-gradient driven by the value's position; the design's `.mslider` class
42
- * styles the thumb/rail. With `bubble` the current value floats above the thumb
43
- * (mockup "Rate anpassen" sliders) instead of the caller printing it elsewhere.
44
- */
45
- export const Slider: React.FunctionComponent<SliderProps> = ({
46
- min,
47
- max,
48
- step = 1,
49
- value,
50
- onChange,
51
- fmt = (v) => v,
52
- bubble,
53
- bubblePaddingBottom = 34,
54
- }) => {
55
- // Local mirror of `value`, updated INSTANTLY on every native input event. Callers commonly
56
- // debounce their own onChange (e.g. CheckoutFinancePanelNext's 50ms setCommonUserConfig,
57
- // which also triggers a MobX-driven re-render of a much bigger subtree) — without this, the
58
- // thumb still drags natively/smoothly (the browser owns that), but the gradient fill and any
59
- // bubble label are driven by the `value` PROP, which only catches up once the debounced commit
60
- // finally lands, so the fill visibly lags/stutters behind the thumb during a fast drag. Synced
61
- // back to the prop via useEffect for externally-driven changes (e.g. a reset button).
62
- const [localValue, setLocalValue] = useState(value);
63
- useEffect(() => { setLocalValue(value); }, [value]);
64
-
65
- const span = max - min;
66
- const pct = span > 0 ? ((localValue - min) / span) * 100 : 0;
67
- return (
68
- <div>
69
- <div style={{ position: 'relative', paddingTop: bubble ? 44 : 0, paddingBottom: bubble ? bubblePaddingBottom : 0 }}>
70
- {bubble && (
71
- // thumb is 22px wide: interpolate the bubble anchor between half-thumb insets so it
72
- // tracks the thumb center (a plain pct% drifts at the rail ends)
73
- <span className="slider-bubble num" style={{ left: `calc(11px + (100% - 22px) * ${pct / 100})` }}>
74
- {fmt(localValue)}
75
- </span>
76
- )}
77
- <input
78
- type="range"
79
- className="mslider"
80
- min={min}
81
- max={max}
82
- step={step}
83
- value={localValue}
84
- onChange={(e) => {
85
- const v = Number(e.target.value);
86
- setLocalValue(v);
87
- onChange(v);
88
- }}
89
- style={{ background: `linear-gradient(90deg, var(--md-primary) ${pct}%, var(--md-sc-highest) ${pct}%)` }}
90
- />
91
- </div>
92
- {!bubble && (
93
- <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 4 }}>
94
- <span className="md-label-sm">{fmt(min)}</span>
95
- <span className="md-label-sm">{fmt(max)}</span>
96
- </div>
97
- )}
98
- </div>
99
- );
100
- };
101
-
102
- /**
103
- * Segmented price-evaluation bar (Figma: 5 discrete tier segments, NOT a gradient) with a
104
- * white ring marker. `leftPct` overrides the marker position (the Marktwert gauge positions
105
- * it continuously); default = centered on the tier segment.
106
- */
107
- export const EvalBar: React.FunctionComponent<{ tier: number; leftPct?: number }> = ({ tier, leftPct }) => (
108
- <div className="fin-eval-bar">
109
- {TIER_COLORS.map((c, i) => (
110
- <span key={i} className="fin-eval-seg" style={{ background: c }} />
111
- ))}
112
- <div
113
- className={`fin-eval-thumb${TIER_KEYS[Math.max(0, Math.min(4, tier))] === 'good' ? ' fin-eval-thumb--good' : ''}`}
114
- style={{ left: `${leftPct != null ? leftPct : (tier + 0.5) * 20}%`, borderColor: TIER_COLORS[Math.max(0, Math.min(4, tier))] }}
115
- />
116
- </div>
117
- );
118
-
119
- /** Figma CTA icon — document with a check-in-circle badge over its bottom-right corner
120
- * (no single lucide glyph matches; composed from file-text + a knocked-out check-circle).
121
- * The badge backdrop assumes a filled (primary) button. */
122
- export const DocCheckIcon: React.FunctionComponent<{ size?: number }> = ({ size = 19 }) => {
123
- // inline width/height on BOTH icons — `.mbtn .lucide { width/height: 18px }` otherwise
124
- // inflates the badge to full icon size and it swallows the document
125
- const badge = Math.max(9, Math.round(size * 0.5));
126
- return (
127
- <span style={{ position: 'relative', display: 'inline-flex', flex: 'none' }}>
128
- <Icon name="file-text" size={size} stroke={2} style={{ width: size, height: size }} />
129
- <span
130
- style={{
131
- position: 'absolute',
132
- right: -3,
133
- bottom: -2,
134
- display: 'flex',
135
- borderRadius: '50%',
136
- background: 'var(--md-primary)',
137
- padding: 1,
138
- }}
139
- >
140
- <Icon name="check-circle" size={badge} stroke={2.8} style={{ width: badge, height: badge }} />
141
- </span>
142
- </span>
143
- );
144
- };
145
-
146
- export interface TermChipsProps {
147
- /** the selectable term values (months), e.g. [12,24,36,48,60,72]. */
148
- options: number[];
149
- value: number;
150
- onChange: (term: number) => void;
151
- /** i18n function (drilled from the page). */
152
- t: TranslationFunction;
153
- }
154
-
155
- /** Laufzeit selector — discrete term values as tappable chips (replaces the fiddly slider). */
156
- export const TermChips: React.FunctionComponent<TermChipsProps> = ({ options, value, onChange, t }) => (
157
- <div className="term-chips" role="group" aria-label={t('autobahn:finance.termSelection')}>
158
- {options.map((m) => (
159
- <button
160
- key={m}
161
- type="button"
162
- aria-pressed={m === value}
163
- className={'term-chip' + (m === value ? ' on' : '')}
164
- onClick={() => onChange(m)}
165
- >
166
- {m}
167
- <span className="tc-unit">{t('autobahn:finance.monthUnit')}</span>
168
- </button>
169
- ))}
170
- </div>
171
- );
172
-
173
- export interface CalcRowProps {
174
- label: React.ReactNode;
175
- /** when true, drops the bottom hairline (last row). */
176
- last?: boolean;
177
- children?: React.ReactNode;
178
- className?: string;
179
- }
180
-
181
- /** One label/value row inside the "Rate anpassen" / "Details" expander. */
182
- export const CalcRow: React.FunctionComponent<CalcRowProps> = ({ label, last, children, className }) => (
183
- <div
184
- className={'calcrow' + (className ? ' ' + className : '')}
185
- style={{
186
- display: 'flex',
187
- justifyContent: 'space-between',
188
- alignItems: 'baseline',
189
- gap: 12,
190
- padding: '8px 0',
191
- borderBottom: last ? 0 : '1px solid var(--md-outline-variant)',
192
- }}
193
- >
194
- <span className="md-label-sm calcrow-label">{label}</span>
195
- <span className="num calcrow-value" style={{ fontSize: 13.5, fontWeight: 600 }}>
196
- {children}
197
- </span>
198
- </div>
199
- );
200
-
201
- /** full-width label(+optional trailing price) / Switch row — Switch itself is inline-flex
202
- * (track+label), so the "label ...... price switch" full-row layout can't be expressed via
203
- * Switch's `label` prop (which renders track-then-label, not a full-width justified row). */
204
- export const ToggleRow: React.FunctionComponent<{
205
- label: string;
206
- price?: string;
207
- checked: boolean;
208
- disabled?: boolean;
209
- onChange: (checked: boolean) => void;
210
- className?: string;
211
- /** cash mode: the package is always included — shows a static "inklusive" note instead of the switch. */
212
- staticNote?: string;
213
- /** when set, the info icon becomes clickable and opens a popover with this body (e.g. the
214
- * Rundum-Sorglos-Paket contents) — "Mit Schlussrate" rows omit this, keeping their icon inert. */
215
- tooltip?: React.ReactNode;
216
- /** aria-label for the popover's close button — required together with `tooltip`. */
217
- tooltipCloseLabel?: string;
218
- /** required together with `tooltip` — builds the trigger's own accessible name (see `infoLabel` below). */
219
- t?: TranslationFunction;
220
- }> = ({ label, price, checked, disabled, onChange, className, staticNote, tooltip, tooltipCloseLabel, t }) => {
221
- const [tooltipOpen, setTooltipOpen] = useState(false);
222
- const toggleTooltip = (e: { stopPropagation: () => void }) => {
223
- e.stopPropagation();
224
- setTooltipOpen((v) => !v);
225
- };
226
- // the visible label alone ("Rundum-Sorglos-Paket") reads as ambiguous out of context (toggle
227
- // the package? show info about it?) — spell out what activating the trigger actually does.
228
- const infoLabel = tooltip && t ? t('autobahn:finance.moreInfoAria', { label }) : undefined;
229
- return (
230
- <div
231
- className={className}
232
- style={{
233
- display: 'flex',
234
- alignItems: 'center',
235
- justifyContent: staticNote ? undefined : 'space-between',
236
- gap: 10,
237
- position: tooltip ? 'relative' : undefined,
238
- }}
239
- >
240
- <span className="md-title-sm" style={{ display: 'inline-flex', alignItems: 'center', gap: 5 }}>
241
- {label}
242
- {/* custom info glyph (not the shared lucide "info" from the Icon registry — that name is
243
- used in many unrelated places, this swap is scoped to just the Rundum-Sorglos-Paket
244
- tooltip trigger). Shared by all three tabs (Finanzierung/Leasing/Kaufen) and both
245
- desktop/mobile — ToggleRow itself is the one shared render for all of them. Viewbox
246
- already bounds every path (1.875–13.125 within 0–15), so no clip-path needed.
247
- The interactive/focusable/touch-target element is THIS icon wrapper only — the label
248
- text next to it is plain, inert text, not part of the trigger. */}
249
- {tooltip && (
250
- <span
251
- className="fin-toggle-info-trigger"
252
- style={{ display: 'inline-flex', cursor: 'pointer' }}
253
- role="button"
254
- tabIndex={0}
255
- aria-label={infoLabel}
256
- aria-expanded={tooltipOpen}
257
- onClick={toggleTooltip}
258
- onKeyDown={(e) => {
259
- // ARIA authoring practices: a role="button" element must answer to both Enter and
260
- // Space, not just Enter — a native <button> gets this for free, this span doesn't.
261
- if (e.key === 'Enter' || e.key === ' ') {
262
- e.preventDefault();
263
- toggleTooltip(e);
264
- }
265
- }}
266
- >
267
- <svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" className="lucide">
268
- <path d="M7.5 13.125C10.6066 13.125 13.125 10.6066 13.125 7.5C13.125 4.3934 10.6066 1.875 7.5 1.875C4.3934 1.875 1.875 4.3934 1.875 7.5C1.875 10.6066 4.3934 13.125 7.5 13.125Z" stroke="#8B98AA" strokeWidth={1.8} />
269
- <path d="M7.5 7.2V10.5125" stroke="#8B98AA" strokeWidth={1.8} strokeLinecap="round" />
270
- <path d="M7.5 4.8125H7.50625" stroke="#8B98AA" strokeWidth={2.4} strokeLinecap="round" />
271
- </svg>
272
- </span>
273
- )}
274
- </span>
275
- {tooltip && tooltipOpen && (
276
- <div className="pp-uvp-tooltip fin-toggle-tooltip" onClick={(e) => e.stopPropagation()}>
277
- <button
278
- type="button"
279
- className="pp-uvp-tooltip-close fin-toggle-tooltip-close"
280
- aria-label={tooltipCloseLabel}
281
- onClick={(e) => {
282
- e.stopPropagation();
283
- setTooltipOpen(false);
284
- }}
285
- >
286
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
287
- <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
288
- </svg>
289
- </button>
290
- <div className="pp-uvp-tooltip-body fin-toggle-tooltip-body">{tooltip}</div>
291
- </div>
292
- )}
293
- <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginLeft: staticNote ? 'auto' : undefined }}>
294
- {/* staticNote (cash mode: package is always included, price already baked into the
295
- fixed price above) fully replaces the price+switch pair — showing "+1.499 €" right
296
- next to "inklusive" read as contradictory, so price is suppressed whenever
297
- staticNote is set, not just the switch. */}
298
- {price && !staticNote && (
299
- <span className="num" style={{ fontWeight: 700, fontSize: 13.5 }}>
300
- {price}
301
- </span>
302
- )}
303
- {staticNote ? (
304
- <span style={{ fontFamily: 'Arial, Arimo, sans-serif', fontWeight: 400, fontSize: 15, lineHeight: '17px', color: '#0E2238' }}>
305
- {staticNote}
306
- </span>
307
- ) : (
308
- <Switch checked={checked} disabled={disabled} onChange={(e) => onChange(e.target.checked)} ariaLabel={label} />
309
- )}
310
- </div>
311
- </div>
312
- );
313
- };
314
-
315
- /** body content for the "Rundum-Sorglos-Paket" ToggleRow tooltip — intro sentence, bold heading,
316
- * the package's contents as a bullet list, then (financing/leasing only) a closing paragraph
317
- * explaining the one-off-vs-financed payment choice. Shared by every addServicesToggle
318
- * ToggleRow (FinanceCalculator's own card + VdpModules' modal/mobile-sheet instances); intro/
319
- * outro vary by mode since cash mode has no "financed into the rate" option. */
320
- export const AddServicesTooltipBody: React.FunctionComponent<{ t: TranslationFunction; isCash?: boolean; isLease?: boolean }> = ({
321
- t,
322
- isCash,
323
- isLease,
324
- }) => (
325
- <>
326
- <p style={{ margin: '0 0 8px' }}>
327
- {t(isCash ? 'autobahn:finance.addServicesTooltipIntroCash' : 'autobahn:finance.addServicesTooltipIntroFinanced')}
328
- </p>
329
- <p style={{ fontFamily: 'Arial, Arimo, sans-serif', fontWeight: 700, fontSize: 10, lineHeight: '13px', color: '#0E2238', margin: '0 0 4px' }}>
330
- {t('autobahn:finance.addServicesTooltipHeading')}
331
- </p>
332
- <ul style={{ margin: 0, padding: '0 0 0 14px' }}>
333
- {t('autobahn:finance.addServicesTooltipItems')
334
- .split('\n')
335
- .map((item) => (
336
- <li key={item}>{item}</li>
337
- ))}
338
- </ul>
339
- {!isCash && (
340
- <p style={{ margin: '8px 0 0' }}>
341
- {t(isLease ? 'autobahn:finance.addServicesTooltipOutroLeasing' : 'autobahn:finance.addServicesTooltipOutroFinancing')}
342
- </p>
343
- )}
344
- </>
345
- );
346
-
347
- export interface FinanceCalculatorProps {
348
- /** active payment mode (controlled). */
349
- mode: FinanceMode;
350
- /** purchase price in EUR (the cash mode hero). */
351
- price: number;
352
- /** previous/list price — when > price, shown struck through as the UVP in cash mode (real discount). */
353
- listPrice?: number;
354
- /** auto.de-ID reference code — shown with the financing/leasing condition line. */
355
- autoDeId?: string;
356
- /** price-rating label, e.g. 'Guter Preis' — drives the Preisbewertung indicator. */
357
- ratingLabel?: string;
358
- /** computed monthly rate in EUR for the current mode — supplied, NOT computed here. */
359
- monthly: number;
360
- /** struck old monthly rate (fe-financing oldMonthlyInstallment, isStrikeShown-gated) —
361
- * rendered as the red line-through figure next to the hero rate (fin/leasing only). */
362
- oldMonthly?: number;
363
- /** effective annual rate (%) for the current mode — supplied, NOT computed here. */
364
- apr: number;
365
- /** current down payment in EUR (controlled). */
366
- down: number;
367
- /** current term in months (controlled). */
368
- term: number;
369
- /** down-payment slider bounds. */
370
- downMin: number;
371
- downMax: number;
372
- /** down-payment slider step (EUR). */
373
- downStep?: number;
374
- /** term slider bounds (months) — used to derive chip options when termOptions is absent. */
375
- termMin: number;
376
- termMax: number;
377
- /** term slider step (months). */
378
- termStep?: number;
379
- /** the discrete selectable terms (months) for the Laufzeit chips. */
380
- termOptions?: number[];
381
- /** annual mileage in km (controlled) — leasing/financing Laufleistung/Jahr. Omit to hide the slider. */
382
- annualMileage?: number;
383
- /** annual-mileage slider bounds + step (km). */
384
- annualMileageMin?: number;
385
- annualMileageMax?: number;
386
- annualMileageStep?: number;
387
- /** annual-mileage slider changed. */
388
- onAnnualMileageChange?: (km: number) => void;
389
- /** "Mit Schlussrate" toggle state (financing only; leasing has no balloon concept). Omit
390
- * onToggleFinalInstallment to hide the row. */
391
- withFinalInstallment?: boolean;
392
- onToggleFinalInstallment?: (checked: boolean) => void;
393
- /** "Rundum-Sorglos-Paket" toggle state (fin/leasing). Omit addServicesCost or
394
- * onToggleAddServices to hide the row. */
395
- withAddServices?: boolean;
396
- addServicesCost?: number;
397
- addServicesDisabled?: boolean;
398
- onToggleAddServices?: (checked: boolean) => void;
399
- /** Kaufen tab only — real carStore.isAvailable, drives the Verfügbarkeit row (replaces the
400
- * static Lieferung row). Same source as VdpTrustRow's "Sofort verfügbar" badge. */
401
- available?: boolean;
402
- /** phone number shown on the secondary CTA (touch only). */
403
- phone?: string;
404
- /** primary CTA click (Angebot sichern). */
405
- onSecure?: () => void;
406
- /** true once the customer already has an offer request/checkout in progress for this car —
407
- * turns the primary CTA green (see .fin-cta-secured) instead of the default filled style. */
408
- secured?: boolean;
409
- /** overrides the primary CTA label while `secured` is true (e.g. "Zur Bestellung"). Ignored
410
- * when `secured` is false — the CTA keeps its own default label in that case. */
411
- secureLabel?: string;
412
- /** secondary CTA click (phone). */
413
- onCall?: () => void;
414
- /** open the Finanzierungs-/Leasingdetails popup (full breakdown + legal, expanded). Omit to hide the link. */
415
- onShowDetails?: () => void;
416
- /** mobile only: open the "Rate anpassen" / "Details anzeigen" sheet (collapsed/default view).
417
- * Omit to hide the trigger row (falls back to the desktop inline expander). */
418
- onOpenAdjust?: () => void;
419
- /** mode segment changed. */
420
- onModeChange: (mode: FinanceMode) => void;
421
- /** down-payment slider changed. */
422
- onDownChange: (down: number) => void;
423
- /** term changed. */
424
- onTermChange: (term: number) => void;
425
- /** whether leasing is actually offered for this car (financingConfig.leasing.isActive — same
426
- * age/mileage-gated flag SearchResultsStore.getLeasingActive stamps for the cards, see
427
- * cardParts.tsx's PriceTabs / toAutobahnCar.ts's `lease`). Default true keeps existing callers'
428
- * behavior; the VDP page passes the real computed value. Hides the Leasing tab when false,
429
- * same as the card — instead of showing a tab that would compute/display a rate the car isn't
430
- * eligible for. */
431
- leasingAvailable?: boolean;
432
- /** i18n function (drilled from the page). */
433
- t: TranslationFunction;
434
- }
435
-
436
- const eur = (n: number): string => n.toLocaleString('de-DE');
437
-
438
- /** build a [min..max] step range (fallback term options when none are supplied). */
439
- const range = (min: number, max: number, step: number): number[] => {
440
- const out: number[] = [];
441
- for (let v = min; v <= max; v += step || 12) out.push(v);
442
- return out.length ? out : [min];
443
- };
444
-
445
- /** quiet primary-colored text link (Finanzierungsdetails / Details anzeigen). */
446
- const DetailsLink: React.FunctionComponent<{ label: string; onClick: () => void }> = ({ label, onClick }) => (
447
- <button
448
- type="button"
449
- onClick={onClick}
450
- style={{
451
- display: 'inline-flex',
452
- alignItems: 'center',
453
- gap: 5,
454
- background: 'none',
455
- border: 0,
456
- padding: 0,
457
- cursor: 'pointer',
458
- color: 'var(--md-primary)',
459
- font: 'inherit',
460
- fontSize: 13,
461
- fontWeight: 600,
462
- }}
463
- >
464
- <Icon name="info" size={15} color="var(--md-primary)" />
465
- {label}
466
- </button>
467
- );
468
-
469
- /** "Rate anpassen" / "Details anzeigen" expander toggle button. */
470
- export const expanderBtnStyle: React.CSSProperties = {
471
- width: '100%',
472
- background: 'none',
473
- border: 0,
474
- cursor: 'pointer',
475
- display: 'flex',
476
- alignItems: 'center',
477
- justifyContent: 'space-between',
478
- padding: '0 0 2px',
479
- color: 'var(--md-primary)',
480
- fontWeight: 600,
481
- fontSize: 14,
482
- };
483
-
484
- const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
485
- mode,
486
- price,
487
- listPrice,
488
- autoDeId,
489
- ratingLabel,
490
- monthly,
491
- oldMonthly,
492
- down,
493
- term,
494
- downMin,
495
- downMax,
496
- downStep = 500,
497
- termMin,
498
- termMax,
499
- termStep = 6,
500
- termOptions,
501
- annualMileage,
502
- annualMileageMin = 5000,
503
- annualMileageMax = 60000,
504
- annualMileageStep = 5000,
505
- onAnnualMileageChange,
506
- withFinalInstallment,
507
- onToggleFinalInstallment,
508
- withAddServices,
509
- addServicesCost,
510
- addServicesDisabled,
511
- onToggleAddServices,
512
- available,
513
- phone = '0800 40 30 182',
514
- onSecure,
515
- secured,
516
- secureLabel,
517
- onCall,
518
- onShowDetails,
519
- onOpenAdjust,
520
- onModeChange,
521
- onDownChange,
522
- onTermChange,
523
- leasingAvailable = true,
524
- t,
525
- }) => {
526
- // Pure view state only — whether the adjust/details expander is open.
527
- const [adjust, setAdjust] = useState(false);
528
- // whether the "UVP-Rate" footnote popover (fin/leasing) is open — same widget as CarCard's.
529
- const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
530
- const isCash = mode === 'cash';
531
- const isLease = mode === 'leasing';
532
- const terms = termOptions && termOptions.length ? termOptions : range(termMin, termMax, termStep);
533
- const showStrike = listPrice != null && listPrice > price;
534
- // price-evaluation tier from the rating label (defaults to 'Guter Preis' tier when unmapped).
535
- const tierIdx = TIER_LABELS.indexOf(ratingLabel as (typeof TIER_LABELS)[number]);
536
- const evalTier = tierIdx >= 0 ? tierIdx : 1;
537
- const isGoodTier = TIER_KEYS[evalTier] === 'good';
538
- // each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
539
- // collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
540
- const evalTierLabel = t('autobahn:tier.' + TIER_KEYS[evalTier]);
541
- const evalPillColor = isGoodTier ? TIER_COLORS[0] : TIER_COLORS[evalTier];
542
- // condition summary (current selection) + its own details link — financing: "0 € Anzahlung ·
543
- // 60 Monate · Finanzierungsdetails"; leasing: "25.000 € Sonderzahlung · 60 Mon. · 10.000
544
- // km/Jahr · Details" (same wording/order as CarCard's own PriceTerms leaseTerms).
545
- const condParts: string[] = [];
546
- if (mode === 'leasing') {
547
- condParts.push(
548
- ...t('autobahn:card.price.leaseTerms', {
549
- firstInstallment: eur(down),
550
- months: term,
551
- mileage: annualMileage != null ? eur(annualMileage) : '',
552
- }).split(' · '),
553
- );
554
- } else if (!isCash) {
555
- condParts.push(t('autobahn:finance.downPaymentLabel', { value: eur(down) }));
556
- condParts.push(t('autobahn:finance.monthsLabel', { months: term, count: term }));
557
- }
558
-
559
- return (
560
- <div className="mcard mcard--elevated fin-calc-card" style={{ padding: 20 }}>
561
- {/* header — desktop only; mobile goes straight into the tabs (see mockup: no card
562
- title above Finanzierung/Leasing/Kaufen on phone). */}
563
- <div className="fin-card-header hide-mobile" style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 14 }}>
564
- <span
565
- style={{
566
- width: 34,
567
- height: 34,
568
- borderRadius: 'var(--md-r-full)',
569
- background: 'var(--md-primary-container)',
570
- display: 'flex',
571
- alignItems: 'center',
572
- justifyContent: 'center',
573
- flex: 'none',
574
- }}
575
- >
576
- <Icon name="tag" size={18} color="var(--md-on-primary-container)" />
577
- </span>
578
- <div style={{ fontFamily: 'var(--md-font-display)', fontSize: 18, fontWeight: 700 }}>{t('autobahn:finance.headerTitle')}</div>
579
- </div>
580
-
581
- {/* payment-type TABS on top — Leasing omitted when the car isn't leasing-eligible, same
582
- rule cardParts.tsx's PriceTabs already applies (car.lease != null there). */}
583
- <div className="fin-tabs" role="tablist">
584
- {(
585
- [
586
- ['fin', 'autobahn:finance.mode.financing'],
587
- ...(leasingAvailable ? ([['leasing', 'autobahn:finance.mode.leasing']] as Array<[FinanceMode, string]>) : []),
588
- ['cash', 'autobahn:finance.mode.cash'],
589
- ] as Array<[FinanceMode, string]>
590
- ).map(([k, labelKey]) => (
591
- <button
592
- key={k}
593
- type="button"
594
- role="tab"
595
- aria-selected={mode === k}
596
- className={'fin-tab' + (mode === k ? ' on' : '')}
597
- onClick={() => onModeChange(k)}
598
- >
599
- {k === 'cash' ? (
600
- <>
601
- {/* cash tab is "Kaufen" on both phone and desktop now — same key both spans. */}
602
- <span className="hide-mobile">{t('autobahn:card.price.buy')}</span>
603
- <span className="show-mobile" style={{ justifyContent: 'center' }}>
604
- {t('autobahn:card.price.buy')}
605
- </span>
606
- </>
607
- ) : (
608
- t(labelKey)
609
- )}
610
- </button>
611
- ))}
612
- </div>
613
-
614
- {/* 2-col grid: rate|pill (row 1) + condLine|bar (row 2) — fixed right column prevents wrapping */}
615
- <div className={'fin-price-grid' + (isCash ? ' fin-price-grid--cash' : '')}>
616
- {/* col 1 row 1: hero rate — Figma: "329 €" all-big, then a small stacked column with
617
- the struck old rate ABOVE "/mtl." (round 11; was a single baseline row) */}
618
- <div className="fin-rate-main">
619
- {/* mobile Kaufen (Figma round 14): struck list price ABOVE the price, right-aligned,
620
- tight to the figure — replaces the Festpreis + UVP lines, which stay desktop-only */}
621
- {isCash && showStrike && (
622
- <div
623
- className="show-mobile"
624
- style={{ justifyContent: 'flex-end', alignItems: 'baseline', gap: 4, lineHeight: 1, marginTop: 7 }}
625
- role="button"
626
- tabIndex={0}
627
- onClick={() => setUvpTooltipOpen((v) => !v)}
628
- >
629
- <span style={{ fontSize: 13, color: 'var(--md-on-surface-variant)' }}>{t('autobahn:finance.uvp')}</span>
630
- <span
631
- className={`num pp-hero-old${
632
- String(Math.round(listPrice as number)).length === 5
633
- ? ' pp-hero-old--len5'
634
- : String(Math.round(listPrice as number)).length === 4
635
- ? ' pp-hero-old--len4'
636
- : ''
637
- }`}
638
- >
639
- {eur(Math.round(listPrice as number))} €
640
- <span
641
- className="pp-eyebrow-badge"
642
- role="button"
643
- tabIndex={0}
644
- onClick={(e) => {
645
- e.stopPropagation();
646
- setUvpTooltipOpen((v) => !v);
647
- }}
648
- >
649
- 2
650
- </span>
651
- {uvpTooltipOpen && (
652
- <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
653
- <button
654
- type="button"
655
- className="pp-uvp-tooltip-close"
656
- aria-label={t('autobahn:modal.close')}
657
- onClick={(e) => {
658
- e.stopPropagation();
659
- setUvpTooltipOpen(false);
660
- }}
661
- >
662
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
663
- <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
664
- </svg>
665
- </button>
666
- <div className="pp-uvp-tooltip-body">{t('autobahn:card.price.uvpListTooltipBody')}</div>
667
- </div>
668
- )}
669
- </span>
670
- </div>
671
- )}
672
- {/* desktop: same struck list price ABOVE the rate, same fin-rate-old-list styling +
673
- clickable UVP badge/tooltip as the mobile sheet's own Kaufen block.
674
- Wrapper now renders on EVERY Kaufen car (isCash alone, not isCash && showStrike) —
675
- cross-tab height parity (md3.css) reserves this row's height once, assuming it's
676
- always there; a car with no discount used to skip it entirely, landing .fin-rate-main
677
- (and the whole card) ~20px shorter than a discounted one and breaking that parity.
678
- fin-rate-strike-slot (md3.css) gives it a fixed height so the slot itself doesn't
679
- move even though the <s> price inside is still conditional on showStrike. */}
680
- {isCash && (
681
- <div
682
- className="hide-mobile fin-rate-strike-slot"
683
- style={{ display: 'flex', justifyContent: 'flex-end', lineHeight: 1, marginTop: 0, cursor: showStrike ? 'pointer' : 'default' }}
684
- role="button"
685
- tabIndex={0}
686
- onClick={() => setUvpTooltipOpen((v) => !v)}
687
- >
688
- {showStrike && (
689
- <s className="num fin-rate-old fin-rate-old-list">
690
- {eur(listPrice as number)} €
691
- <span
692
- className="pp-eyebrow-badge"
693
- role="button"
694
- tabIndex={0}
695
- onClick={(e) => {
696
- e.stopPropagation();
697
- setUvpTooltipOpen((v) => !v);
698
- }}
699
- >
700
- 2
701
- </span>
702
- {uvpTooltipOpen && (
703
- <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
704
- <button
705
- type="button"
706
- className="pp-uvp-tooltip-close"
707
- aria-label={t('autobahn:modal.close')}
708
- onClick={(e) => {
709
- e.stopPropagation();
710
- setUvpTooltipOpen(false);
711
- }}
712
- >
713
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
714
- <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
715
- </svg>
716
- </button>
717
- <div className="pp-uvp-tooltip-body">{t('autobahn:card.price.uvpListTooltipBody')}</div>
718
- </div>
719
- )}
720
- </s>
721
- )}
722
- </div>
723
- )}
724
- <div style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
725
- {isCash ? (
726
- <>
727
- {/* phone: ONE unbreakable "13.249 €" span (a separate € span wraps to its own
728
- line); desktop keeps the number + quiet small € pair */}
729
- <span
730
- className={`num show-mobile fin-rate-cash-mobile${
731
- (() => {
732
- const digits = String(Math.round(price as number)).length;
733
- if (digits >= 8) return ' fin-rate-cash-mobile--len8';
734
- if (digits === 7) return ' fin-rate-cash-mobile--len7';
735
- if (digits === 6) return ' fin-rate-cash-mobile--len6';
736
- return '';
737
- })()
738
- }`}
739
- style={{ fontSize: 48, fontWeight: 800, color: 'var(--md-primary)', letterSpacing: '-2px', whiteSpace: 'nowrap' }}
740
- >
741
- {eur(price)} €<sup>1</sup>
742
- </span>
743
- <span
744
- className="num hide-mobile"
745
- style={{ fontSize: 45, fontWeight: 800, color: 'var(--md-primary)', letterSpacing: '-2px' }}
746
- >
747
- {eur(price)} €<sup>1</sup>
748
- </span>
749
- </>
750
- ) : (
751
- <>
752
- <span
753
- className={`num fin-rate-hero${
754
- (() => {
755
- const digits = String(Math.round(monthly)).length;
756
- if (digits >= 6) return ' fin-rate-hero--len6';
757
- if (digits === 5) return ' fin-rate-hero--len5';
758
- if (digits === 4) return ' fin-rate-hero--len4';
759
- return '';
760
- })()
761
- }`}
762
- style={{ fontSize: 48, fontWeight: 800, color: 'var(--md-primary)', letterSpacing: '-2px' }}
763
- >
764
- {eur(Math.round(monthly))}<span style={{ marginLeft: 6 }}>€</span>
765
- </span>
766
- <span className="fin-rate-unit">
767
- {/* struck old rate (REAL oldMonthlyInstallment; SRP strikes the same source) */}
768
- {oldMonthly != null && (
769
- <span
770
- style={{ display: 'flex', flexDirection: 'column', cursor: 'pointer' }}
771
- role="button"
772
- tabIndex={0}
773
- onClick={() => setUvpTooltipOpen((v) => !v)}
774
- >
775
- <span className="pp-eyebrow">
776
- {t('autobahn:card.price.uvpRateLabel')}
777
- <span
778
- className="pp-eyebrow-badge"
779
- role="button"
780
- tabIndex={0}
781
- onClick={(e) => {
782
- e.stopPropagation();
783
- setUvpTooltipOpen((v) => !v);
784
- }}
785
- >
786
- 3
787
- </span>
788
- {uvpTooltipOpen && (
789
- <div
790
- className={'pp-uvp-tooltip' + (mode === 'leasing' ? ' pp-uvp-tooltip--leasing' : '')}
791
- onClick={(e) => e.stopPropagation()}
792
- >
793
- <button
794
- type="button"
795
- className="pp-uvp-tooltip-close"
796
- aria-label={t('autobahn:modal.close')}
797
- onClick={(e) => {
798
- e.stopPropagation();
799
- setUvpTooltipOpen(false);
800
- }}
801
- >
802
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
803
- <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
804
- </svg>
805
- </button>
806
- <div className="pp-uvp-tooltip-body">
807
- {t(
808
- mode === 'leasing'
809
- ? 'autobahn:card.price.uvpRateTooltipBodyLeasing'
810
- : 'autobahn:card.price.uvpRateTooltipBody',
811
- )}
812
- </div>
813
- </div>
814
- )}
815
- </span>
816
- <s
817
- className={`num fin-rate-old fin-rate-example-price${
818
- String(Math.round(oldMonthly)).length >= 5
819
- ? ' fin-rate-example-price--len5'
820
- : String(Math.round(oldMonthly)).length === 4
821
- ? ' fin-rate-example-price--len4'
822
- : ''
823
- }`}
824
- >
825
- {eur(Math.round(oldMonthly))} €
826
- </s>
827
- </span>
828
- )}
829
- {/* no struck old rate above it (strike hidden) — nudge "/mtl." down so it
830
- sits level with the blue hero rate instead of centering high in the row. */}
831
- <span
832
- className="fin-rate-example-suffix"
833
- style={oldMonthly == null ? { paddingTop: 20 } : undefined}
834
- >
835
- {t('autobahn:finance.perMonth')}
836
- </span>
837
- </span>
838
- </>
839
- )}
840
- </div>
841
- {isCash && <div className="md-label-sm hide-mobile">{t('autobahn:finance.fixedPrice')}</div>}
842
- </div>
843
- {/* col 2: pill + eval bar grouped together (display:contents on desktop — no-op,
844
- preserves the original rate|pill / cond|bar auto-placement; mobile turns this into
845
- a real flex column so the two stack tight with a fixed 16px gap). */}
846
- <div className="fin-eval-col">
847
- {/* col 2 row 1: price-rating pill (Figma: bold colored label, NO icon) */}
848
- <div className="fin-eval-pill-cell">
849
- {ratingLabel && (
850
- <span
851
- className={`fin-eval-pill${isGoodTier ? ' fin-eval-pill--good' : ''}`}
852
- style={{ color: evalPillColor, background: `color-mix(in srgb, ${evalPillColor} 16%, transparent)` }}
853
- aria-label={t('autobahn:finance.priceRatingAria', { rating: evalTierLabel })}
854
- >
855
- {evalTierLabel}
856
- {isGoodTier && <sup>4</sup>}
857
- </span>
858
- )}
859
- </div>
860
- {/* segmented evaluation bar (Figma: discrete tiers, not a gradient) */}
861
- <div className="fin-eval-bar-cell">{ratingLabel && <EvalBar tier={evalTier} />}</div>
862
- </div>
863
- {/* col 1 row 2: condition line — financing "0 € Anzahlung · 60 Monate · Finanzierungsdetails",
864
- leasing "25.000 € Sonderzahlung · 60 Mon. · 10.000 km/Jahr · Details". Buy has nothing
865
- to show here (no down payment/term/details link of its own) — not rendered at all
866
- rather than left as an empty reserved-height div. */}
867
- {!isCash && (
868
- <div className="fin-cond">
869
- {condParts.map((part, i) => (
870
- <React.Fragment key={i}>
871
- {i > 0 && <span className="cc-terms-dot"> · </span>}
872
- {part}
873
- </React.Fragment>
874
- ))}
875
- {onShowDetails && (
876
- <>
877
- <span className="cc-terms-dot"> · </span>
878
- {/* plain underlined text link, same onShowDetails handler as .fin-info used to open. */}
879
- <button type="button" className="cc-terms-link" onClick={onShowDetails}>
880
- {mode === 'leasing' ? t('autobahn:card.price.detailsLink') : t('autobahn:finance.financingDetails')}
881
- </button>
882
- </>
883
- )}
884
- </div>
885
- )}
886
- </div>
887
-
888
- {/* ============================== DESKTOP (≥601px) — unchanged ============================== */}
889
- <div className="hide-mobile">
890
- {/* RATE EDIT (Rate anpassen) — between the rate and the request CTA. fin-adjust--cash:
891
- Kaufen-only margin-top override (0, was the shared 14px) — see md3.css. */}
892
- <div className={'fin-adjust' + (isCash ? ' fin-adjust--cash' : '')}>
893
- <button onClick={() => setAdjust((a) => !a)} style={expanderBtnStyle}>
894
- <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7 }}>
895
- <Icon name={isCash ? 'list' : 'sliders-horizontal'} size={16} color="var(--md-primary)" />
896
- {isCash ? t('autobahn:finance.detailsShow') : t('autobahn:finance.adjustRate')}
897
- </span>
898
- <Icon name={adjust ? 'chevron-up' : 'chevron-down'} size={18} color="var(--md-primary)" />
899
- </button>
900
- {adjust &&
901
- (isCash ? (
902
- <>
903
- <div style={{ marginTop: 4 }}>
904
- <CalcRow label={t('autobahn:finance.paymentLabel')} last={!available && !(addServicesCost != null && onToggleAddServices)}>{t('autobahn:finance.paymentValue')}</CalcRow>
905
- {available && (
906
- <CalcRow label={t('autobahn:finance.availabilityLabel')} last={!(addServicesCost != null && onToggleAddServices)}>
907
- {t('autobahn:finance.availabilityValue')}
908
- </CalcRow>
909
- )}
910
- </div>
911
- {addServicesCost != null && onToggleAddServices && (
912
- <ToggleRow
913
- className="fin-toggle-addservices fin-toggle-addservices--cash"
914
- label={t('autobahn:finance.addServicesToggle')}
915
- price={t('autobahn:finance.addServicesOnce', { value: eur(Math.round(addServicesCost)) })}
916
- checked={!!withAddServices}
917
- disabled={addServicesDisabled}
918
- onChange={onToggleAddServices}
919
- staticNote={t('autobahn:finance.addServicesIncluded')}
920
- tooltip={<AddServicesTooltipBody t={t} isCash />}
921
- tooltipCloseLabel={t('autobahn:modal.close')}
922
- t={t}
923
- />
924
- )}
925
- </>
926
- ) : (
927
- <div style={{ display: 'flex', flexDirection: 'column', marginTop: 8 }}>
928
- <div style={{ marginBottom: 15 }}>
929
- <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
930
- <span className="md-title-sm">{t('autobahn:finance.downPaymentSliderLabel')}</span>
931
- <span className="num" style={{ fontWeight: 700 }}>
932
- {eur(down)} €
933
- </span>
934
- </div>
935
- <Slider
936
- min={downMin}
937
- max={downMax}
938
- step={downStep}
939
- value={down}
940
- onChange={onDownChange}
941
- fmt={(v) => `${eur(Number(v))} €`}
942
- />
943
- </div>
944
- {annualMileage != null && onAnnualMileageChange && (
945
- <div style={{ marginBottom: 15 }}>
946
- <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
947
- <span className="md-title-sm">{t('autobahn:finance.annualMileageLabel')}</span>
948
- <span className="num" style={{ fontWeight: 700 }}>
949
- {eur(annualMileage)} km
950
- </span>
951
- </div>
952
- <Slider
953
- min={annualMileageMin}
954
- max={annualMileageMax}
955
- step={annualMileageStep}
956
- value={annualMileage}
957
- onChange={onAnnualMileageChange}
958
- fmt={(v) => `${eur(Number(v))} km`}
959
- />
960
- </div>
961
- )}
962
- <div style={{ marginBottom: 15 }}>
963
- <div className="md-title-sm" style={{ marginBottom: 8 }}>
964
- {t('autobahn:finance.termSelection')}
965
- </div>
966
- <TermChips options={terms.filter((v) => v !== 12 && v !== 96)} value={term} onChange={onTermChange} t={t} />
967
- </div>
968
- {/* same Mit-Schlussrate / Rundum-Sorglos-Paket toggles as the mobile sheet / modal
969
- desktop block — replaces the static Kaufpreis/Garantie/Lieferung rows. */}
970
- {!isLease && onToggleFinalInstallment && (
971
- <ToggleRow
972
- className="fin-toggle-final"
973
- label={t('autobahn:finance.finalInstallmentToggle')}
974
- checked={!!withFinalInstallment}
975
- onChange={onToggleFinalInstallment}
976
- />
977
- )}
978
- {addServicesCost != null && onToggleAddServices && (
979
- <ToggleRow
980
- className={'fin-toggle-addservices' + (isLease ? ' fin-toggle-addservices--leasing' : '')}
981
- label={t('autobahn:finance.addServicesToggle')}
982
- price={t('autobahn:finance.addServicesPerMonth', { value: eur(Math.round(addServicesCost)) })}
983
- checked={!!withAddServices}
984
- disabled={addServicesDisabled}
985
- onChange={onToggleAddServices}
986
- tooltip={<AddServicesTooltipBody t={t} isLease={isLease} />}
987
- tooltipCloseLabel={t('autobahn:modal.close')}
988
- t={t}
989
- />
990
- )}
991
- </div>
992
- ))}
993
- </div>
994
-
995
- {/* REQUEST CTA */}
996
- <Button
997
- variant="filled"
998
- block
999
- size="lg"
1000
- icon="shield-check"
1001
- className={secured ? 'fin-cta-secured' : undefined}
1002
- style={{ marginTop: 14 }}
1003
- onClick={onSecure}
1004
- >
1005
- {secured && secureLabel ? secureLabel : t('autobahn:finance.secureOffer')}
1006
- </Button>
1007
- {/* phone CTA — touch only (hidden on desktop via .fin-call) */}
1008
- <div className="fin-call">
1009
- <Button variant="outlined" block icon="phone" onClick={onCall}>
1010
- {phone}
1011
- </Button>
1012
- </div>
1013
-
1014
- {/* auto.de-ID in front of the Finanzierungs-/Leasingdetails link — one row, under everything */}
1015
- {(autoDeId || (!isCash && onShowDetails)) && (
1016
- <div className="fin-info">
1017
- {autoDeId && <span className="fin-id">auto.de-ID {autoDeId}</span>}
1018
- {!isCash && onShowDetails && (
1019
- <DetailsLink
1020
- label={mode === 'leasing' ? t('autobahn:finance.leasingDetails') : t('autobahn:finance.financingDetails')}
1021
- onClick={onShowDetails}
1022
- />
1023
- )}
1024
- </div>
1025
- )}
1026
- </div>
1027
-
1028
- {/* ============================== MOBILE (≤600px) — new layout ============================== */}
1029
- <div className="show-mobile" style={{ flexDirection: 'column' }}>
1030
- {/* side-by-side CTAs — mockup ratio ~2:1, with the tiny auto.de-ID sitting
1031
- directly under the Anrufen button (not in its own full-width row). */}
1032
- <div className="fin-cta-row" style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
1033
- {/* Figma CTA icon: document + check badge (composed — no single lucide glyph) */}
1034
- <Button
1035
- variant="filled"
1036
- size="lg"
1037
- className={secured ? 'fin-cta-secured' : undefined}
1038
- style={{ width: 216, height: 50, paddingLeft: 0, paddingRight: 9, gap: secured ? 3 : 18 }}
1039
- onClick={onSecure}
1040
- >
1041
- {/* size 23 either way — was 18 for the secured (shield-check) state, notably
1042
- smaller than DocCheckIcon's 23 in the default state despite sharing the exact
1043
- same 50px button box; nothing about switching to "already secured" should
1044
- shrink the icon. */}
1045
- {secured ? <Icon name="shield-check" size={23} /> : <DocCheckIcon size={23} />}
1046
- {secured && secureLabel ? secureLabel : t('autobahn:finance.secureOffer')}
1047
- </Button>
1048
- <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 4, minWidth: 0 }}>
1049
- <Button variant="outlined" size="lg" icon="phone" style={{ width: 112, height: 50 }} onClick={onCall}>
1050
- {t('autobahn:finance.callCta')}
1051
- </Button>
1052
- {autoDeId && (
1053
- <span
1054
- className="num"
1055
- style={{ fontSize: 10, fontWeight: 700, color: 'var(--md-primary)', textAlign: 'center', whiteSpace: 'nowrap' }}
1056
- >
1057
- auto.de ID: {autoDeId}
1058
- </span>
1059
- )}
1060
- </div>
1061
- </div>
1062
-
1063
- {/* Persönliche Beratung — icon + one line (the details link now lives in .fin-cond above) */}
1064
- <div className="fin-info" style={{ justifyContent: 'flex-start', paddingLeft: 15 }}>
1065
- <Icon name="user" size={26} color="var(--md-on-surface-variant)" style={{ flex: 'none', marginRight: 20 }} />
1066
- <span className="fin-info-line">{t('autobahn:finance.personalConsultationLine')}</span>
1067
- </div>
1068
-
1069
- {/* "Rate anpassen" / "Details anzeigen" — opens the full bottom sheet (not an inline expander) */}
1070
- {onOpenAdjust && (
1071
- <button
1072
- type="button"
1073
- onClick={onOpenAdjust}
1074
- style={{ ...expanderBtnStyle, borderTop: '1px solid var(--md-outline-variant)', marginTop: 11, padding: '11px 0 2px 21px' }}
1075
- >
1076
- <span style={{ display: 'inline-flex', alignItems: 'center', gap: 21 }}>
1077
- <Icon name="sliders-horizontal" size={23} color="var(--md-primary)" />
1078
- <span className="fin-adjust-btn-label">
1079
- {isCash ? t('autobahn:finance.detailsShow') : t('autobahn:finance.adjustRate')}
1080
- </span>
1081
- </span>
1082
- <Icon name="chevron-right" size={23} color="var(--md-primary)" />
1083
- </button>
1084
- )}
1085
- </div>
1086
- </div>
1087
- );
1088
- };
1089
-
1090
- export default FinanceCalculator;
1
+ // Autobahn (auto.de redesign) — VDP offer / finance card (Finanzierung / Leasing /
2
+ // Barzahlung).
3
+ //
4
+ // Structure (desktop rethink, tabs-on-top): payment-type TABS at the top (MD3 underline tabs),
5
+ // then the rate (with any discount), then the "Rate anpassen" rate-editor, then the primary
6
+ // "Angebot sichern" request CTA, and finally the Finanzierungs-/Leasingdetails info + popup link
7
+ // at the foot. Laufzeit is chosen via chips (discrete terms), not a slider.
8
+ //
9
+ // CONTROLLED / PRESENTATIONAL — computes NOTHING financial: `mode`, `monthly`, `down`, `term` and
10
+ // the slider/chip bounds all arrive as props; segment/slider/chip changes are reported back via
11
+ // `onModeChange` / `onDownChange` / `onTermChange`. The real numbers come from `financingStore`.
12
+ // The only local state is the `adjust` expander (pure view state).
13
+ //
14
+ // Renders correctly only inside a `<div className="md3">` subtree.
15
+
16
+ import React, { useState, useEffect } from 'react';
17
+ import { TranslationFunction } from '../types';
18
+
19
+ import { Button, Icon, Switch, CreditCostNotice } from '../ui';
20
+ import { TIER_LABELS, TIER_KEYS, TIER_COLORS } from '../constants';
21
+
22
+ /** Payment mode segment keys. Mirrors the design's ['fin','leasing','cash']. */
23
+ export type FinanceMode = 'fin' | 'leasing' | 'cash';
24
+
25
+ export interface SliderProps {
26
+ min: number;
27
+ max: number;
28
+ step?: number;
29
+ value: number;
30
+ onChange: (value: number) => void;
31
+ /** formats the min/max end labels (and is reused by callers for the value). */
32
+ fmt?: (v: number) => React.ReactNode;
33
+ /** render the current value in a floating bubble above the thumb (Figma sheet sliders). */
34
+ bubble?: boolean;
35
+ /** space reserved below the rail for the bubble's tail (Figma differs per sheet: fin vs leasing). */
36
+ bubblePaddingBottom?: number;
37
+ }
38
+
39
+ /**
40
+ * Range slider with a filled track and min/max end labels. The track fill is a
41
+ * linear-gradient driven by the value's position; the design's `.mslider` class
42
+ * styles the thumb/rail. With `bubble` the current value floats above the thumb
43
+ * (mockup "Rate anpassen" sliders) instead of the caller printing it elsewhere.
44
+ */
45
+ export const Slider: React.FunctionComponent<SliderProps> = ({
46
+ min,
47
+ max,
48
+ step = 1,
49
+ value,
50
+ onChange,
51
+ fmt = (v) => v,
52
+ bubble,
53
+ bubblePaddingBottom = 34,
54
+ }) => {
55
+ // Local mirror of `value`, updated INSTANTLY on every native input event. Callers commonly
56
+ // debounce their own onChange (e.g. CheckoutFinancePanelNext's 50ms setCommonUserConfig,
57
+ // which also triggers a MobX-driven re-render of a much bigger subtree) — without this, the
58
+ // thumb still drags natively/smoothly (the browser owns that), but the gradient fill and any
59
+ // bubble label are driven by the `value` PROP, which only catches up once the debounced commit
60
+ // finally lands, so the fill visibly lags/stutters behind the thumb during a fast drag. Synced
61
+ // back to the prop via useEffect for externally-driven changes (e.g. a reset button).
62
+ const [localValue, setLocalValue] = useState(value);
63
+ useEffect(() => { setLocalValue(value); }, [value]);
64
+
65
+ const span = max - min;
66
+ const pct = span > 0 ? ((localValue - min) / span) * 100 : 0;
67
+ return (
68
+ <div>
69
+ <div style={{ position: 'relative', paddingTop: bubble ? 44 : 0, paddingBottom: bubble ? bubblePaddingBottom : 0 }}>
70
+ {bubble && (
71
+ // thumb is 22px wide: interpolate the bubble anchor between half-thumb insets so it
72
+ // tracks the thumb center (a plain pct% drifts at the rail ends)
73
+ <span className="slider-bubble num" style={{ left: `calc(11px + (100% - 22px) * ${pct / 100})` }}>
74
+ {fmt(localValue)}
75
+ </span>
76
+ )}
77
+ <input
78
+ type="range"
79
+ className="mslider"
80
+ min={min}
81
+ max={max}
82
+ step={step}
83
+ value={localValue}
84
+ onChange={(e) => {
85
+ const v = Number(e.target.value);
86
+ setLocalValue(v);
87
+ onChange(v);
88
+ }}
89
+ style={{ background: `linear-gradient(90deg, var(--md-primary) ${pct}%, var(--md-sc-highest) ${pct}%)` }}
90
+ />
91
+ </div>
92
+ {!bubble && (
93
+ <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 4 }}>
94
+ <span className="md-label-sm">{fmt(min)}</span>
95
+ <span className="md-label-sm">{fmt(max)}</span>
96
+ </div>
97
+ )}
98
+ </div>
99
+ );
100
+ };
101
+
102
+ /**
103
+ * Segmented price-evaluation bar (Figma: 5 discrete tier segments, NOT a gradient) with a
104
+ * white ring marker. `leftPct` overrides the marker position (the Marktwert gauge positions
105
+ * it continuously); default = centered on the tier segment.
106
+ */
107
+ export const EvalBar: React.FunctionComponent<{ tier: number; leftPct?: number }> = ({ tier, leftPct }) => (
108
+ <div className="fin-eval-bar">
109
+ {TIER_COLORS.map((c, i) => (
110
+ <span key={i} className="fin-eval-seg" style={{ background: c }} />
111
+ ))}
112
+ <div
113
+ className={`fin-eval-thumb${TIER_KEYS[Math.max(0, Math.min(4, tier))] === 'good' ? ' fin-eval-thumb--good' : ''}`}
114
+ style={{ left: `${leftPct != null ? leftPct : (tier + 0.5) * 20}%`, borderColor: TIER_COLORS[Math.max(0, Math.min(4, tier))] }}
115
+ />
116
+ </div>
117
+ );
118
+
119
+ /** Figma CTA icon — document with a check-in-circle badge over its bottom-right corner
120
+ * (no single lucide glyph matches; composed from file-text + a knocked-out check-circle).
121
+ * The badge backdrop assumes a filled (primary) button. */
122
+ export const DocCheckIcon: React.FunctionComponent<{ size?: number }> = ({ size = 19 }) => {
123
+ // inline width/height on BOTH icons — `.mbtn .lucide { width/height: 18px }` otherwise
124
+ // inflates the badge to full icon size and it swallows the document
125
+ const badge = Math.max(9, Math.round(size * 0.5));
126
+ return (
127
+ <span style={{ position: 'relative', display: 'inline-flex', flex: 'none' }}>
128
+ <Icon name="file-text" size={size} stroke={2} style={{ width: size, height: size }} />
129
+ <span
130
+ style={{
131
+ position: 'absolute',
132
+ right: -3,
133
+ bottom: -2,
134
+ display: 'flex',
135
+ borderRadius: '50%',
136
+ background: 'var(--md-primary)',
137
+ padding: 1,
138
+ }}
139
+ >
140
+ <Icon name="check-circle" size={badge} stroke={2.8} style={{ width: badge, height: badge }} />
141
+ </span>
142
+ </span>
143
+ );
144
+ };
145
+
146
+ export interface TermChipsProps {
147
+ /** the selectable term values (months), e.g. [12,24,36,48,60,72]. */
148
+ options: number[];
149
+ value: number;
150
+ onChange: (term: number) => void;
151
+ /** i18n function (drilled from the page). */
152
+ t: TranslationFunction;
153
+ }
154
+
155
+ /** Laufzeit selector — discrete term values as tappable chips (replaces the fiddly slider). */
156
+ export const TermChips: React.FunctionComponent<TermChipsProps> = ({ options, value, onChange, t }) => (
157
+ <div className="term-chips" role="group" aria-label={t('autobahn:finance.termSelection')}>
158
+ {options.map((m) => (
159
+ <button
160
+ key={m}
161
+ type="button"
162
+ aria-pressed={m === value}
163
+ className={'term-chip' + (m === value ? ' on' : '')}
164
+ onClick={() => onChange(m)}
165
+ >
166
+ {m}
167
+ <span className="tc-unit">{t('autobahn:finance.monthUnit')}</span>
168
+ </button>
169
+ ))}
170
+ </div>
171
+ );
172
+
173
+ export interface CalcRowProps {
174
+ label: React.ReactNode;
175
+ /** when true, drops the bottom hairline (last row). */
176
+ last?: boolean;
177
+ children?: React.ReactNode;
178
+ className?: string;
179
+ }
180
+
181
+ /** One label/value row inside the "Rate anpassen" / "Details" expander. */
182
+ export const CalcRow: React.FunctionComponent<CalcRowProps> = ({ label, last, children, className }) => (
183
+ <div
184
+ className={'calcrow' + (className ? ' ' + className : '')}
185
+ style={{
186
+ display: 'flex',
187
+ justifyContent: 'space-between',
188
+ alignItems: 'baseline',
189
+ gap: 12,
190
+ padding: '8px 0',
191
+ borderBottom: last ? 0 : '1px solid var(--md-outline-variant)',
192
+ }}
193
+ >
194
+ <span className="md-label-sm calcrow-label">{label}</span>
195
+ <span className="num calcrow-value" style={{ fontSize: 13.5, fontWeight: 600 }}>
196
+ {children}
197
+ </span>
198
+ </div>
199
+ );
200
+
201
+ /** full-width label(+optional trailing price) / Switch row — Switch itself is inline-flex
202
+ * (track+label), so the "label ...... price switch" full-row layout can't be expressed via
203
+ * Switch's `label` prop (which renders track-then-label, not a full-width justified row). */
204
+ export const ToggleRow: React.FunctionComponent<{
205
+ label: string;
206
+ price?: string;
207
+ checked: boolean;
208
+ disabled?: boolean;
209
+ onChange: (checked: boolean) => void;
210
+ className?: string;
211
+ /** cash mode: the package is always included — shows a static "inklusive" note instead of the switch. */
212
+ staticNote?: string;
213
+ /** when set, the info icon becomes clickable and opens a popover with this body (e.g. the
214
+ * Rundum-Sorglos-Paket contents) — "Mit Schlussrate" rows omit this, keeping their icon inert. */
215
+ tooltip?: React.ReactNode;
216
+ /** aria-label for the popover's close button — required together with `tooltip`. */
217
+ tooltipCloseLabel?: string;
218
+ /** required together with `tooltip` — builds the trigger's own accessible name (see `infoLabel` below). */
219
+ t?: TranslationFunction;
220
+ }> = ({ label, price, checked, disabled, onChange, className, staticNote, tooltip, tooltipCloseLabel, t }) => {
221
+ const [tooltipOpen, setTooltipOpen] = useState(false);
222
+ const toggleTooltip = (e: { stopPropagation: () => void }) => {
223
+ e.stopPropagation();
224
+ setTooltipOpen((v) => !v);
225
+ };
226
+ // the visible label alone ("Rundum-Sorglos-Paket") reads as ambiguous out of context (toggle
227
+ // the package? show info about it?) — spell out what activating the trigger actually does.
228
+ const infoLabel = tooltip && t ? t('autobahn:finance.moreInfoAria', { label }) : undefined;
229
+ return (
230
+ <div
231
+ className={className}
232
+ style={{
233
+ display: 'flex',
234
+ alignItems: 'center',
235
+ justifyContent: staticNote ? undefined : 'space-between',
236
+ gap: 10,
237
+ position: tooltip ? 'relative' : undefined,
238
+ }}
239
+ >
240
+ <span className="md-title-sm" style={{ display: 'inline-flex', alignItems: 'center', gap: 5 }}>
241
+ {label}
242
+ {/* custom info glyph (not the shared lucide "info" from the Icon registry — that name is
243
+ used in many unrelated places, this swap is scoped to just the Rundum-Sorglos-Paket
244
+ tooltip trigger). Shared by all three tabs (Finanzierung/Leasing/Kaufen) and both
245
+ desktop/mobile — ToggleRow itself is the one shared render for all of them. Viewbox
246
+ already bounds every path (1.875–13.125 within 0–15), so no clip-path needed.
247
+ The interactive/focusable/touch-target element is THIS icon wrapper only — the label
248
+ text next to it is plain, inert text, not part of the trigger. */}
249
+ {tooltip && (
250
+ <span
251
+ className="fin-toggle-info-trigger"
252
+ style={{ display: 'inline-flex', cursor: 'pointer' }}
253
+ role="button"
254
+ tabIndex={0}
255
+ aria-label={infoLabel}
256
+ aria-expanded={tooltipOpen}
257
+ onClick={toggleTooltip}
258
+ onKeyDown={(e) => {
259
+ // ARIA authoring practices: a role="button" element must answer to both Enter and
260
+ // Space, not just Enter — a native <button> gets this for free, this span doesn't.
261
+ if (e.key === 'Enter' || e.key === ' ') {
262
+ e.preventDefault();
263
+ toggleTooltip(e);
264
+ }
265
+ }}
266
+ >
267
+ <svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" className="lucide">
268
+ <path d="M7.5 13.125C10.6066 13.125 13.125 10.6066 13.125 7.5C13.125 4.3934 10.6066 1.875 7.5 1.875C4.3934 1.875 1.875 4.3934 1.875 7.5C1.875 10.6066 4.3934 13.125 7.5 13.125Z" stroke="#8B98AA" strokeWidth={1.8} />
269
+ <path d="M7.5 7.2V10.5125" stroke="#8B98AA" strokeWidth={1.8} strokeLinecap="round" />
270
+ <path d="M7.5 4.8125H7.50625" stroke="#8B98AA" strokeWidth={2.4} strokeLinecap="round" />
271
+ </svg>
272
+ </span>
273
+ )}
274
+ </span>
275
+ {tooltip && tooltipOpen && (
276
+ <div className="pp-uvp-tooltip fin-toggle-tooltip" onClick={(e) => e.stopPropagation()}>
277
+ <button
278
+ type="button"
279
+ className="pp-uvp-tooltip-close fin-toggle-tooltip-close"
280
+ aria-label={tooltipCloseLabel}
281
+ onClick={(e) => {
282
+ e.stopPropagation();
283
+ setTooltipOpen(false);
284
+ }}
285
+ >
286
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
287
+ <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
288
+ </svg>
289
+ </button>
290
+ <div className="pp-uvp-tooltip-body fin-toggle-tooltip-body">{tooltip}</div>
291
+ </div>
292
+ )}
293
+ <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginLeft: staticNote ? 'auto' : undefined }}>
294
+ {/* staticNote (cash mode: package is always included, price already baked into the
295
+ fixed price above) fully replaces the price+switch pair — showing "+1.499 €" right
296
+ next to "inklusive" read as contradictory, so price is suppressed whenever
297
+ staticNote is set, not just the switch. */}
298
+ {price && !staticNote && (
299
+ <span className="num" style={{ fontWeight: 700, fontSize: 13.5 }}>
300
+ {price}
301
+ </span>
302
+ )}
303
+ {staticNote ? (
304
+ <span style={{ fontFamily: 'Arial, Arimo, sans-serif', fontWeight: 400, fontSize: 15, lineHeight: '17px', color: '#0E2238' }}>
305
+ {staticNote}
306
+ </span>
307
+ ) : (
308
+ <Switch checked={checked} disabled={disabled} onChange={(e) => onChange(e.target.checked)} ariaLabel={label} />
309
+ )}
310
+ </div>
311
+ </div>
312
+ );
313
+ };
314
+
315
+ /** body content for the "Rundum-Sorglos-Paket" ToggleRow tooltip — intro sentence, bold heading,
316
+ * the package's contents as a bullet list, then (financing/leasing only) a closing paragraph
317
+ * explaining the one-off-vs-financed payment choice. Shared by every addServicesToggle
318
+ * ToggleRow (FinanceCalculator's own card + VdpModules' modal/mobile-sheet instances); intro/
319
+ * outro vary by mode since cash mode has no "financed into the rate" option. */
320
+ export const AddServicesTooltipBody: React.FunctionComponent<{ t: TranslationFunction; isCash?: boolean; isLease?: boolean }> = ({
321
+ t,
322
+ isCash,
323
+ isLease,
324
+ }) => (
325
+ <>
326
+ <p style={{ margin: '0 0 8px' }}>
327
+ {t(isCash ? 'autobahn:finance.addServicesTooltipIntroCash' : 'autobahn:finance.addServicesTooltipIntroFinanced')}
328
+ </p>
329
+ <p style={{ fontFamily: 'Arial, Arimo, sans-serif', fontWeight: 700, fontSize: 10, lineHeight: '13px', color: '#0E2238', margin: '0 0 4px' }}>
330
+ {t('autobahn:finance.addServicesTooltipHeading')}
331
+ </p>
332
+ <ul style={{ margin: 0, padding: '0 0 0 14px' }}>
333
+ {t('autobahn:finance.addServicesTooltipItems')
334
+ .split('\n')
335
+ .map((item) => (
336
+ <li key={item}>{item}</li>
337
+ ))}
338
+ </ul>
339
+ {!isCash && (
340
+ <p style={{ margin: '8px 0 0' }}>
341
+ {t(isLease ? 'autobahn:finance.addServicesTooltipOutroLeasing' : 'autobahn:finance.addServicesTooltipOutroFinancing')}
342
+ </p>
343
+ )}
344
+ </>
345
+ );
346
+
347
+ export interface FinanceCalculatorProps {
348
+ /** active payment mode (controlled). */
349
+ mode: FinanceMode;
350
+ /** purchase price in EUR (the cash mode hero). */
351
+ price: number;
352
+ /** previous/list price — when > price, shown struck through as the UVP in cash mode (real discount). */
353
+ listPrice?: number;
354
+ /** auto.de-ID reference code — shown with the financing/leasing condition line. */
355
+ autoDeId?: string;
356
+ /** price-rating label, e.g. 'Guter Preis' — drives the Preisbewertung indicator. */
357
+ ratingLabel?: string;
358
+ /** computed monthly rate in EUR for the current mode — supplied, NOT computed here. */
359
+ monthly: number;
360
+ /** struck old monthly rate (fe-financing oldMonthlyInstallment, isStrikeShown-gated) —
361
+ * rendered as the red line-through figure next to the hero rate (fin/leasing only). */
362
+ oldMonthly?: number;
363
+ /** effective annual rate (%) for the current mode — supplied, NOT computed here. */
364
+ apr: number;
365
+ /** current down payment in EUR (controlled). */
366
+ down: number;
367
+ /** current term in months (controlled). */
368
+ term: number;
369
+ /** down-payment slider bounds. */
370
+ downMin: number;
371
+ downMax: number;
372
+ /** down-payment slider step (EUR). */
373
+ downStep?: number;
374
+ /** term slider bounds (months) — used to derive chip options when termOptions is absent. */
375
+ termMin: number;
376
+ termMax: number;
377
+ /** term slider step (months). */
378
+ termStep?: number;
379
+ /** the discrete selectable terms (months) for the Laufzeit chips. */
380
+ termOptions?: number[];
381
+ /** annual mileage in km (controlled) — leasing/financing Laufleistung/Jahr. Omit to hide the slider. */
382
+ annualMileage?: number;
383
+ /** annual-mileage slider bounds + step (km). */
384
+ annualMileageMin?: number;
385
+ annualMileageMax?: number;
386
+ annualMileageStep?: number;
387
+ /** annual-mileage slider changed. */
388
+ onAnnualMileageChange?: (km: number) => void;
389
+ /** "Mit Schlussrate" toggle state (financing only; leasing has no balloon concept). Omit
390
+ * onToggleFinalInstallment to hide the row. */
391
+ withFinalInstallment?: boolean;
392
+ onToggleFinalInstallment?: (checked: boolean) => void;
393
+ /** "Rundum-Sorglos-Paket" toggle state (fin/leasing). Omit addServicesCost or
394
+ * onToggleAddServices to hide the row. */
395
+ withAddServices?: boolean;
396
+ addServicesCost?: number;
397
+ addServicesDisabled?: boolean;
398
+ onToggleAddServices?: (checked: boolean) => void;
399
+ /** Kaufen tab only — real carStore.isAvailable, drives the Verfügbarkeit row (replaces the
400
+ * static Lieferung row). Same source as VdpTrustRow's "Sofort verfügbar" badge. */
401
+ available?: boolean;
402
+ /** phone number shown on the secondary CTA (touch only). */
403
+ phone?: string;
404
+ /** primary CTA click (Angebot sichern). */
405
+ onSecure?: () => void;
406
+ /** true once the customer already has an offer request/checkout in progress for this car —
407
+ * turns the primary CTA green (see .fin-cta-secured) instead of the default filled style. */
408
+ secured?: boolean;
409
+ /** overrides the primary CTA label while `secured` is true (e.g. "Zur Bestellung"). Ignored
410
+ * when `secured` is false — the CTA keeps its own default label in that case. */
411
+ secureLabel?: string;
412
+ /** secondary CTA click (phone). */
413
+ onCall?: () => void;
414
+ /** open the Finanzierungs-/Leasingdetails popup (full breakdown + legal, expanded). Omit to hide the link. */
415
+ onShowDetails?: () => void;
416
+ /** mobile only: open the "Rate anpassen" / "Details anzeigen" sheet (collapsed/default view).
417
+ * Omit to hide the trigger row (falls back to the desktop inline expander). */
418
+ onOpenAdjust?: () => void;
419
+ /** mode segment changed. */
420
+ onModeChange: (mode: FinanceMode) => void;
421
+ /** down-payment slider changed. */
422
+ onDownChange: (down: number) => void;
423
+ /** term changed. */
424
+ onTermChange: (term: number) => void;
425
+ /** whether leasing is actually offered for this car (financingConfig.leasing.isActive — same
426
+ * age/mileage-gated flag SearchResultsStore.getLeasingActive stamps for the cards, see
427
+ * cardParts.tsx's PriceTabs / toAutobahnCar.ts's `lease`). Default true keeps existing callers'
428
+ * behavior; the VDP page passes the real computed value. Hides the Leasing tab when false,
429
+ * same as the card — instead of showing a tab that would compute/display a rate the car isn't
430
+ * eligible for. */
431
+ leasingAvailable?: boolean;
432
+ /** i18n function (drilled from the page). */
433
+ t: TranslationFunction;
434
+ }
435
+
436
+ const eur = (n: number): string => n.toLocaleString('de-DE');
437
+
438
+ /** build a [min..max] step range (fallback term options when none are supplied). */
439
+ const range = (min: number, max: number, step: number): number[] => {
440
+ const out: number[] = [];
441
+ for (let v = min; v <= max; v += step || 12) out.push(v);
442
+ return out.length ? out : [min];
443
+ };
444
+
445
+ /** quiet primary-colored text link (Finanzierungsdetails / Details anzeigen). */
446
+ const DetailsLink: React.FunctionComponent<{ label: string; onClick: () => void }> = ({ label, onClick }) => (
447
+ <button
448
+ type="button"
449
+ onClick={onClick}
450
+ style={{
451
+ display: 'inline-flex',
452
+ alignItems: 'center',
453
+ gap: 5,
454
+ background: 'none',
455
+ border: 0,
456
+ padding: 0,
457
+ cursor: 'pointer',
458
+ color: 'var(--md-primary)',
459
+ font: 'inherit',
460
+ fontSize: 13,
461
+ fontWeight: 600,
462
+ }}
463
+ >
464
+ <Icon name="info" size={15} color="var(--md-primary)" />
465
+ {label}
466
+ </button>
467
+ );
468
+
469
+ /** "Rate anpassen" / "Details anzeigen" expander toggle button. */
470
+ export const expanderBtnStyle: React.CSSProperties = {
471
+ width: '100%',
472
+ background: 'none',
473
+ border: 0,
474
+ cursor: 'pointer',
475
+ display: 'flex',
476
+ alignItems: 'center',
477
+ justifyContent: 'space-between',
478
+ padding: '0 0 2px',
479
+ color: 'var(--md-primary)',
480
+ fontWeight: 600,
481
+ fontSize: 14,
482
+ };
483
+
484
+ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
485
+ mode,
486
+ price,
487
+ listPrice,
488
+ autoDeId,
489
+ ratingLabel,
490
+ monthly,
491
+ oldMonthly,
492
+ down,
493
+ term,
494
+ downMin,
495
+ downMax,
496
+ downStep = 500,
497
+ termMin,
498
+ termMax,
499
+ termStep = 6,
500
+ termOptions,
501
+ annualMileage,
502
+ annualMileageMin = 5000,
503
+ annualMileageMax = 60000,
504
+ annualMileageStep = 5000,
505
+ onAnnualMileageChange,
506
+ withFinalInstallment,
507
+ onToggleFinalInstallment,
508
+ withAddServices,
509
+ addServicesCost,
510
+ addServicesDisabled,
511
+ onToggleAddServices,
512
+ available,
513
+ phone = '0800 40 30 182',
514
+ onSecure,
515
+ secured,
516
+ secureLabel,
517
+ onCall,
518
+ onShowDetails,
519
+ onOpenAdjust,
520
+ onModeChange,
521
+ onDownChange,
522
+ onTermChange,
523
+ leasingAvailable = true,
524
+ t,
525
+ }) => {
526
+ // Pure view state only — whether the adjust/details expander is open.
527
+ const [adjust, setAdjust] = useState(false);
528
+ // whether the "UVP-Rate" footnote popover (fin/leasing) is open — same widget as CarCard's.
529
+ const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
530
+ const isCash = mode === 'cash';
531
+ const isLease = mode === 'leasing';
532
+ const terms = termOptions && termOptions.length ? termOptions : range(termMin, termMax, termStep);
533
+ const showStrike = listPrice != null && listPrice > price;
534
+ // price-evaluation tier from the rating label (defaults to 'Guter Preis' tier when unmapped).
535
+ const tierIdx = TIER_LABELS.indexOf(ratingLabel as (typeof TIER_LABELS)[number]);
536
+ const evalTier = tierIdx >= 0 ? tierIdx : 1;
537
+ const isGoodTier = TIER_KEYS[evalTier] === 'good';
538
+ // each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
539
+ // collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
540
+ const evalTierLabel = t('autobahn:tier.' + TIER_KEYS[evalTier]);
541
+ const evalPillColor = isGoodTier ? TIER_COLORS[0] : TIER_COLORS[evalTier];
542
+ // condition summary (current selection) + its own details link — financing: "0 € Anzahlung ·
543
+ // 60 Monate · Finanzierungsdetails"; leasing: "25.000 € Sonderzahlung · 60 Mon. · 10.000
544
+ // km/Jahr · Details" (same wording/order as CarCard's own PriceTerms leaseTerms).
545
+ const condParts: string[] = [];
546
+ if (mode === 'leasing') {
547
+ condParts.push(
548
+ ...t('autobahn:card.price.leaseTerms', {
549
+ firstInstallment: eur(down),
550
+ months: term,
551
+ mileage: annualMileage != null ? eur(annualMileage) : '',
552
+ }).split(' · '),
553
+ );
554
+ } else if (!isCash) {
555
+ condParts.push(t('autobahn:finance.downPaymentLabel', { value: eur(down) }));
556
+ condParts.push(t('autobahn:finance.monthsLabel', { months: term, count: term }));
557
+ }
558
+
559
+ return (
560
+ <div className="mcard mcard--elevated fin-calc-card" style={{ padding: 20 }}>
561
+ {/* header — desktop only; mobile goes straight into the tabs (see mockup: no card
562
+ title above Finanzierung/Leasing/Kaufen on phone). */}
563
+ <div className="fin-card-header hide-mobile" style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 14 }}>
564
+ <span
565
+ style={{
566
+ width: 34,
567
+ height: 34,
568
+ borderRadius: 'var(--md-r-full)',
569
+ background: 'var(--md-primary-container)',
570
+ display: 'flex',
571
+ alignItems: 'center',
572
+ justifyContent: 'center',
573
+ flex: 'none',
574
+ }}
575
+ >
576
+ <Icon name="tag" size={18} color="var(--md-on-primary-container)" />
577
+ </span>
578
+ <div style={{ fontFamily: 'var(--md-font-display)', fontSize: 18, fontWeight: 700 }}>{t('autobahn:finance.headerTitle')}</div>
579
+ </div>
580
+
581
+ {/* payment-type TABS on top — Leasing omitted when the car isn't leasing-eligible, same
582
+ rule cardParts.tsx's PriceTabs already applies (car.lease != null there). */}
583
+ <div className="fin-tabs" role="tablist">
584
+ {(
585
+ [
586
+ ['fin', 'autobahn:finance.mode.financing'],
587
+ ...(leasingAvailable ? ([['leasing', 'autobahn:finance.mode.leasing']] as Array<[FinanceMode, string]>) : []),
588
+ ['cash', 'autobahn:finance.mode.cash'],
589
+ ] as Array<[FinanceMode, string]>
590
+ ).map(([k, labelKey]) => (
591
+ <button
592
+ key={k}
593
+ type="button"
594
+ role="tab"
595
+ aria-selected={mode === k}
596
+ className={'fin-tab' + (mode === k ? ' on' : '')}
597
+ onClick={() => onModeChange(k)}
598
+ >
599
+ {k === 'cash' ? (
600
+ <>
601
+ {/* cash tab is "Kaufen" on both phone and desktop now — same key both spans. */}
602
+ <span className="hide-mobile">{t('autobahn:card.price.buy')}</span>
603
+ <span className="show-mobile" style={{ justifyContent: 'center' }}>
604
+ {t('autobahn:card.price.buy')}
605
+ </span>
606
+ </>
607
+ ) : (
608
+ t(labelKey)
609
+ )}
610
+ </button>
611
+ ))}
612
+ </div>
613
+
614
+ {/* 2-col grid: rate|pill (row 1) + condLine|bar (row 2) — fixed right column prevents wrapping */}
615
+ <div className={'fin-price-grid' + (isCash ? ' fin-price-grid--cash' : '')}>
616
+ {/* col 1 row 1: hero rate — Figma: "329 €" all-big, then a small stacked column with
617
+ the struck old rate ABOVE "/mtl." (round 11; was a single baseline row) */}
618
+ <div className="fin-rate-main">
619
+ {/* mobile Kaufen (Figma round 14): struck list price ABOVE the price, right-aligned,
620
+ tight to the figure — replaces the Festpreis + UVP lines, which stay desktop-only */}
621
+ {isCash && showStrike && (
622
+ <div
623
+ className="show-mobile"
624
+ style={{ justifyContent: 'flex-end', alignItems: 'baseline', gap: 4, lineHeight: 1, marginTop: 7 }}
625
+ role="button"
626
+ tabIndex={0}
627
+ onClick={() => setUvpTooltipOpen((v) => !v)}
628
+ >
629
+ <span style={{ fontSize: 13, color: 'var(--md-on-surface-variant)' }}>{t('autobahn:finance.uvp')}</span>
630
+ <span
631
+ className={`num pp-hero-old${
632
+ String(Math.round(listPrice as number)).length === 5
633
+ ? ' pp-hero-old--len5'
634
+ : String(Math.round(listPrice as number)).length === 4
635
+ ? ' pp-hero-old--len4'
636
+ : ''
637
+ }`}
638
+ >
639
+ {eur(Math.round(listPrice as number))} €
640
+ <span
641
+ className="pp-eyebrow-badge"
642
+ role="button"
643
+ tabIndex={0}
644
+ onClick={(e) => {
645
+ e.stopPropagation();
646
+ setUvpTooltipOpen((v) => !v);
647
+ }}
648
+ >
649
+ 2
650
+ </span>
651
+ {uvpTooltipOpen && (
652
+ <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
653
+ <button
654
+ type="button"
655
+ className="pp-uvp-tooltip-close"
656
+ aria-label={t('autobahn:modal.close')}
657
+ onClick={(e) => {
658
+ e.stopPropagation();
659
+ setUvpTooltipOpen(false);
660
+ }}
661
+ >
662
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
663
+ <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
664
+ </svg>
665
+ </button>
666
+ <div className="pp-uvp-tooltip-body">{t('autobahn:card.price.uvpListTooltipBody')}</div>
667
+ </div>
668
+ )}
669
+ </span>
670
+ </div>
671
+ )}
672
+ {/* desktop: same struck list price ABOVE the rate, same fin-rate-old-list styling +
673
+ clickable UVP badge/tooltip as the mobile sheet's own Kaufen block.
674
+ Wrapper now renders on EVERY Kaufen car (isCash alone, not isCash && showStrike) —
675
+ cross-tab height parity (md3.css) reserves this row's height once, assuming it's
676
+ always there; a car with no discount used to skip it entirely, landing .fin-rate-main
677
+ (and the whole card) ~20px shorter than a discounted one and breaking that parity.
678
+ fin-rate-strike-slot (md3.css) gives it a fixed height so the slot itself doesn't
679
+ move even though the <s> price inside is still conditional on showStrike. */}
680
+ {isCash && (
681
+ <div
682
+ className="hide-mobile fin-rate-strike-slot"
683
+ style={{ display: 'flex', justifyContent: 'flex-end', lineHeight: 1, marginTop: 0, cursor: showStrike ? 'pointer' : 'default' }}
684
+ role="button"
685
+ tabIndex={0}
686
+ onClick={() => setUvpTooltipOpen((v) => !v)}
687
+ >
688
+ {showStrike && (
689
+ <s className="num fin-rate-old fin-rate-old-list">
690
+ {eur(listPrice as number)} €
691
+ <span
692
+ className="pp-eyebrow-badge"
693
+ role="button"
694
+ tabIndex={0}
695
+ onClick={(e) => {
696
+ e.stopPropagation();
697
+ setUvpTooltipOpen((v) => !v);
698
+ }}
699
+ >
700
+ 2
701
+ </span>
702
+ {uvpTooltipOpen && (
703
+ <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
704
+ <button
705
+ type="button"
706
+ className="pp-uvp-tooltip-close"
707
+ aria-label={t('autobahn:modal.close')}
708
+ onClick={(e) => {
709
+ e.stopPropagation();
710
+ setUvpTooltipOpen(false);
711
+ }}
712
+ >
713
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
714
+ <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
715
+ </svg>
716
+ </button>
717
+ <div className="pp-uvp-tooltip-body">{t('autobahn:card.price.uvpListTooltipBody')}</div>
718
+ </div>
719
+ )}
720
+ </s>
721
+ )}
722
+ </div>
723
+ )}
724
+ <div style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
725
+ {isCash ? (
726
+ <>
727
+ {/* phone: ONE unbreakable "13.249 €" span (a separate € span wraps to its own
728
+ line); desktop keeps the number + quiet small € pair */}
729
+ <span
730
+ className={`num show-mobile fin-rate-cash-mobile${
731
+ (() => {
732
+ const digits = String(Math.round(price as number)).length;
733
+ if (digits >= 8) return ' fin-rate-cash-mobile--len8';
734
+ if (digits === 7) return ' fin-rate-cash-mobile--len7';
735
+ if (digits === 6) return ' fin-rate-cash-mobile--len6';
736
+ return '';
737
+ })()
738
+ }`}
739
+ style={{ fontSize: 48, fontWeight: 800, color: 'var(--md-primary)', letterSpacing: '-2px', whiteSpace: 'nowrap' }}
740
+ >
741
+ {eur(price)} €<sup>1</sup>
742
+ </span>
743
+ <span
744
+ className="num hide-mobile"
745
+ style={{ fontSize: 45, fontWeight: 800, color: 'var(--md-primary)', letterSpacing: '-2px' }}
746
+ >
747
+ {eur(price)} €<sup>1</sup>
748
+ </span>
749
+ </>
750
+ ) : (
751
+ <>
752
+ <span
753
+ className={`num fin-rate-hero${
754
+ (() => {
755
+ const digits = String(Math.round(monthly)).length;
756
+ if (digits >= 6) return ' fin-rate-hero--len6';
757
+ if (digits === 5) return ' fin-rate-hero--len5';
758
+ if (digits === 4) return ' fin-rate-hero--len4';
759
+ return '';
760
+ })()
761
+ }`}
762
+ style={{ fontSize: 48, fontWeight: 800, color: 'var(--md-primary)', letterSpacing: '-2px' }}
763
+ >
764
+ {eur(Math.round(monthly))}<span style={{ marginLeft: 6 }}>€</span>
765
+ </span>
766
+ <span className="fin-rate-unit">
767
+ {/* struck old rate (REAL oldMonthlyInstallment; SRP strikes the same source) */}
768
+ {oldMonthly != null && (
769
+ <span
770
+ style={{ display: 'flex', flexDirection: 'column', cursor: 'pointer' }}
771
+ role="button"
772
+ tabIndex={0}
773
+ onClick={() => setUvpTooltipOpen((v) => !v)}
774
+ >
775
+ <span className="pp-eyebrow">
776
+ {t('autobahn:card.price.uvpRateLabel')}
777
+ <span
778
+ className="pp-eyebrow-badge"
779
+ role="button"
780
+ tabIndex={0}
781
+ onClick={(e) => {
782
+ e.stopPropagation();
783
+ setUvpTooltipOpen((v) => !v);
784
+ }}
785
+ >
786
+ 3
787
+ </span>
788
+ {uvpTooltipOpen && (
789
+ <div
790
+ className={'pp-uvp-tooltip' + (mode === 'leasing' ? ' pp-uvp-tooltip--leasing' : '')}
791
+ onClick={(e) => e.stopPropagation()}
792
+ >
793
+ <button
794
+ type="button"
795
+ className="pp-uvp-tooltip-close"
796
+ aria-label={t('autobahn:modal.close')}
797
+ onClick={(e) => {
798
+ e.stopPropagation();
799
+ setUvpTooltipOpen(false);
800
+ }}
801
+ >
802
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
803
+ <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
804
+ </svg>
805
+ </button>
806
+ <div className="pp-uvp-tooltip-body">
807
+ {t(
808
+ mode === 'leasing'
809
+ ? 'autobahn:card.price.uvpRateTooltipBodyLeasing'
810
+ : 'autobahn:card.price.uvpRateTooltipBody',
811
+ )}
812
+ </div>
813
+ </div>
814
+ )}
815
+ </span>
816
+ <s
817
+ className={`num fin-rate-old fin-rate-example-price${
818
+ String(Math.round(oldMonthly)).length >= 5
819
+ ? ' fin-rate-example-price--len5'
820
+ : String(Math.round(oldMonthly)).length === 4
821
+ ? ' fin-rate-example-price--len4'
822
+ : ''
823
+ }`}
824
+ >
825
+ {eur(Math.round(oldMonthly))} €
826
+ </s>
827
+ </span>
828
+ )}
829
+ {/* no struck old rate above it (strike hidden) — nudge "/mtl." down so it
830
+ sits level with the blue hero rate instead of centering high in the row. */}
831
+ <span
832
+ className="fin-rate-example-suffix"
833
+ style={oldMonthly == null ? { paddingTop: 20 } : undefined}
834
+ >
835
+ {t('autobahn:finance.perMonth')}
836
+ </span>
837
+ </span>
838
+ </>
839
+ )}
840
+ </div>
841
+ {isCash && <div className="md-label-sm hide-mobile">{t('autobahn:finance.fixedPrice')}</div>}
842
+ </div>
843
+ {/* col 2: pill + eval bar grouped together (display:contents on desktop — no-op,
844
+ preserves the original rate|pill / cond|bar auto-placement; mobile turns this into
845
+ a real flex column so the two stack tight with a fixed 16px gap). */}
846
+ <div className="fin-eval-col">
847
+ {/* col 2 row 1: price-rating pill (Figma: bold colored label, NO icon) */}
848
+ <div className="fin-eval-pill-cell">
849
+ {ratingLabel && (
850
+ <span
851
+ className={`fin-eval-pill${isGoodTier ? ' fin-eval-pill--good' : ''}`}
852
+ style={{ color: evalPillColor, background: `color-mix(in srgb, ${evalPillColor} 16%, transparent)` }}
853
+ aria-label={t('autobahn:finance.priceRatingAria', { rating: evalTierLabel })}
854
+ >
855
+ {evalTierLabel}
856
+ {isGoodTier && <sup>4</sup>}
857
+ </span>
858
+ )}
859
+ </div>
860
+ {/* segmented evaluation bar (Figma: discrete tiers, not a gradient) */}
861
+ <div className="fin-eval-bar-cell">{ratingLabel && <EvalBar tier={evalTier} />}</div>
862
+ </div>
863
+ {/* col 1 row 2: condition line — financing "0 € Anzahlung · 60 Monate · Finanzierungsdetails",
864
+ leasing "25.000 € Sonderzahlung · 60 Mon. · 10.000 km/Jahr · Details". Buy has nothing
865
+ to show here (no down payment/term/details link of its own) — not rendered at all
866
+ rather than left as an empty reserved-height div. */}
867
+ {!isCash && (
868
+ <div className="fin-cond">
869
+ {condParts.map((part, i) => (
870
+ <React.Fragment key={i}>
871
+ {i > 0 && <span className="cc-terms-dot"> · </span>}
872
+ {part}
873
+ </React.Fragment>
874
+ ))}
875
+ {onShowDetails && (
876
+ <>
877
+ <span className="cc-terms-dot"> · </span>
878
+ {/* plain underlined text link, same onShowDetails handler as .fin-info used to open. */}
879
+ <button type="button" className="cc-terms-link" onClick={onShowDetails}>
880
+ {mode === 'leasing' ? t('autobahn:card.price.detailsLink') : t('autobahn:finance.financingDetails')}
881
+ </button>
882
+ </>
883
+ )}
884
+ </div>
885
+ )}
886
+ </div>
887
+
888
+ {/* ADV-405/406 Kreditkosten-Hinweis — Preis-Card (mobile) + „Dein Angebot“ (desktop): below the
889
+ conditions line, above „Angebot anfragen“/„Anrufen“ (mobile) or „Rate anpassen“ (desktop).
890
+ Not on Kaufen (no reserved space — the Kaufen view stays exactly as before). */}
891
+ {!isCash && <CreditCostNotice t={t} cls="fin-ccn" />}
892
+
893
+ {/* ============================== DESKTOP (≥601px) — unchanged ============================== */}
894
+ <div className="hide-mobile">
895
+ {/* RATE EDIT (Rate anpassen) — between the rate and the request CTA. fin-adjust--cash:
896
+ Kaufen-only margin-top override (0, was the shared 14px) — see md3.css. */}
897
+ <div className={'fin-adjust' + (isCash ? ' fin-adjust--cash' : '')}>
898
+ <button onClick={() => setAdjust((a) => !a)} style={expanderBtnStyle}>
899
+ <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7 }}>
900
+ <Icon name={isCash ? 'list' : 'sliders-horizontal'} size={16} color="var(--md-primary)" />
901
+ {isCash ? t('autobahn:finance.detailsShow') : t('autobahn:finance.adjustRate')}
902
+ </span>
903
+ <Icon name={adjust ? 'chevron-up' : 'chevron-down'} size={18} color="var(--md-primary)" />
904
+ </button>
905
+ {adjust &&
906
+ (isCash ? (
907
+ <>
908
+ <div style={{ marginTop: 4 }}>
909
+ <CalcRow label={t('autobahn:finance.paymentLabel')} last={!available && !(addServicesCost != null && onToggleAddServices)}>{t('autobahn:finance.paymentValue')}</CalcRow>
910
+ {available && (
911
+ <CalcRow label={t('autobahn:finance.availabilityLabel')} last={!(addServicesCost != null && onToggleAddServices)}>
912
+ {t('autobahn:finance.availabilityValue')}
913
+ </CalcRow>
914
+ )}
915
+ </div>
916
+ {addServicesCost != null && onToggleAddServices && (
917
+ <ToggleRow
918
+ className="fin-toggle-addservices fin-toggle-addservices--cash"
919
+ label={t('autobahn:finance.addServicesToggle')}
920
+ price={t('autobahn:finance.addServicesOnce', { value: eur(Math.round(addServicesCost)) })}
921
+ checked={!!withAddServices}
922
+ disabled={addServicesDisabled}
923
+ onChange={onToggleAddServices}
924
+ staticNote={t('autobahn:finance.addServicesIncluded')}
925
+ tooltip={<AddServicesTooltipBody t={t} isCash />}
926
+ tooltipCloseLabel={t('autobahn:modal.close')}
927
+ t={t}
928
+ />
929
+ )}
930
+ </>
931
+ ) : (
932
+ <div style={{ display: 'flex', flexDirection: 'column', marginTop: 8 }}>
933
+ <div style={{ marginBottom: 15 }}>
934
+ <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
935
+ <span className="md-title-sm">{t('autobahn:finance.downPaymentSliderLabel')}</span>
936
+ <span className="num" style={{ fontWeight: 700 }}>
937
+ {eur(down)} €
938
+ </span>
939
+ </div>
940
+ <Slider
941
+ min={downMin}
942
+ max={downMax}
943
+ step={downStep}
944
+ value={down}
945
+ onChange={onDownChange}
946
+ fmt={(v) => `${eur(Number(v))} €`}
947
+ />
948
+ </div>
949
+ {annualMileage != null && onAnnualMileageChange && (
950
+ <div style={{ marginBottom: 15 }}>
951
+ <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
952
+ <span className="md-title-sm">{t('autobahn:finance.annualMileageLabel')}</span>
953
+ <span className="num" style={{ fontWeight: 700 }}>
954
+ {eur(annualMileage)} km
955
+ </span>
956
+ </div>
957
+ <Slider
958
+ min={annualMileageMin}
959
+ max={annualMileageMax}
960
+ step={annualMileageStep}
961
+ value={annualMileage}
962
+ onChange={onAnnualMileageChange}
963
+ fmt={(v) => `${eur(Number(v))} km`}
964
+ />
965
+ </div>
966
+ )}
967
+ <div style={{ marginBottom: 15 }}>
968
+ <div className="md-title-sm" style={{ marginBottom: 8 }}>
969
+ {t('autobahn:finance.termSelection')}
970
+ </div>
971
+ <TermChips options={terms.filter((v) => v !== 12 && v !== 96)} value={term} onChange={onTermChange} t={t} />
972
+ </div>
973
+ {/* same Mit-Schlussrate / Rundum-Sorglos-Paket toggles as the mobile sheet / modal
974
+ desktop block — replaces the static Kaufpreis/Garantie/Lieferung rows. */}
975
+ {!isLease && onToggleFinalInstallment && (
976
+ <ToggleRow
977
+ className="fin-toggle-final"
978
+ label={t('autobahn:finance.finalInstallmentToggle')}
979
+ checked={!!withFinalInstallment}
980
+ onChange={onToggleFinalInstallment}
981
+ />
982
+ )}
983
+ {addServicesCost != null && onToggleAddServices && (
984
+ <ToggleRow
985
+ className={'fin-toggle-addservices' + (isLease ? ' fin-toggle-addservices--leasing' : '')}
986
+ label={t('autobahn:finance.addServicesToggle')}
987
+ price={t('autobahn:finance.addServicesPerMonth', { value: eur(Math.round(addServicesCost)) })}
988
+ checked={!!withAddServices}
989
+ disabled={addServicesDisabled}
990
+ onChange={onToggleAddServices}
991
+ tooltip={<AddServicesTooltipBody t={t} isLease={isLease} />}
992
+ tooltipCloseLabel={t('autobahn:modal.close')}
993
+ t={t}
994
+ />
995
+ )}
996
+ </div>
997
+ ))}
998
+ </div>
999
+
1000
+ {/* REQUEST CTA */}
1001
+ <Button
1002
+ variant="filled"
1003
+ block
1004
+ size="lg"
1005
+ icon="shield-check"
1006
+ className={secured ? 'fin-cta-secured' : undefined}
1007
+ style={{ marginTop: 14 }}
1008
+ onClick={onSecure}
1009
+ >
1010
+ {secured && secureLabel ? secureLabel : t('autobahn:finance.secureOffer')}
1011
+ </Button>
1012
+ {/* phone CTA — touch only (hidden on desktop via .fin-call) */}
1013
+ <div className="fin-call">
1014
+ <Button variant="outlined" block icon="phone" onClick={onCall}>
1015
+ {phone}
1016
+ </Button>
1017
+ </div>
1018
+
1019
+ {/* auto.de-ID in front of the Finanzierungs-/Leasingdetails link — one row, under everything */}
1020
+ {(autoDeId || (!isCash && onShowDetails)) && (
1021
+ <div className="fin-info">
1022
+ {autoDeId && <span className="fin-id">auto.de-ID {autoDeId}</span>}
1023
+ {!isCash && onShowDetails && (
1024
+ <DetailsLink
1025
+ label={mode === 'leasing' ? t('autobahn:finance.leasingDetails') : t('autobahn:finance.financingDetails')}
1026
+ onClick={onShowDetails}
1027
+ />
1028
+ )}
1029
+ </div>
1030
+ )}
1031
+ </div>
1032
+
1033
+ {/* ============================== MOBILE (≤600px) — new layout ============================== */}
1034
+ <div className="show-mobile" style={{ flexDirection: 'column' }}>
1035
+ {/* side-by-side CTAs — mockup ratio ~2:1, with the tiny auto.de-ID sitting
1036
+ directly under the Anrufen button (not in its own full-width row). */}
1037
+ <div className="fin-cta-row" style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
1038
+ {/* Figma CTA icon: document + check badge (composed — no single lucide glyph) */}
1039
+ <Button
1040
+ variant="filled"
1041
+ size="lg"
1042
+ className={secured ? 'fin-cta-secured' : undefined}
1043
+ style={{ width: 216, height: 50, paddingLeft: 0, paddingRight: 9, gap: secured ? 3 : 18 }}
1044
+ onClick={onSecure}
1045
+ >
1046
+ {/* size 23 either way — was 18 for the secured (shield-check) state, notably
1047
+ smaller than DocCheckIcon's 23 in the default state despite sharing the exact
1048
+ same 50px button box; nothing about switching to "already secured" should
1049
+ shrink the icon. */}
1050
+ {secured ? <Icon name="shield-check" size={23} /> : <DocCheckIcon size={23} />}
1051
+ {secured && secureLabel ? secureLabel : t('autobahn:finance.secureOffer')}
1052
+ </Button>
1053
+ <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 4, minWidth: 0 }}>
1054
+ <Button variant="outlined" size="lg" icon="phone" style={{ width: 112, height: 50 }} onClick={onCall}>
1055
+ {t('autobahn:finance.callCta')}
1056
+ </Button>
1057
+ {autoDeId && (
1058
+ <span
1059
+ className="num"
1060
+ style={{ fontSize: 10, fontWeight: 700, color: 'var(--md-primary)', textAlign: 'center', whiteSpace: 'nowrap' }}
1061
+ >
1062
+ auto.de ID: {autoDeId}
1063
+ </span>
1064
+ )}
1065
+ </div>
1066
+ </div>
1067
+
1068
+ {/* Persönliche Beratung — icon + one line (the details link now lives in .fin-cond above) */}
1069
+ <div className="fin-info" style={{ justifyContent: 'flex-start', paddingLeft: 15 }}>
1070
+ <Icon name="user" size={26} color="var(--md-on-surface-variant)" style={{ flex: 'none', marginRight: 20 }} />
1071
+ <span className="fin-info-line">{t('autobahn:finance.personalConsultationLine')}</span>
1072
+ </div>
1073
+
1074
+ {/* "Rate anpassen" / "Details anzeigen" — opens the full bottom sheet (not an inline expander) */}
1075
+ {onOpenAdjust && (
1076
+ <button
1077
+ type="button"
1078
+ onClick={onOpenAdjust}
1079
+ style={{ ...expanderBtnStyle, borderTop: '1px solid var(--md-outline-variant)', marginTop: 11, padding: '11px 0 2px 21px' }}
1080
+ >
1081
+ <span style={{ display: 'inline-flex', alignItems: 'center', gap: 21 }}>
1082
+ <Icon name="sliders-horizontal" size={23} color="var(--md-primary)" />
1083
+ <span className="fin-adjust-btn-label">
1084
+ {isCash ? t('autobahn:finance.detailsShow') : t('autobahn:finance.adjustRate')}
1085
+ </span>
1086
+ </span>
1087
+ <Icon name="chevron-right" size={23} color="var(--md-primary)" />
1088
+ </button>
1089
+ )}
1090
+ </div>
1091
+ </div>
1092
+ );
1093
+ };
1094
+
1095
+ export default FinanceCalculator;