@bytebrand/fe-ui-core-autobahn 1.0.169 → 1.0.171
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.
- package/cards/CarCard.tsx +47 -10
- package/cards/CarRow.tsx +5 -1
- package/cards/cardParts.tsx +11 -1
- package/chrome/AccountMenuIcon.tsx +20 -2
- package/chrome/TopBar.tsx +28 -17
- package/constants/app.ts +11 -1
- package/constants/core.ts +12 -1
- package/locales/de/autobahn.json +4 -2
- package/locales/en/autobahn.json +4 -2
- package/locales/legacy/data.ts +2 -1
- package/package.json +1 -1
- package/theme/md3.css +6 -3
- package/ui/Dropdown.tsx +16 -8
- package/ui/index.ts +2 -0
- package/ui/scrollFieldIntoView.ts +41 -0
- package/ui/usePortalMenuPosition.ts +14 -12
- package/utils/index.ts +2 -0
- package/vdp/VdpModules.tsx +3 -3
- package/vdp/types.ts +5 -5
- package/vehiclesProps/accidentDisclosure.ts +25 -0
- package/vehiclesProps/decoratedLightProps.tsx +20 -6
- package/vehiclesProps/decoratedProps.tsx +12 -4
package/cards/CarCard.tsx
CHANGED
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
GalleryActivityPill,
|
|
39
39
|
cardSpec,
|
|
40
40
|
PaymentMode,
|
|
41
|
+
startPaymentMode,
|
|
41
42
|
callDealerSalesPhone,
|
|
42
43
|
DEALER_SALES_PHONE,
|
|
43
44
|
} from './cardParts';
|
|
@@ -98,6 +99,11 @@ export interface CarCardProps {
|
|
|
98
99
|
* (still onOpenRateAdjust).
|
|
99
100
|
*/
|
|
100
101
|
onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Tab the price block opens on (default Finanzierung) — e.g. the SRP's leasing-only results
|
|
104
|
+
* open every card on Leasing. Ignored for a car without a lease rate (it has no Leasing tab).
|
|
105
|
+
*/
|
|
106
|
+
initialMode?: PaymentMode;
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
@@ -113,8 +119,9 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
113
119
|
onCall,
|
|
114
120
|
onOpenRateAdjust,
|
|
115
121
|
onShowFinancingDetails,
|
|
122
|
+
initialMode,
|
|
116
123
|
}) => {
|
|
117
|
-
const [mode, setMode] = useState<PaymentMode>(
|
|
124
|
+
const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
|
|
118
125
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
119
126
|
const [viewerOpen, setViewerOpen] = useState(false);
|
|
120
127
|
const mediaRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -157,6 +164,8 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
157
164
|
// active that's already 3, so NEU is dropped rather than causing a 4th to overflow.
|
|
158
165
|
const activeDealChips = [showDrop || showSave, showPct, !!car.zeroDown].filter(Boolean).length;
|
|
159
166
|
const showNeu = asGoodAsNew && car.isNew && activeDealChips < 3;
|
|
167
|
+
// tabs the price block can switch to (PriceTabs shows Leasing only when the car has a lease rate)
|
|
168
|
+
const paymentModes: PaymentMode[] = car.lease != null ? ['financing', 'leasing', 'buy'] : ['financing', 'buy'];
|
|
160
169
|
return (
|
|
161
170
|
<article
|
|
162
171
|
className="mcard mcard--interactive cc-card"
|
|
@@ -277,18 +286,46 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
277
286
|
<div className="cc-price" style={{ marginTop: 0, borderTop: '1px solid var(--md-outline-variant)' }}>
|
|
278
287
|
<PriceTabs car={car} mode={mode} onModeChange={setMode} t={t} />
|
|
279
288
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 10 }}>
|
|
280
|
-
|
|
289
|
+
{/* every tab's hero stacked in one grid cell (.cc-hero-stack), only the active one
|
|
290
|
+
visible, bottom-aligned — Kaufen's struck list price sits on its own line above
|
|
291
|
+
the price, so without this the row (and the card) grew/shrank by that line on
|
|
292
|
+
every tab switch. Same trick as .cc-terms-stack below. */}
|
|
293
|
+
<div className="cc-hero-stack">
|
|
294
|
+
{paymentModes.map((m) => (
|
|
295
|
+
<div
|
|
296
|
+
key={m}
|
|
297
|
+
className={'cc-hero-slot' + (m === mode ? '' : ' cc-hero-slot--hidden')}
|
|
298
|
+
aria-hidden={m === mode ? undefined : true}
|
|
299
|
+
>
|
|
300
|
+
<PriceHero car={car} mode={m} t={t} alwaysShowUnit />
|
|
301
|
+
</div>
|
|
302
|
+
))}
|
|
303
|
+
</div>
|
|
281
304
|
<PriceEvalCol car={car} t={t} />
|
|
282
305
|
</div>
|
|
283
306
|
{/* same fallback CardCtaRow already uses below: pages that haven't wired a real
|
|
284
|
-
"Rate anpassen" sheet yet still get a working "Details" link (opens the car).
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
307
|
+
"Rate anpassen" sheet yet still get a working "Details" link (opens the car).
|
|
308
|
+
Every tab's terms line is rendered into the same grid cell (.cc-terms-stack) and
|
|
309
|
+
only the active one is visible — the cell is as tall as the tallest line, so the
|
|
310
|
+
card keeps one height across Finanzierung/Leasing/Kaufen (Leasing's longer line
|
|
311
|
+
wraps to 2 lines on narrow phones). No change to the visible line itself. */}
|
|
312
|
+
<div className="cc-terms-stack">
|
|
313
|
+
{paymentModes.map((m) => (
|
|
314
|
+
<div
|
|
315
|
+
key={m}
|
|
316
|
+
className={'cc-terms-slot' + (m === mode ? '' : ' cc-terms-slot--hidden')}
|
|
317
|
+
aria-hidden={m === mode ? undefined : true}
|
|
318
|
+
>
|
|
319
|
+
<PriceTerms
|
|
320
|
+
car={car}
|
|
321
|
+
mode={m}
|
|
322
|
+
onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
|
|
323
|
+
onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, m) : undefined}
|
|
324
|
+
t={t}
|
|
325
|
+
/>
|
|
326
|
+
</div>
|
|
327
|
+
))}
|
|
328
|
+
</div>
|
|
292
329
|
</div>
|
|
293
330
|
{/* Mobile-only row (CardCtaRow itself carries the show-mobile class) — always
|
|
294
331
|
rendered, with real fallbacks the page can override once it wires its own
|
package/cards/CarRow.tsx
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
ZeroDownChip,
|
|
42
42
|
fmtKm,
|
|
43
43
|
PaymentMode,
|
|
44
|
+
startPaymentMode,
|
|
44
45
|
ratingTone,
|
|
45
46
|
} from './cardParts';
|
|
46
47
|
import { AutobahnCar } from './types';
|
|
@@ -80,6 +81,8 @@ export interface CarRowProps {
|
|
|
80
81
|
* links render as plain text (see PricePaths' own fallback).
|
|
81
82
|
*/
|
|
82
83
|
onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
|
|
84
|
+
/** Tab the mobile price tabs open on — see CarCard's identically-named prop. */
|
|
85
|
+
initialMode?: PaymentMode;
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
@@ -92,8 +95,9 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
92
95
|
t,
|
|
93
96
|
adminAction,
|
|
94
97
|
onShowFinancingDetails,
|
|
98
|
+
initialMode,
|
|
95
99
|
}) => {
|
|
96
|
-
const [mode, setMode] = useState<PaymentMode>(
|
|
100
|
+
const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
|
|
97
101
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
98
102
|
const mediaRef = useRef<HTMLDivElement | null>(null);
|
|
99
103
|
// always call the LATEST onMediaEnter without re-arming the observer on every render (the
|
package/cards/cardParts.tsx
CHANGED
|
@@ -489,6 +489,11 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
|
|
|
489
489
|
|
|
490
490
|
export type PaymentMode = 'financing' | 'leasing' | 'buy';
|
|
491
491
|
|
|
492
|
+
/** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
|
|
493
|
+
* without a lease rate — PriceTabs has no Leasing tab for it. */
|
|
494
|
+
export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
|
|
495
|
+
requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
|
|
496
|
+
|
|
492
497
|
export interface PriceTabsProps {
|
|
493
498
|
car: AutobahnCar;
|
|
494
499
|
mode: PaymentMode;
|
|
@@ -710,7 +715,12 @@ export const PriceTerms: React.FunctionComponent<{
|
|
|
710
715
|
onShowDetails?: () => void;
|
|
711
716
|
t: TranslationFunction;
|
|
712
717
|
}> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
|
|
713
|
-
|
|
718
|
+
// Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
|
|
719
|
+
// here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
|
|
720
|
+
// real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
|
|
721
|
+
// every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
|
|
722
|
+
// FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
|
|
723
|
+
if (mode === 'buy') return <div className="cc-terms" />;
|
|
714
724
|
const finFirstInstallment =
|
|
715
725
|
car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
|
|
716
726
|
const finMonths = car.finMonths ?? _finMonths;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
export type AccountMenuIconName =
|
|
4
|
-
| 'layout-grid' | 'car-front' | 'bookmark' | 'star' | 'scale' | 'user' | 'help-circle' | 'log-out'
|
|
4
|
+
| 'layout-grid' | 'car-front' | 'bookmark' | 'star' | 'scale' | 'user' | 'help-circle' | 'log-out'
|
|
5
|
+
| 'settings' | 'store';
|
|
6
|
+
type FilledIconName = 'settings' | 'store';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Row icons of the Konto menu (Figma "Konto / Kontomenü", 64243:14111): Lucide-style glyphs in a
|
|
@@ -9,7 +11,7 @@ export type AccountMenuIconName =
|
|
|
9
11
|
* square-cornered, unlike lucide-react 0.288's — so the paths are Figma's export, not the lib Icon.
|
|
10
12
|
* `at` moves each export to where Figma places it in the frame: the group inset minus half the stroke.
|
|
11
13
|
*/
|
|
12
|
-
const GLYPHS: Record<AccountMenuIconName, { at: [number, number]; d: string[] }> = {
|
|
14
|
+
const GLYPHS: Record<Exclude<AccountMenuIconName, FilledIconName>, { at: [number, number]; d: string[] }> = {
|
|
13
15
|
'layout-grid': {
|
|
14
16
|
at: [1.85, 1.85],
|
|
15
17
|
d: [
|
|
@@ -66,7 +68,23 @@ const GLYPHS: Record<AccountMenuIconName, { at: [number, number]; d: string[] }>
|
|
|
66
68
|
},
|
|
67
69
|
};
|
|
68
70
|
|
|
71
|
+
/** Filled Material glyphs supplied for the role rows (2026-10-28): "settings" (Bildeinstellungen)
|
|
72
|
+
* and "store" (the dealer rows). Unlike the stroked Figma glyphs they are filled 24-unit glyphs;
|
|
73
|
+
* viewBox 1 1 22 22 only trims their empty margin, so they keep their own size in the 22px frame.
|
|
74
|
+
* Their masks were full 24px rects (no-ops), so dropped. */
|
|
75
|
+
const FILLED: Record<FilledIconName, string> = {
|
|
76
|
+
settings: 'M13.5 21.5H10.475C10.2583 21.5 10.0667 21.425 9.9 21.275C9.73334 21.125 9.63334 20.9333 9.6 20.7L9.3 18.45C9.03334 18.3667 8.76267 18.2417 8.488 18.075C8.21267 17.9083 7.95834 17.7333 7.725 17.55L5.65 18.45C5.43334 18.5333 5.221 18.5417 5.013 18.475C4.80434 18.4083 4.63334 18.275 4.5 18.075L3 15.45C2.88334 15.25 2.85 15.0373 2.9 14.812C2.95 14.5873 3.05834 14.4083 3.225 14.275L5.05 12.9C5.01667 12.75 4.996 12.6 4.988 12.45C4.97934 12.3 4.975 12.15 4.975 12C4.975 11.8667 4.97934 11.725 4.988 11.575C4.996 11.425 5.01667 11.2667 5.05 11.1L3.225 9.725C3.05834 9.59167 2.95 9.41267 2.9 9.188C2.85 8.96267 2.88334 8.75 3 8.55L4.5 5.95C4.61667 5.75 4.78334 5.61667 5 5.55C5.21667 5.48333 5.425 5.49167 5.625 5.575L7.725 6.45C7.95834 6.26667 8.21267 6.096 8.488 5.938C8.76267 5.77933 9.03334 5.65 9.3 5.55L9.6 3.3C9.63334 3.06667 9.73334 2.875 9.9 2.725C10.0667 2.575 10.2583 2.5 10.475 2.5H13.5C13.7333 2.5 13.9333 2.575 14.1 2.725C14.2667 2.875 14.3667 3.06667 14.4 3.3L14.7 5.55C15 5.66667 15.2707 5.79567 15.512 5.937C15.754 6.079 16 6.25 16.25 6.45L18.375 5.575C18.575 5.49167 18.7793 5.48333 18.988 5.55C19.196 5.61667 19.3667 5.75 19.5 5.95L21 8.55C21.1167 8.75 21.15 8.96267 21.1 9.188C21.05 9.41267 20.9417 9.59167 20.775 9.725L18.925 11.125C18.9583 11.2917 18.975 11.4417 18.975 11.575V12C18.975 12.1333 18.9707 12.2707 18.962 12.412C18.954 12.554 18.9333 12.7167 18.9 12.9L20.725 14.275C20.9083 14.4083 21.025 14.5873 21.075 14.812C21.125 15.0373 21.0833 15.25 20.95 15.45L19.45 18.05C19.3333 18.25 19.1667 18.3833 18.95 18.45C18.7333 18.5167 18.5167 18.5083 18.3 18.425L16.25 17.55C16 17.75 15.746 17.925 15.488 18.075C15.2293 18.225 14.9667 18.35 14.7 18.45L14.4 20.7C14.3667 20.9333 14.2667 21.125 14.1 21.275C13.9333 21.425 13.7333 21.5 13.5 21.5ZM12 15C12.8333 15 13.5417 14.7083 14.125 14.125C14.7083 13.5417 15 12.8333 15 12C15 11.1667 14.7083 10.4583 14.125 9.875C13.5417 9.29167 12.8333 9 12 9C11.1667 9 10.4583 9.29167 9.875 9.875C9.29167 10.4583 9 11.1667 9 12C9 12.8333 9.29167 13.5417 9.875 14.125C10.4583 14.7083 11.1667 15 12 15ZM12 13.5C11.5833 13.5 11.2293 13.354 10.938 13.062C10.646 12.7707 10.5 12.4167 10.5 12C10.5 11.5833 10.646 11.2293 10.938 10.938C11.2293 10.646 11.5833 10.5 12 10.5C12.4167 10.5 12.7707 10.646 13.062 10.938C13.354 11.2293 13.5 11.5833 13.5 12C13.5 12.4167 13.354 12.7707 13.062 13.062C12.7707 13.354 12.4167 13.5 12 13.5ZM11 20H12.975L13.325 17.325C13.8417 17.1917 14.3083 17 14.725 16.75C15.1417 16.5 15.55 16.1833 15.95 15.8L18.425 16.85L19.425 15.15L17.25 13.525C17.3333 13.2583 17.3877 13 17.413 12.75C17.4377 12.5 17.45 12.25 17.45 12C17.45 11.7333 17.4377 11.4793 17.413 11.238C17.3877 10.996 17.3333 10.75 17.25 10.5L19.425 8.85L18.45 7.15L15.925 8.2C15.5917 7.85 15.1917 7.53733 14.725 7.262C14.2583 6.98733 13.7917 6.79167 13.325 6.675L13 4H11.025L10.675 6.675C10.175 6.79167 9.70834 6.975 9.275 7.225C8.84167 7.475 8.425 7.79167 8.025 8.175L5.55 7.15L4.575 8.85L6.725 10.45C6.64167 10.7 6.58334 10.95 6.55 11.2C6.51667 11.45 6.5 11.7167 6.5 12C6.5 12.2667 6.51667 12.525 6.55 12.775C6.58334 13.025 6.64167 13.275 6.725 13.525L4.575 15.15L5.55 16.85L8.025 15.8C8.40834 16.1833 8.81667 16.5 9.25 16.75C9.68334 17 10.1583 17.1917 10.675 17.325L11 20Z',
|
|
77
|
+
store: 'M5 6C4.71666 6 4.479 5.90433 4.287 5.713C4.09566 5.521 4 5.28333 4 5C4 4.71667 4.09566 4.479 4.287 4.287C4.479 4.09567 4.71666 4 5 4H19C19.2833 4 19.5207 4.09567 19.712 4.287C19.904 4.479 20 4.71667 20 5C20 5.28333 19.904 5.521 19.712 5.713C19.5207 5.90433 19.2833 6 19 6H5ZM5 20C4.71666 20 4.479 19.904 4.287 19.712C4.09566 19.5207 4 19.2833 4 19V14H3.825C3.50833 14 3.25 13.879 3.05 13.637C2.85 13.3957 2.78333 13.1167 2.85 12.8L3.85 7.8C3.9 7.56667 4.01666 7.375 4.2 7.225C4.38333 7.075 4.59166 7 4.825 7H19.175C19.4083 7 19.6167 7.075 19.8 7.225C19.9833 7.375 20.1 7.56667 20.15 7.8L21.15 12.8C21.2167 13.1167 21.15 13.3957 20.95 13.637C20.75 13.879 20.4917 14 20.175 14H20V19C20 19.2833 19.904 19.5207 19.712 19.712C19.5207 19.904 19.2833 20 19 20C18.7167 20 18.4793 19.904 18.288 19.712C18.096 19.5207 18 19.2833 18 19V14H14V19C14 19.2833 13.9043 19.5207 13.713 19.712C13.521 19.904 13.2833 20 13 20H5ZM6 18H12V14H6V18ZM5.05 12H18.95L18.35 9H5.65L5.05 12Z',
|
|
78
|
+
};
|
|
79
|
+
|
|
69
80
|
const AccountMenuIcon: React.FunctionComponent<{ name: AccountMenuIconName }> = ({ name }) => {
|
|
81
|
+
if (name === 'settings' || name === 'store') {
|
|
82
|
+
return (
|
|
83
|
+
<svg className="acct-icon" width="22" height="22" viewBox="1 1 22 22" fill="currentColor" aria-hidden="true">
|
|
84
|
+
<path d={FILLED[name]} />
|
|
85
|
+
</svg>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
70
88
|
const { at, d } = GLYPHS[name];
|
|
71
89
|
return (
|
|
72
90
|
<svg
|
package/chrome/TopBar.tsx
CHANGED
|
@@ -102,8 +102,12 @@ export interface TopBarProps {
|
|
|
102
102
|
compareCount?: number;
|
|
103
103
|
/** active language tag (appStore.language) — ticks the current language row. */
|
|
104
104
|
language?: string;
|
|
105
|
-
/** dealer-main account (authStore.isDealerMain) —
|
|
105
|
+
/** dealer-main account (authStore.isDealerMain) — Bildeinstellungen and the dealer switch. */
|
|
106
106
|
isDealerMain?: boolean;
|
|
107
|
+
/** dealer admin (authStore.isDealerAdmin) — Bildeinstellungen, like isDealerMain. */
|
|
108
|
+
isDealerAdmin?: boolean;
|
|
109
|
+
/** dealer employee (authStore.isEmployee) — the "Meine Händler" switch, like isDealerMain. */
|
|
110
|
+
isEmployee?: boolean;
|
|
107
111
|
/** attached dealerships (profileStore.dealers: { dealer: {id, email}, isActive }[]). */
|
|
108
112
|
dealers?: ReadonlyArray<{ dealer: { id: string; email: string }; isActive: boolean }>;
|
|
109
113
|
/** switch the active dealership (App.setMainDealer → profileStore.switchDealer). */
|
|
@@ -151,6 +155,8 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
151
155
|
compareCount = 0,
|
|
152
156
|
language = 'de',
|
|
153
157
|
isDealerMain = false,
|
|
158
|
+
isDealerAdmin = false,
|
|
159
|
+
isEmployee = false,
|
|
154
160
|
dealers = [],
|
|
155
161
|
onDealerSelect,
|
|
156
162
|
onSignOut,
|
|
@@ -218,18 +224,22 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
218
224
|
);
|
|
219
225
|
|
|
220
226
|
/** one Konto-menu row (Figma "acct-row"): 22px icon, label, count badge when above 0. `icon` is a
|
|
221
|
-
*
|
|
227
|
+
* menu glyph; `lucide` is a lib Icon for the guest rows Figma doesn't draw. `checked` (dealer rows)
|
|
228
|
+
* marks the active choice with the same check as the language rows. */
|
|
222
229
|
const acctRow = (
|
|
223
230
|
key: string,
|
|
224
231
|
label: string,
|
|
225
232
|
onClick: () => void,
|
|
226
|
-
opts: { icon?: AccountMenuIconName; lucide?: string; badge?: number } = {},
|
|
233
|
+
opts: { icon?: AccountMenuIconName; lucide?: string; badge?: number; checked?: boolean } = {},
|
|
227
234
|
): JSX.Element => (
|
|
228
|
-
<button key={key} type="button" className="acct-row" onClick={onClick}>
|
|
235
|
+
<button key={key} type="button" className="acct-row" onClick={onClick} aria-pressed={opts.checked}>
|
|
229
236
|
{opts.icon && <AccountMenuIcon name={opts.icon} />}
|
|
230
237
|
{opts.lucide && <Icon name={opts.lucide} size={22} stroke={ACCT_ICON_STROKE} cls="acct-icon" />}
|
|
231
238
|
<span className="acct-label">{label}</span>
|
|
232
239
|
{!!opts.badge && opts.badge > 0 && <span className="acct-badge">{opts.badge}</span>}
|
|
240
|
+
{opts.checked && (
|
|
241
|
+
<span className="acct-check"><Icon name="check" size={13} color="#fff" stroke={3} /></span>
|
|
242
|
+
)}
|
|
233
243
|
</button>
|
|
234
244
|
);
|
|
235
245
|
|
|
@@ -256,8 +266,11 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
256
266
|
);
|
|
257
267
|
|
|
258
268
|
/** Konto menu (Figma "Kontomenü (geöffnet)", 64243:14205 desktop / 64243:14299 mobile — the same
|
|
259
|
-
* 312px dropdown at every width): the name, then groups split by lines
|
|
260
|
-
*
|
|
269
|
+
* 312px dropdown at every width): the name, then groups split by lines — Figma's rows for every
|
|
270
|
+
* user, Profil, then the role rows (the dealer switch for employees, Bildeinstellungen for
|
|
271
|
+
* dealers/admins). Rows Figma doesn't draw use the same style. */
|
|
272
|
+
const isDealerOrAdmin = isDealerMain || isDealerAdmin;
|
|
273
|
+
const showDealers = (isDealerMain || isEmployee) && dealers.length > 1;
|
|
261
274
|
const renderAccountMenu = (): JSX.Element => (
|
|
262
275
|
<div className="acct-menu">
|
|
263
276
|
<div className="acct-scroll">
|
|
@@ -267,9 +280,7 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
267
280
|
<span className="acct-name">{userLabel || t('autobahn:chrome.myAccount')}</span>
|
|
268
281
|
</div>
|
|
269
282
|
<div className="acct-list">
|
|
270
|
-
{
|
|
271
|
-
{!isDealerMain &&
|
|
272
|
-
acctRow('overview', t('autobahn:chrome.acct.overview'), () => goRoute(R_DASHBOARD), { icon: 'layout-grid' })}
|
|
283
|
+
{acctRow('overview', t('autobahn:chrome.acct.overview'), () => goRoute(R_DASHBOARD), { icon: 'layout-grid' })}
|
|
273
284
|
{ordersCount > 0 &&
|
|
274
285
|
acctRow('myOrder', t('autobahn:chrome.acct.myOrder'), () => goRoute(R_MY_ORDERS), { icon: 'car-front' })}
|
|
275
286
|
{acctRow('savedSearches', t('autobahn:chrome.acct.savedSearches'), () => goRoute(R_SAVED_SEARCHES), { icon: 'bookmark', badge: savedSearchesCount })}
|
|
@@ -279,26 +290,26 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
279
290
|
<div className="acct-list">
|
|
280
291
|
{acctRow('profile', t('autobahn:chrome.acct.profile'), () => goRoute(R_SETTINGS), { icon: 'user' })}
|
|
281
292
|
</div>
|
|
282
|
-
|
|
283
|
-
{acctRow('support', t('autobahn:chrome.acct.support'), () => goRoute(R_KONTAKT), { icon: 'help-circle' })}
|
|
284
|
-
</div>
|
|
285
|
-
{isDealerMain && (
|
|
293
|
+
{(showDealers || isDealerOrAdmin) && (
|
|
286
294
|
<div className="acct-list">
|
|
287
|
-
{
|
|
288
|
-
{acctRow('imageSettings', t('autobahn:chrome.imageSettings'), () => goRoute(R_IMAGE_SETTINGS), { lucide: 'image' })}
|
|
289
|
-
{dealers.length > 1 && (
|
|
295
|
+
{showDealers && (
|
|
290
296
|
<>
|
|
291
297
|
<div className="acct-sub">{t('autobahn:chrome.myDealers')} ({dealers.length})</div>
|
|
292
298
|
{dealers.map((d) =>
|
|
293
299
|
acctRow(`dealer-${d.dealer.id}`, d.dealer.email, () => {
|
|
294
300
|
setAccount(false);
|
|
295
301
|
if (!d.isActive && onDealerSelect) onDealerSelect(d.dealer.id);
|
|
296
|
-
}, {
|
|
302
|
+
}, { icon: 'store', checked: d.isActive }),
|
|
297
303
|
)}
|
|
298
304
|
</>
|
|
299
305
|
)}
|
|
306
|
+
{isDealerOrAdmin &&
|
|
307
|
+
acctRow('imageSettings', t('autobahn:chrome.imageSettings'), () => goRoute(R_IMAGE_SETTINGS), { icon: 'settings' })}
|
|
300
308
|
</div>
|
|
301
309
|
)}
|
|
310
|
+
<div className="acct-list">
|
|
311
|
+
{acctRow('support', t('autobahn:chrome.acct.support'), () => goRoute(R_KONTAKT), { icon: 'help-circle' })}
|
|
312
|
+
</div>
|
|
302
313
|
{renderLanguageRows()}
|
|
303
314
|
<div className="acct-list">
|
|
304
315
|
{acctRow('signOut', t('autobahn:chrome.signOut'), () => { setAccount(false); if (onSignOut) onSignOut(); }, { icon: 'log-out' })}
|
package/constants/app.ts
CHANGED
|
@@ -40,7 +40,17 @@ export const LOCAL_STORAGE_KEY = {
|
|
|
40
40
|
i18n_KEY: 'i18nLanguage'
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// ADV-284: evaluated at import time — with site storage blocked, reading localStorage throws a
|
|
44
|
+
// SecurityError that took down the whole bundle. Blocked storage behaves like "nothing saved".
|
|
45
|
+
const readStoredLang = (): string | null => {
|
|
46
|
+
try {
|
|
47
|
+
return localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const DEFAULT_LANG: string = typeof window !== 'undefined' ? readStoredLang() : 'de';
|
|
44
54
|
|
|
45
55
|
// Default support contact phone
|
|
46
56
|
export const CONTACT_PHONE: string = '+498004030182';
|
package/constants/core.ts
CHANGED
|
@@ -35,7 +35,18 @@ export const LOCAL_STORAGE_KEY = {
|
|
|
35
35
|
i18n_KEY: 'i18nLanguage'
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
// ADV-284: evaluated at import time — with site storage blocked, merely reading
|
|
39
|
+
// window.localStorage throws a SecurityError, which took down the whole bundle (landing
|
|
40
|
+
// page never rendered). Treat blocked storage like "no language saved".
|
|
41
|
+
const readStoredLang = (): string | null => {
|
|
42
|
+
try {
|
|
43
|
+
return typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null;
|
|
44
|
+
} catch (e) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const DEFAULT_LANG: string = readStoredLang() ?? 'de';
|
|
39
50
|
|
|
40
51
|
export const ROW_STYLES = {
|
|
41
52
|
marginBottom: 10
|
package/locales/de/autobahn.json
CHANGED
|
@@ -494,7 +494,8 @@
|
|
|
494
494
|
"ratings": "Bewertungen"
|
|
495
495
|
},
|
|
496
496
|
"section": {
|
|
497
|
-
"similar": "Ähnliche Fahrzeuge"
|
|
497
|
+
"similar": "Ähnliche Fahrzeuge",
|
|
498
|
+
"unavailableSimilar": "Ähnliche / vergleichbare Fahrzeuge"
|
|
498
499
|
},
|
|
499
500
|
"breadcrumb": {
|
|
500
501
|
"home": "Start",
|
|
@@ -805,7 +806,8 @@
|
|
|
805
806
|
"serviceHistory": "Scheckheft",
|
|
806
807
|
"warranty": "Garantie",
|
|
807
808
|
"yes": "Ja",
|
|
808
|
-
"no": "Nein"
|
|
809
|
+
"no": "Nein",
|
|
810
|
+
"notSpecified": "keine Angabe"
|
|
809
811
|
},
|
|
810
812
|
"common": {
|
|
811
813
|
"needsData": "Daten folgt"
|
package/locales/en/autobahn.json
CHANGED
|
@@ -494,7 +494,8 @@
|
|
|
494
494
|
"ratings": "Ratings"
|
|
495
495
|
},
|
|
496
496
|
"section": {
|
|
497
|
-
"similar": "Similar vehicles"
|
|
497
|
+
"similar": "Similar vehicles",
|
|
498
|
+
"unavailableSimilar": "Similar / comparable vehicles"
|
|
498
499
|
},
|
|
499
500
|
"breadcrumb": {
|
|
500
501
|
"home": "Home",
|
|
@@ -805,7 +806,8 @@
|
|
|
805
806
|
"serviceHistory": "Full service history",
|
|
806
807
|
"warranty": "Warranty",
|
|
807
808
|
"yes": "Yes",
|
|
808
|
-
"no": "No"
|
|
809
|
+
"no": "No",
|
|
810
|
+
"notSpecified": "not specified"
|
|
809
811
|
},
|
|
810
812
|
"common": {
|
|
811
813
|
"needsData": "Data coming soon"
|
package/locales/legacy/data.ts
CHANGED
|
@@ -103,7 +103,8 @@ export const vehicleProps = (car?: any, isOfferAvailable: boolean = true) => {
|
|
|
103
103
|
wltpDischargedCombinedLabel: `${getFormattedNumber(vehicleOption.wltpCombined != null ? vehicleOption.wltpCombined : 19.9)}l/100km (entladen, komb)`,
|
|
104
104
|
wltpCo2WtdCombinedShort: `${getFormattedNumber(vehicleOption.wltpCo2)}g CO2/km (gew., komb)*`,
|
|
105
105
|
co2ClassWeighted: `CO2-Klasse ${(cbd.cbd as any)[vehicleOption.wltpEnergyEfficiencyClass] || vehicleOption.wltpEnergyEfficiencyClass || ''} (gew., komb)`,
|
|
106
|
-
|
|
106
|
+
// ADV-187: no hard-coded fallback class — callers only render this when the class is defined.
|
|
107
|
+
co2ClassDischarged: `CO2-Klasse ${(cbd.cbd as any)[vehicleOption.wltpDischargedEnergyEfficiencyClass] || vehicleOption.wltpDischargedEnergyEfficiencyClass || ''} (entladen, komb)`
|
|
107
108
|
},
|
|
108
109
|
title: {
|
|
109
110
|
'addOfferToMainSlide': 'Zum Schieberegler hinzufügen',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/fe-ui-core-autobahn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.171",
|
|
4
4
|
"description": "auto.de md3 (Autobahn) design system — UI primitives, cards, chrome, VDP modules, theme CSS and locales. Ships raw TypeScript source (like fe-ui-core before it); each consumer's bundler compiles it.",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"license": "UNLICENSED",
|
package/theme/md3.css
CHANGED
|
@@ -10100,7 +10100,8 @@ line-height: 31px;
|
|
|
10100
10100
|
z-index: 71;
|
|
10101
10101
|
background: var(--md-surface);
|
|
10102
10102
|
border-radius: var(--md-r-xl) var(--md-r-xl) 0 0;
|
|
10103
|
-
|
|
10103
|
+
/* % of the fixed containing block, not vh/dvh: on iOS vh is the toolbars-collapsed height, and Chrome on iOS does not shrink dvh while its toolbars are shown either, so a 92vh/92dvh bottom sheet grew under the address bar and hid its own header (title, download, close). The fixed box itself always matches the visible area. */
|
|
10104
|
+
max-height: 92%;
|
|
10104
10105
|
display: flex;
|
|
10105
10106
|
flex-direction: column;
|
|
10106
10107
|
box-shadow: 0 -8px 30px rgba(16, 22, 42, 0.22);
|
|
@@ -14251,7 +14252,8 @@ color: #005CFF;
|
|
|
14251
14252
|
flex-direction: column;
|
|
14252
14253
|
width: 100%;
|
|
14253
14254
|
max-width: 560px;
|
|
14254
|
-
|
|
14255
|
+
/* % of the scrim (fixed, inset 0, 16px padding) instead of calc(100vh - 32px): see the iOS note on the mobile .mmodal below */
|
|
14256
|
+
max-height: 100%;
|
|
14255
14257
|
background: var(--md-sc-lowest, #fff);
|
|
14256
14258
|
color: var(--md-on-surface);
|
|
14257
14259
|
border-radius: var(--md-r-lg);
|
|
@@ -14397,7 +14399,8 @@ color: #005CFF;
|
|
|
14397
14399
|
}
|
|
14398
14400
|
.md3 .mmodal {
|
|
14399
14401
|
max-width: 100%;
|
|
14400
|
-
|
|
14402
|
+
/* % of the fixed containing block, not vh/dvh: on iOS vh is the toolbars-collapsed height, and Chrome on iOS does not shrink dvh while its toolbars are shown either, so a 92vh/92dvh bottom sheet grew under the address bar and hid its own header (title, download, close). The fixed box itself always matches the visible area. */
|
|
14403
|
+
max-height: 92%;
|
|
14401
14404
|
border-radius: var(--md-r-lg) var(--md-r-lg) 0 0;
|
|
14402
14405
|
border-bottom: 0;
|
|
14403
14406
|
animation: mmodal-sheet-up 0.25s ease-out;
|
package/ui/Dropdown.tsx
CHANGED
|
@@ -22,6 +22,7 @@ import * as ReactDOM from 'react-dom';
|
|
|
22
22
|
|
|
23
23
|
import Icon from './Icon';
|
|
24
24
|
import { usePortalMenuPosition } from './usePortalMenuPosition';
|
|
25
|
+
import { scrollFieldIntoView } from './scrollFieldIntoView';
|
|
25
26
|
|
|
26
27
|
export interface DropdownOption {
|
|
27
28
|
value: string;
|
|
@@ -189,15 +190,22 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
189
190
|
if (allowCustomValue) setQuery(value || '');
|
|
190
191
|
}, [disabled, selectedIndex, allowCustomValue, value]);
|
|
191
192
|
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
//
|
|
193
|
+
// Scroll the trigger (searchable or not) to the top of the page on open, THEN — searchable
|
|
194
|
+
// only — focus the search input instead of leaving focus on the trigger. Every Dropdown shares
|
|
195
|
+
// this, not just searchable ones: on mobile a trigger sitting mid-page can open a menu that
|
|
196
|
+
// runs off the bottom of the viewport with no way to see the rest of it, same underlying
|
|
197
|
+
// problem a searchable trigger has with the keyboard eating the space below it. A plain
|
|
198
|
+
// `scrollIntoView({block:'center'})` used to run here (searchable-only) — "center" only moves
|
|
199
|
+
// the trigger when it's already near a viewport edge, so on a trigger that's roughly mid-page
|
|
200
|
+
// already (the common case) it was a near no-op, leaving a few hundred px of dead space above
|
|
201
|
+
// the trigger that the keyboard (searchable) or the menu's own bottom edge (any dropdown) then
|
|
202
|
+
// ran into.
|
|
196
203
|
React.useEffect(() => {
|
|
197
|
-
if (!open
|
|
198
|
-
if (rootRef.current
|
|
199
|
-
|
|
200
|
-
|
|
204
|
+
if (!open) return;
|
|
205
|
+
if (rootRef.current) scrollFieldIntoView(rootRef.current);
|
|
206
|
+
// searchRef is only ever attached in the searchable+open (editing) render branch, so this
|
|
207
|
+
// naturally no-ops for a non-searchable dropdown — nothing else to focus there, the trigger
|
|
208
|
+
// <button> already has focus from the click/keypress that opened it.
|
|
201
209
|
if (searchRef.current) {
|
|
202
210
|
searchRef.current.focus();
|
|
203
211
|
// pre-filled custom value (see openMenu) starts selected, so typing immediately
|
package/ui/index.ts
CHANGED
|
@@ -39,6 +39,8 @@ export type { FormFieldProps } from './FormField';
|
|
|
39
39
|
export { default as Dropdown } from './Dropdown';
|
|
40
40
|
export type { DropdownProps, DropdownOption } from './Dropdown';
|
|
41
41
|
|
|
42
|
+
export { scrollFieldIntoView } from './scrollFieldIntoView';
|
|
43
|
+
|
|
42
44
|
export { default as Spec } from './Spec';
|
|
43
45
|
export type { SpecProps } from './Spec';
|
|
44
46
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Autobahn (auto.de redesign) — shared "scroll a just-opened/just-focused field to the top of the
|
|
2
|
+
// page" behaviour, used by Dropdown.tsx and by fe-main's DualRange/RateSlider (FilterContent.tsx)
|
|
3
|
+
// text fields on /search/detailed. On mobile, opening a dropdown's menu or focusing a text field
|
|
4
|
+
// brings the on-screen keyboard up and/or needs room for a popover below the field — if the field
|
|
5
|
+
// is sitting mid-page, there may not be enough space left below it once the keyboard/menu takes
|
|
6
|
+
// its share. Scrolling the field to the very top of the page first maximizes what's available.
|
|
7
|
+
//
|
|
8
|
+
// Extracted out of Dropdown.tsx so it can be shared verbatim with fe-main's non-Dropdown form
|
|
9
|
+
// fields (DualRange/RateSlider's text inputs) — same problem, same fix, one place to keep them
|
|
10
|
+
// from drifting apart. See Dropdown.tsx's own call site for the original reasoning this was
|
|
11
|
+
// pulled from.
|
|
12
|
+
export function scrollFieldIntoView(field: HTMLElement): void {
|
|
13
|
+
if (typeof window === 'undefined') return;
|
|
14
|
+
// Mobile-only: the on-screen-keyboard/popover space problem this fixes doesn't exist on
|
|
15
|
+
// desktop, where there's no keyboard pushing the viewport around. Same breakpoint + matchMedia
|
|
16
|
+
// pattern as Modal.tsx/CardCarousel.tsx elsewhere in this lib.
|
|
17
|
+
if (window.matchMedia('(min-width: 601px)').matches) return;
|
|
18
|
+
// Anchor on whichever is higher up: the field itself, or a short field label/caption sitting
|
|
19
|
+
// directly above it (own previous sibling, or — the common "label above a row of controls"
|
|
20
|
+
// shape, e.g. "Marke & Modell" above the Make/Model row on /search/detailed — the wrapping
|
|
21
|
+
// row's previous sibling). Checked by height, not by class name, so this works for ANY
|
|
22
|
+
// caller's label without this needing to know that call site's specific markup.
|
|
23
|
+
const MAX_LABEL_HEIGHT = 30;
|
|
24
|
+
const asLabel = (el: Element | null): HTMLElement | null => {
|
|
25
|
+
if (!(el instanceof HTMLElement)) return null;
|
|
26
|
+
const h = el.getBoundingClientRect().height;
|
|
27
|
+
return h > 0 && h <= MAX_LABEL_HEIGHT ? el : null;
|
|
28
|
+
};
|
|
29
|
+
const anchor =
|
|
30
|
+
asLabel(field.previousElementSibling) ||
|
|
31
|
+
asLabel(field.parentElement && field.parentElement.previousElementSibling) ||
|
|
32
|
+
field;
|
|
33
|
+
// No sticky-header reservation here: every current caller (NewMainPage '/', FilterContent on
|
|
34
|
+
// '/search*') sits on a page where TopBar's own autoHideOnScroll is on (App.tsx: isHomePage ||
|
|
35
|
+
// isSearchPage) — the header slides itself out of the way the instant this scroll starts,
|
|
36
|
+
// independently of this call, so reserving space for it here would double-count.
|
|
37
|
+
const GAP = 8;
|
|
38
|
+
const rect = anchor.getBoundingClientRect();
|
|
39
|
+
const targetY = window.scrollY + rect.top - GAP;
|
|
40
|
+
window.scrollTo({ top: Math.max(0, targetY), behavior: 'smooth' });
|
|
41
|
+
}
|
|
@@ -79,6 +79,20 @@ const ESTIMATED_MENU_HEIGHT = 300;
|
|
|
79
79
|
// a scroll within this window of opening REPOSITIONS instead of closing — see the effect below.
|
|
80
80
|
const SELF_SCROLL_GRACE_MS = 500;
|
|
81
81
|
|
|
82
|
+
// Module-level (not hook-local) so Dropdown.tsx's own searchable-open scroll effect can reuse the
|
|
83
|
+
// exact same measurement — the sticky app header (.topbar, position:sticky/top:0) sits over the
|
|
84
|
+
// top of the viewport on every page that uses it (TopBar's autoHideOnScroll is opt-in, off by
|
|
85
|
+
// default — most pages keep it permanently docked), so anything that scrolls/positions content
|
|
86
|
+
// near the top of the viewport needs to stop at its live bottom edge, not y=0. Reading the
|
|
87
|
+
// header's live bottom edge (0 when absent, e.g. inside a modal, or when autoHideOnScroll has slid
|
|
88
|
+
// it away) gives a correct boundary without hardcoding a pixel height that could drift from the
|
|
89
|
+
// header's own CSS.
|
|
90
|
+
export const getSafeTop = (): number => {
|
|
91
|
+
if (typeof document === 'undefined') return 0;
|
|
92
|
+
const header = document.querySelector('.topbar');
|
|
93
|
+
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
94
|
+
};
|
|
95
|
+
|
|
82
96
|
export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivElement>({
|
|
83
97
|
enabled,
|
|
84
98
|
open,
|
|
@@ -121,18 +135,6 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
121
135
|
};
|
|
122
136
|
}, [enabled, open, portalRoot]);
|
|
123
137
|
|
|
124
|
-
// the portal menu's z-index (1400, .mselect-menu--portal) is intentionally higher than every
|
|
125
|
-
// other fixed overlay it must paint over (checkout sheets/modals) — which also means it would
|
|
126
|
-
// paint over the sticky app header (.topbar, position:sticky/top:0/z-index:50) if left
|
|
127
|
-
// unconstrained. Reading the header's live bottom edge (0 when absent, e.g. inside a modal, or
|
|
128
|
-
// when TopBar's autoHideOnScroll has slid it away) gives a correct top boundary without
|
|
129
|
-
// hardcoding a pixel height that could drift from the header's own CSS.
|
|
130
|
-
const getSafeTop = (): number => {
|
|
131
|
-
if (typeof document === 'undefined') return 0;
|
|
132
|
-
const header = document.querySelector('.topbar');
|
|
133
|
-
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
138
|
const [menuPos, setMenuPos] = React.useState<PortalMenuPos | null>(null);
|
|
137
139
|
|
|
138
140
|
const positionMenu = React.useCallback(() => {
|
package/utils/index.ts
CHANGED
|
@@ -83,3 +83,5 @@ export type { IValues, IFilters, IQuery } from './query';
|
|
|
83
83
|
// Decorated car props (renders React UI; lives in vehiclesProps/ with its
|
|
84
84
|
// IconContainer + Co2Widget dependencies under compat/).
|
|
85
85
|
export { default as getDecoratedProps } from '../vehiclesProps/decoratedProps';
|
|
86
|
+
export { setStrictConditionOwners, isStrictConditionOwner, strictAccidentStatus } from '../vehiclesProps/accidentDisclosure';
|
|
87
|
+
export type { AccidentStatus } from '../vehiclesProps/accidentDisclosure';
|
package/vdp/VdpModules.tsx
CHANGED
|
@@ -92,7 +92,7 @@ export const VdpHeaderSummary: React.FunctionComponent<VdpHeaderCardProps> = ({
|
|
|
92
92
|
['zap', extractPS(vehicle.power)],
|
|
93
93
|
['fuel', stripParen(vehicle.fuel)],
|
|
94
94
|
['cog', vehicle.gear],
|
|
95
|
-
['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })],
|
|
95
|
+
...(vehicle.owners == null ? [] : ([['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })]] as const)),
|
|
96
96
|
];
|
|
97
97
|
return (
|
|
98
98
|
<>
|
|
@@ -142,7 +142,7 @@ export const VdpFactsGrid: React.FunctionComponent<VdpHeaderCardProps> = ({ vehi
|
|
|
142
142
|
['calendar', vehicle.reg],
|
|
143
143
|
['cog', vehicle.gear],
|
|
144
144
|
['fuel', stripParen(vehicle.fuel)],
|
|
145
|
-
['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })],
|
|
145
|
+
...(vehicle.owners == null ? [] : ([['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })]] as const)),
|
|
146
146
|
...(vehicle.body ? ([['car-front', vehicle.body]] as const) : []),
|
|
147
147
|
];
|
|
148
148
|
return (
|
|
@@ -216,7 +216,7 @@ export const VdpHeaderCondition: React.FunctionComponent<VdpHeaderCardProps> = (
|
|
|
216
216
|
// only the Garantie tile has one, linking out to auto.de's warranty policy page.
|
|
217
217
|
const tiles: ReadonlyArray<readonly [string, string, string, string?]> = [
|
|
218
218
|
['wrench', t('autobahn:header.huLabel'), condition.hu === 'Neu' ? t('autobahn:header.huNew') : t('autobahn:header.huUntil', { date: condition.hu })],
|
|
219
|
-
['shield-check', t('autobahn:header.accidentFree'), condition.unfallfrei ? t('autobahn:header.yes') : t('autobahn:header.no')],
|
|
219
|
+
['shield-check', t('autobahn:header.accidentFree'), condition.unfallfrei == null ? t('autobahn:header.notSpecified', { defaultValue: 'keine Angabe' }) : condition.unfallfrei ? t('autobahn:header.yes') : t('autobahn:header.no')],
|
|
220
220
|
['clipboard-check', t('autobahn:header.serviceHistory'), condition.scheckheft ? t('autobahn:header.yes') : t('autobahn:header.no')],
|
|
221
221
|
['award', t('autobahn:header.warranty'), condition.garantie, 'https://www.auto.de/garantie/'],
|
|
222
222
|
];
|
package/vdp/types.ts
CHANGED
|
@@ -111,8 +111,8 @@ export interface Co2CostsSummary {
|
|
|
111
111
|
export interface VehicleCondition {
|
|
112
112
|
/** TÜV/HU validity, e.g. '03/2027' — or 'Neu' for a new HU. */
|
|
113
113
|
hu: string;
|
|
114
|
-
/** accident-free flag (Unfallfrei). */
|
|
115
|
-
unfallfrei: boolean;
|
|
114
|
+
/** accident-free flag (Unfallfrei); null = not specified by the source ("keine Angabe"). */
|
|
115
|
+
unfallfrei: boolean | null;
|
|
116
116
|
/** full service history (Scheckheftgepflegt). */
|
|
117
117
|
scheckheft: boolean;
|
|
118
118
|
/** warranty label, e.g. '12 Monate inkl.'. */
|
|
@@ -191,8 +191,8 @@ export interface VehicleDetail {
|
|
|
191
191
|
fuel: string;
|
|
192
192
|
/** gearbox label, e.g. 'Automatik' / 'Schaltgetriebe'. */
|
|
193
193
|
gear: string;
|
|
194
|
-
/** number of previous owners (rendered as 'N. Hand'). */
|
|
195
|
-
owners: number;
|
|
194
|
+
/** number of previous owners (rendered as 'N. Hand'); null = not known, the fact is not shown. */
|
|
195
|
+
owners: number | null;
|
|
196
196
|
/** number of seats. */
|
|
197
197
|
seats: number;
|
|
198
198
|
/** number of doors. */
|
|
@@ -302,7 +302,7 @@ export function defaultVdpSpecs(v: VehicleDetail): VdpSpec[] {
|
|
|
302
302
|
[['cog', 'Getriebe', v.gear], true],
|
|
303
303
|
[['users', 'Sitze', `${v.seats} Sitze`], false],
|
|
304
304
|
[['door-open', 'Türen', `${v.doors} Türen`], false],
|
|
305
|
-
[['user', 'Halter', `${v.owners}. Hand`], true], // 0 Vorbesitzer is valid
|
|
305
|
+
...(v.owners == null ? [] : [[['user', 'Halter', `${v.owners}. Hand`], true] as const]), // 0 Vorbesitzer is valid
|
|
306
306
|
[['palette', 'Außenfarbe', v.color], true],
|
|
307
307
|
[['car-front', 'Karosserie', v.body], true],
|
|
308
308
|
[['droplet', 'Verbrauch komb.', v.cons], true], // Pkw-EnVKV — exempt from this rule
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// FINN handover v0.6 (Daniel, 15.10.2026): for the owners set here, accident and owner facts follow
|
|
2
|
+
// only what the source states — mainData.accidentDamaged false → accident-free, true → accident,
|
|
3
|
+
// empty → not specified; an empty owner count is not shown as "0. Hand". Every other dealer keeps
|
|
4
|
+
// the old display (accident-free unless `damaged`). The app sets the owners once at start.
|
|
5
|
+
let strictOwners: ReadonlyArray<string> = [];
|
|
6
|
+
|
|
7
|
+
export function setStrictConditionOwners(ownerIds: ReadonlyArray<string>): void {
|
|
8
|
+
strictOwners = (ownerIds || []).filter(Boolean);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isStrictConditionOwner(car: any): boolean {
|
|
12
|
+
const ownerId = car?.metaData?.ownerId;
|
|
13
|
+
return !!ownerId && strictOwners.includes(ownerId);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type AccidentStatus = 'accidentFree' | 'accident' | 'notSpecified';
|
|
17
|
+
|
|
18
|
+
// The strict status, or undefined when the car's owner keeps the old display.
|
|
19
|
+
export function strictAccidentStatus(car: any): AccidentStatus | undefined {
|
|
20
|
+
if (!isStrictConditionOwner(car)) return undefined;
|
|
21
|
+
const value = car?.mainData?.accidentDamaged;
|
|
22
|
+
if (value === true) return 'accident';
|
|
23
|
+
if (value === false) return 'accidentFree';
|
|
24
|
+
return 'notSpecified';
|
|
25
|
+
}
|
|
@@ -6,6 +6,7 @@ import { formatTimestamp } from '../utils/DateUtils';
|
|
|
6
6
|
import { DELIVERY_PERIODS_EXTRA } from '../constants/core';
|
|
7
7
|
import moment from 'moment';
|
|
8
8
|
import { IDecoratedProp } from '../types/types';
|
|
9
|
+
import { strictAccidentStatus } from './accidentDisclosure';
|
|
9
10
|
|
|
10
11
|
interface IDecoratedProps {
|
|
11
12
|
[key: string]: IDecoratedProp;
|
|
@@ -165,7 +166,10 @@ const getDecoratedLightProps = (
|
|
|
165
166
|
if (hybridPlugin) {
|
|
166
167
|
if (wltpWeightedPowerCombinedContent && wltpWeightedCombinedContent) {
|
|
167
168
|
const dischargedCombined = Number.isFinite(wltpConsumptionCombined) ? wltpConsumptionCombined : 19.9;
|
|
168
|
-
|
|
169
|
+
// ADV-187: the discharged class is derived server-side from wltpCo2Discharged; when the
|
|
170
|
+
// backend could not derive it the field is selector_unknown — hide the segment, never
|
|
171
|
+
// fall back to a hard-coded class here.
|
|
172
|
+
const dischargedClass = car.environmentEmissions.wltpDischargedEnergyEfficiencyClass;
|
|
169
173
|
const weightedCombinedLabeled = t('vehicleProps:value.wltpWeightedCombinedLabel', { consumption: wltpWeightedCombined.toLocaleString(language), unit: translatedUnit });
|
|
170
174
|
const dischargedCombinedLabeled = t('vehicleProps:value.wltpDischargedCombinedLabel', { consumption: dischargedCombined.toLocaleString(language), unit: translatedUnit });
|
|
171
175
|
const co2WeightedContent = Number.isFinite(wltpCo2)
|
|
@@ -174,14 +178,16 @@ const getDecoratedLightProps = (
|
|
|
174
178
|
const co2ClassWeighted = isPropDefined(wltpEnergyEfficiencyClass)
|
|
175
179
|
? t('vehicleProps:value.co2ClassWeighted', { class: t(`cbd:${wltpEnergyEfficiencyClass}`) })
|
|
176
180
|
: null;
|
|
177
|
-
const co2ClassDischarged =
|
|
181
|
+
const co2ClassDischarged = isPropDefined(dischargedClass)
|
|
182
|
+
? t('vehicleProps:value.co2ClassDischarged', { class: t(`cbd:${dischargedClass}`) })
|
|
183
|
+
: null;
|
|
178
184
|
return <React.Fragment>
|
|
179
185
|
{`${wltpWeightedPowerCombinedContent} + `}
|
|
180
186
|
{`${weightedCombinedLabeled}, `}
|
|
181
187
|
{`${dischargedCombinedLabeled}`}
|
|
182
188
|
{co2WeightedContent && <>, {co2WeightedContent}</>}
|
|
183
189
|
{co2ClassWeighted && <>, {co2ClassWeighted}</>}
|
|
184
|
-
{<>, {co2ClassDischarged}</>}
|
|
190
|
+
{co2ClassDischarged && <>, {co2ClassDischarged}</>}
|
|
185
191
|
</React.Fragment>
|
|
186
192
|
}
|
|
187
193
|
|
|
@@ -316,7 +322,10 @@ const getDecoratedLightProps = (
|
|
|
316
322
|
if (hybridPlugin) {
|
|
317
323
|
if (wltpWeightedPowerCombinedContent && wltpWeightedCombinedContent) {
|
|
318
324
|
const dischargedCombined = Number.isFinite(wltpConsumptionCombined) ? wltpConsumptionCombined : 19.9;
|
|
319
|
-
|
|
325
|
+
// ADV-187: the discharged class is derived server-side from wltpCo2Discharged; when the
|
|
326
|
+
// backend could not derive it the field is selector_unknown — hide the segment, never
|
|
327
|
+
// fall back to a hard-coded class here.
|
|
328
|
+
const dischargedClass = car.environmentEmissions.wltpDischargedEnergyEfficiencyClass;
|
|
320
329
|
const weightedCombinedLabeled = t('vehicleProps:value.wltpWeightedCombinedLabel', { consumption: wltpWeightedCombined.toLocaleString(language), unit: translatedUnit });
|
|
321
330
|
const dischargedCombinedLabeled = t('vehicleProps:value.wltpDischargedCombinedLabel', { consumption: dischargedCombined.toLocaleString(language), unit: translatedUnit });
|
|
322
331
|
const co2WeightedContent = Number.isFinite(wltpCo2)
|
|
@@ -325,14 +334,16 @@ const getDecoratedLightProps = (
|
|
|
325
334
|
const co2ClassWeighted = isPropDefined(wltpEnergyEfficiencyClass)
|
|
326
335
|
? t('vehicleProps:value.co2ClassWeighted', { class: t(`cbd:${wltpEnergyEfficiencyClass}`) })
|
|
327
336
|
: null;
|
|
328
|
-
const co2ClassDischarged =
|
|
337
|
+
const co2ClassDischarged = isPropDefined(dischargedClass)
|
|
338
|
+
? t('vehicleProps:value.co2ClassDischarged', { class: t(`cbd:${dischargedClass}`) })
|
|
339
|
+
: null;
|
|
329
340
|
return <React.Fragment>
|
|
330
341
|
{`${wltpWeightedPowerCombinedContent} + `}
|
|
331
342
|
{`${weightedCombinedLabeled}, `}
|
|
332
343
|
{`${dischargedCombinedLabeled}`}
|
|
333
344
|
{co2WeightedContent && <>, {co2WeightedContent}</>}
|
|
334
345
|
{co2ClassWeighted && <>, {co2ClassWeighted}</>}
|
|
335
|
-
{<>, {co2ClassDischarged}</>}
|
|
346
|
+
{co2ClassDischarged && <>, {co2ClassDischarged}</>}
|
|
336
347
|
</React.Fragment>
|
|
337
348
|
}
|
|
338
349
|
|
|
@@ -509,6 +520,9 @@ const getDecoratedLightProps = (
|
|
|
509
520
|
title: t('cbd:mainData_accidentDamaged'),
|
|
510
521
|
icon: 'wrench',
|
|
511
522
|
get value() {
|
|
523
|
+
const strict = strictAccidentStatus(car);
|
|
524
|
+
if (strict === 'notSpecified') return t('vehicleProps:value.na');
|
|
525
|
+
if (strict) return strict === 'accident' ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
512
526
|
return damaged ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
513
527
|
}
|
|
514
528
|
},
|
|
@@ -9,6 +9,7 @@ import { EMISSION_STICKERS_ICONS, WP_EMISSION_STICKERS_ICONS } from '../constant
|
|
|
9
9
|
import { DELIVERY_PERIODS_EXTRA } from '../constants';
|
|
10
10
|
import { IDecoratedProp, ICar, IFinancingUtils } from '../types/types';
|
|
11
11
|
import { getFormattedPrice } from '../utils/CommonUtils';
|
|
12
|
+
import { strictAccidentStatus } from './accidentDisclosure';
|
|
12
13
|
|
|
13
14
|
const formatDeliveryPeriod = (t: (key: string, options?: object) => string, deliveryPeriod: string) => {
|
|
14
15
|
const count: number = +DELIVERY_PERIODS_EXTRA.find((period: any) => period.value === deliveryPeriod).label;
|
|
@@ -195,6 +196,9 @@ const getDecoratedProps = (
|
|
|
195
196
|
title: t('cbd:mainData_accidentDamaged'),
|
|
196
197
|
icon: 'wrench',
|
|
197
198
|
get value() {
|
|
199
|
+
const strict = strictAccidentStatus(car);
|
|
200
|
+
if (strict === 'notSpecified') return t('vehicleProps:value.na');
|
|
201
|
+
if (strict) return strict === 'accident' ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
198
202
|
return damaged ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
199
203
|
}
|
|
200
204
|
},
|
|
@@ -880,10 +884,12 @@ const getDecoratedProps = (
|
|
|
880
884
|
// (entladen, komb) fuel consumption + a discharged CO2 class.
|
|
881
885
|
if (hybridPlugin && wltpConsumptionWeightedPowerCombinedContent && wltpConsumptionWeightedCombinedContent) {
|
|
882
886
|
const ADV88_DEFAULT_DISCHARGED_COMBINED = 19.9;
|
|
883
|
-
const ADV88_DEFAULT_DISCHARGED_CO2_CLASS = 'selector_energyEfficiencyClass_g';
|
|
884
887
|
|
|
885
888
|
const dischargedCombined = Number.isFinite(wltpCombined) ? wltpCombined : ADV88_DEFAULT_DISCHARGED_COMBINED;
|
|
886
|
-
|
|
889
|
+
// ADV-187: the discharged class is derived server-side from wltpCo2Discharged; when the
|
|
890
|
+
// backend could not derive it the field is selector_unknown — hide the segment, never
|
|
891
|
+
// fall back to a hard-coded class here.
|
|
892
|
+
const dischargedClass = car.environmentEmissions.wltpDischargedEnergyEfficiencyClass;
|
|
887
893
|
|
|
888
894
|
const weightedCombinedLabeled = t('vehicleProps:value.wltpWeightedCombinedLabel', { consumption: wltpWeightedCombined.toLocaleString(language), unit: translatedUnit });
|
|
889
895
|
const dischargedCombinedLabeled = t('vehicleProps:value.wltpDischargedCombinedLabel', { consumption: dischargedCombined.toLocaleString(language), unit: translatedUnit });
|
|
@@ -893,7 +899,9 @@ const getDecoratedProps = (
|
|
|
893
899
|
const co2ClassWeighted = isPropDefined(wltpEnergyEfficiencyClass)
|
|
894
900
|
? t('vehicleProps:value.co2ClassWeighted', { class: t(`cbd:${wltpEnergyEfficiencyClass}`) })
|
|
895
901
|
: null;
|
|
896
|
-
const co2ClassDischarged =
|
|
902
|
+
const co2ClassDischarged = isPropDefined(dischargedClass)
|
|
903
|
+
? t('vehicleProps:value.co2ClassDischarged', { class: t(`cbd:${dischargedClass}`) })
|
|
904
|
+
: null;
|
|
897
905
|
|
|
898
906
|
return <React.Fragment>
|
|
899
907
|
{wrapValue(wltpConsumptionWeightedPowerCombinedContent)}{' + '}
|
|
@@ -901,7 +909,7 @@ const getDecoratedProps = (
|
|
|
901
909
|
{wrapValue(dischargedCombinedLabeled)}
|
|
902
910
|
{co2WeightedContent && <>{', '}{wrapValue(co2WeightedContent)}</>}
|
|
903
911
|
{co2ClassWeighted && <>{', '}{co2ClassWeighted}</>}
|
|
904
|
-
{', '}{co2ClassDischarged}
|
|
912
|
+
{co2ClassDischarged && <>{', '}{co2ClassDischarged}</>}
|
|
905
913
|
</React.Fragment>
|
|
906
914
|
}
|
|
907
915
|
|