@bytebrand/fe-ui-core-autobahn 1.0.169 → 1.0.170
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/TopBar.tsx +26 -25
- 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;
|
package/chrome/TopBar.tsx
CHANGED
|
@@ -35,12 +35,10 @@ const R_FAVOURITES = '/favourites';
|
|
|
35
35
|
const R_SAVED_SEARCHES = '/my-searches';
|
|
36
36
|
const R_MY_VEHICLES = '/my-vehicles/overview';
|
|
37
37
|
const R_SETTINGS = '/my-settings';
|
|
38
|
-
|
|
39
|
-
/** DashboardPage branches internally on authStore.isDealer — same route serves regular users too. */
|
|
38
|
+
/** DashboardPage branches internally on authStore.isDealer — the Konto menu links it for dealers/admins only. */
|
|
40
39
|
const R_DASHBOARD = '/account/dashboard';
|
|
41
40
|
const R_IMAGE_SETTINGS = '/account/image-settings';
|
|
42
41
|
const R_KONTAKT = '/account/kontakt';
|
|
43
|
-
const R_COMPARE = '/compare';
|
|
44
42
|
|
|
45
43
|
/** lib Icon strokes are in lucide's 24-unit viewBox: drawn at 22px this is the Konto menu's 1.8px. */
|
|
46
44
|
const ACCT_ICON_STROKE = (1.8 * 24) / 22;
|
|
@@ -94,16 +92,21 @@ export interface TopBarProps {
|
|
|
94
92
|
favoritesCount?: number;
|
|
95
93
|
/** unread Suchaufträge count — badge on the bell. Defaults to 0 (no badge). */
|
|
96
94
|
notificationCount?: number;
|
|
97
|
-
/** placed-orders count (profileStore.totalOrdered)
|
|
95
|
+
/** placed-orders count (profileStore.totalOrdered). Not shown: the Konto menu follows the role list
|
|
96
|
+
* (no "Meine Bestellung" row); kept so hosts that pass it still compile. */
|
|
98
97
|
ordersCount?: number;
|
|
99
98
|
/** saved searches (filterStore.savedSearchStrings.length) — badge on the "Gespeicherte Suchen" row. */
|
|
100
99
|
savedSearchesCount?: number;
|
|
101
|
-
/** cars picked for comparison (compareStore.vehiclesIDsToCompare.length)
|
|
100
|
+
/** cars picked for comparison (compareStore.vehiclesIDsToCompare.length). Not shown, same as ordersCount. */
|
|
102
101
|
compareCount?: number;
|
|
103
102
|
/** active language tag (appStore.language) — ticks the current language row. */
|
|
104
103
|
language?: string;
|
|
105
|
-
/** dealer-main account (authStore.isDealerMain) —
|
|
104
|
+
/** dealer-main account (authStore.isDealerMain) — Übersicht, Bildeinstellungen and the dealer switch. */
|
|
106
105
|
isDealerMain?: boolean;
|
|
106
|
+
/** dealer admin (authStore.isDealerAdmin) — Übersicht and Bildeinstellungen, like isDealerMain. */
|
|
107
|
+
isDealerAdmin?: boolean;
|
|
108
|
+
/** dealer employee (authStore.isEmployee) — the "Meine Händler" switch, like isDealerMain. */
|
|
109
|
+
isEmployee?: boolean;
|
|
107
110
|
/** attached dealerships (profileStore.dealers: { dealer: {id, email}, isActive }[]). */
|
|
108
111
|
dealers?: ReadonlyArray<{ dealer: { id: string; email: string }; isActive: boolean }>;
|
|
109
112
|
/** switch the active dealership (App.setMainDealer → profileStore.switchDealer). */
|
|
@@ -146,11 +149,11 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
146
149
|
userLabel,
|
|
147
150
|
favoritesCount = 0,
|
|
148
151
|
notificationCount = 0,
|
|
149
|
-
ordersCount = 0,
|
|
150
152
|
savedSearchesCount = 0,
|
|
151
|
-
compareCount = 0,
|
|
152
153
|
language = 'de',
|
|
153
154
|
isDealerMain = false,
|
|
155
|
+
isDealerAdmin = false,
|
|
156
|
+
isEmployee = false,
|
|
154
157
|
dealers = [],
|
|
155
158
|
onDealerSelect,
|
|
156
159
|
onSignOut,
|
|
@@ -256,8 +259,11 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
256
259
|
);
|
|
257
260
|
|
|
258
261
|
/** 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
|
-
*
|
|
262
|
+
* 312px dropdown at every width): the name, then groups split by lines. Rows and roles follow the
|
|
263
|
+
* PM's role list (2026-10-28): Übersicht and Bildeinstellungen for dealers/admins only, the dealer
|
|
264
|
+
* switch for employees, everything else for every user. Rows Figma doesn't draw use the same style. */
|
|
265
|
+
const isDealerOrAdmin = isDealerMain || isDealerAdmin;
|
|
266
|
+
const showDealers = (isDealerMain || isEmployee) && dealers.length > 1;
|
|
261
267
|
const renderAccountMenu = (): JSX.Element => (
|
|
262
268
|
<div className="acct-menu">
|
|
263
269
|
<div className="acct-scroll">
|
|
@@ -267,26 +273,16 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
267
273
|
<span className="acct-name">{userLabel || t('autobahn:chrome.myAccount')}</span>
|
|
268
274
|
</div>
|
|
269
275
|
<div className="acct-list">
|
|
270
|
-
{
|
|
271
|
-
{!isDealerMain &&
|
|
276
|
+
{isDealerOrAdmin &&
|
|
272
277
|
acctRow('overview', t('autobahn:chrome.acct.overview'), () => goRoute(R_DASHBOARD), { icon: 'layout-grid' })}
|
|
273
|
-
{
|
|
274
|
-
|
|
278
|
+
{acctRow('profile', t('autobahn:chrome.acct.profile'), () => goRoute(R_SETTINGS), { icon: 'user' })}
|
|
279
|
+
{acctRow('myVehicles', t('autobahn:chrome.myVehicles'), () => goRoute(R_MY_VEHICLES), { icon: 'car-front' })}
|
|
275
280
|
{acctRow('savedSearches', t('autobahn:chrome.acct.savedSearches'), () => goRoute(R_SAVED_SEARCHES), { icon: 'bookmark', badge: savedSearchesCount })}
|
|
276
281
|
{acctRow('favorites', t('autobahn:chrome.acct.favorites'), () => goRoute(R_FAVOURITES), { icon: 'star', badge: favoritesCount })}
|
|
277
|
-
{acctRow('compare', t('autobahn:chrome.acct.compare'), () => goRoute(R_COMPARE), { icon: 'scale', badge: compareCount })}
|
|
278
|
-
</div>
|
|
279
|
-
<div className="acct-list">
|
|
280
|
-
{acctRow('profile', t('autobahn:chrome.acct.profile'), () => goRoute(R_SETTINGS), { icon: 'user' })}
|
|
281
|
-
</div>
|
|
282
|
-
<div className="acct-list">
|
|
283
|
-
{acctRow('support', t('autobahn:chrome.acct.support'), () => goRoute(R_KONTAKT), { icon: 'help-circle' })}
|
|
284
282
|
</div>
|
|
285
|
-
{
|
|
283
|
+
{(showDealers || isDealerOrAdmin) && (
|
|
286
284
|
<div className="acct-list">
|
|
287
|
-
{
|
|
288
|
-
{acctRow('imageSettings', t('autobahn:chrome.imageSettings'), () => goRoute(R_IMAGE_SETTINGS), { lucide: 'image' })}
|
|
289
|
-
{dealers.length > 1 && (
|
|
285
|
+
{showDealers && (
|
|
290
286
|
<>
|
|
291
287
|
<div className="acct-sub">{t('autobahn:chrome.myDealers')} ({dealers.length})</div>
|
|
292
288
|
{dealers.map((d) =>
|
|
@@ -297,8 +293,13 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
297
293
|
)}
|
|
298
294
|
</>
|
|
299
295
|
)}
|
|
296
|
+
{isDealerOrAdmin &&
|
|
297
|
+
acctRow('imageSettings', t('autobahn:chrome.imageSettings'), () => goRoute(R_IMAGE_SETTINGS), { lucide: 'image' })}
|
|
300
298
|
</div>
|
|
301
299
|
)}
|
|
300
|
+
<div className="acct-list">
|
|
301
|
+
{acctRow('support', t('autobahn:chrome.acct.support'), () => goRoute(R_KONTAKT), { icon: 'help-circle' })}
|
|
302
|
+
</div>
|
|
302
303
|
{renderLanguageRows()}
|
|
303
304
|
<div className="acct-list">
|
|
304
305
|
{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.170",
|
|
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
|
|