@bytebrand/fe-ui-core-autobahn 1.0.181 → 1.0.183
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 +8 -1
- package/cards/CarCardSkeleton.tsx +103 -0
- package/cards/CarRow.tsx +5 -1
- package/cards/CarRowSkeleton.tsx +152 -0
- package/cards/cardParts.tsx +5 -0
- package/cards/index.ts +6 -0
- package/chrome/AccountMenuIcon.tsx +109 -0
- package/chrome/Footer.tsx +16 -3
- package/chrome/TopBar.tsx +139 -266
- package/compat/CookieModal/CookieModal.tsx +20 -6
- package/compat/CookieModal/Modal.tsx +6 -3
- package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +43 -15
- package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +4 -3
- package/compat/CookieModal/useModal.ts +5 -1
- package/compat/Loader/Loader.tsx +1 -7
- package/compat/MdField/MdField.tsx +28 -4
- package/compat/TimePicker/TimePicker.tsx +12 -2
- package/data/toAutobahnCar.ts +16 -2
- package/iconsvg/IconSVG.tsx +1 -5
- package/locales/de/autobahn.json +37 -5
- package/locales/en/autobahn.json +36 -4
- package/package.json +1 -1
- package/theme/md3.css +5327 -1210
- package/ui/Dropdown.tsx +29 -10
- package/ui/FormCheckbox.tsx +22 -2
- package/ui/FormField.tsx +2 -1
- package/ui/Icon.tsx +6 -0
- package/ui/MfieldCheckIcon.tsx +13 -0
- package/ui/Modal.tsx +84 -6
- package/ui/Skeleton.tsx +79 -20
- package/ui/index.ts +2 -0
- package/ui/scrollFieldIntoView.ts +41 -0
- package/ui/usePortalMenuPosition.ts +27 -15
- package/utils/cookieConsent.ts +84 -0
- package/utils/index.ts +10 -0
- package/vdp/FinanceCalculator.tsx +19 -5
- package/vdp/VdpModules.tsx +36 -6
- package/vdp/types.ts +5 -5
- package/vehiclesProps/accidentDisclosure.ts +25 -0
- package/vehiclesProps/decoratedLightProps.tsx +4 -0
- package/vehiclesProps/decoratedProps.tsx +4 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// ADV-268 — the cookie consent store (`localStorage['cookieConfig']`: per category the DISABLED
|
|
2
|
+
// vendor-cookie names, see COOKIE_SCHEMA) plus what the account page needs on top of it:
|
|
3
|
+
// - when the choice last changed (`cookieConfigChangedAt`, ISO), written on every save that
|
|
4
|
+
// changes it — the consent dialogs save through saveCookieConfig;
|
|
5
|
+
// - a window event after each save, so a page showing the state can update live;
|
|
6
|
+
// - openCookieSettings(), which makes the mounted CookieModal show its settings dialog again.
|
|
7
|
+
// Storage access is guarded: with site storage blocked every read returns "no choice yet".
|
|
8
|
+
|
|
9
|
+
import { COOKIE_SCHEMA } from '../constants/common';
|
|
10
|
+
|
|
11
|
+
export const COOKIE_CONFIG_KEY = 'cookieConfig';
|
|
12
|
+
export const COOKIE_CONFIG_CHANGED_AT_KEY = 'cookieConfigChangedAt';
|
|
13
|
+
export const COOKIE_CONSENT_CHANGE_EVENT = 'autode:cookie-consent-change';
|
|
14
|
+
export const OPEN_COOKIE_SETTINGS_EVENT = 'autode:open-cookie-settings';
|
|
15
|
+
|
|
16
|
+
export interface ICookieConfig {
|
|
17
|
+
marketing: string[];
|
|
18
|
+
analytics: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type CookieCategoryState = 'on' | 'partial' | 'off';
|
|
22
|
+
|
|
23
|
+
export interface ICookieConsentState {
|
|
24
|
+
/** false until the visitor saved a choice in the cookie dialog */
|
|
25
|
+
decided: boolean;
|
|
26
|
+
/** ISO date of the last change, null when unknown (no choice yet, or saved before it was recorded) */
|
|
27
|
+
changedAt: string | null;
|
|
28
|
+
analytics: CookieCategoryState;
|
|
29
|
+
marketing: CookieCategoryState;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const vendorCookies = (category: 'analytics' | 'marketing'): string[] =>
|
|
33
|
+
Object.values(COOKIE_SCHEMA[category]).reduce((acc: string[], val: string[]) => acc.concat(val), []);
|
|
34
|
+
|
|
35
|
+
const readStorage = (key: string): string | null => {
|
|
36
|
+
try {
|
|
37
|
+
return localStorage.getItem(key);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const saveCookieConfig = (config: ICookieConfig | Record<string, string[]>) => {
|
|
44
|
+
const next = JSON.stringify(config);
|
|
45
|
+
try {
|
|
46
|
+
const previous = localStorage.getItem(COOKIE_CONFIG_KEY);
|
|
47
|
+
localStorage.setItem(COOKIE_CONFIG_KEY, next);
|
|
48
|
+
if (previous !== next || !localStorage.getItem(COOKIE_CONFIG_CHANGED_AT_KEY)) {
|
|
49
|
+
localStorage.setItem(COOKIE_CONFIG_CHANGED_AT_KEY, new Date().toISOString());
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
window.dispatchEvent(new Event(COOKIE_CONSENT_CHANGE_EVENT));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const getCookieConsentState = (): ICookieConsentState => {
|
|
58
|
+
let config: Partial<ICookieConfig> | null = null;
|
|
59
|
+
try {
|
|
60
|
+
config = JSON.parse(readStorage(COOKIE_CONFIG_KEY));
|
|
61
|
+
} catch (e) {
|
|
62
|
+
config = null;
|
|
63
|
+
}
|
|
64
|
+
if (!config) return { decided: false, changedAt: null, analytics: 'off', marketing: 'off' };
|
|
65
|
+
|
|
66
|
+
const categoryState = (category: 'analytics' | 'marketing'): CookieCategoryState => {
|
|
67
|
+
const disabled = Array.isArray(config[category]) ? config[category] : [];
|
|
68
|
+
const all = vendorCookies(category);
|
|
69
|
+
const allowed = all.filter((cookie) => !disabled.includes(cookie)).length;
|
|
70
|
+
if (allowed === all.length) return 'on';
|
|
71
|
+
return allowed ? 'partial' : 'off';
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
decided: true,
|
|
76
|
+
changedAt: readStorage(COOKIE_CONFIG_CHANGED_AT_KEY),
|
|
77
|
+
analytics: categoryState('analytics'),
|
|
78
|
+
marketing: categoryState('marketing')
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const openCookieSettings = () => {
|
|
83
|
+
window.dispatchEvent(new Event(OPEN_COOKIE_SETTINGS_EVENT));
|
|
84
|
+
};
|
package/utils/index.ts
CHANGED
|
@@ -62,6 +62,14 @@ export {
|
|
|
62
62
|
updateCookieList
|
|
63
63
|
} from './CommonUtils';
|
|
64
64
|
|
|
65
|
+
export {
|
|
66
|
+
COOKIE_CONSENT_CHANGE_EVENT,
|
|
67
|
+
getCookieConsentState,
|
|
68
|
+
openCookieSettings,
|
|
69
|
+
saveCookieConfig
|
|
70
|
+
} from './cookieConsent';
|
|
71
|
+
export type { CookieCategoryState, ICookieConsentState } from './cookieConsent';
|
|
72
|
+
|
|
65
73
|
export { getEquipment, getEquipmentCount } from '../vehiclesProps/equipment';
|
|
66
74
|
|
|
67
75
|
export type { IDecoratedProps, IEquipmentProps, ICarPropElement } from '../types/types';
|
|
@@ -83,3 +91,5 @@ export type { IValues, IFilters, IQuery } from './query';
|
|
|
83
91
|
// Decorated car props (renders React UI; lives in vehiclesProps/ with its
|
|
84
92
|
// IconContainer + Co2Widget dependencies under compat/).
|
|
85
93
|
export { default as getDecoratedProps } from '../vehiclesProps/decoratedProps';
|
|
94
|
+
export { setStrictConditionOwners, isStrictConditionOwner, strictAccidentStatus } from '../vehiclesProps/accidentDisclosure';
|
|
95
|
+
export type { AccidentStatus } from '../vehiclesProps/accidentDisclosure';
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Renders correctly only inside a `<div className="md3">` subtree.
|
|
15
15
|
|
|
16
|
-
import React, { useState } from 'react';
|
|
16
|
+
import React, { useState, useEffect } from 'react';
|
|
17
17
|
import { TranslationFunction } from '../types';
|
|
18
18
|
|
|
19
19
|
import { Button, Icon, Switch } from '../ui';
|
|
@@ -52,8 +52,18 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
52
52
|
bubble,
|
|
53
53
|
bubblePaddingBottom = 34,
|
|
54
54
|
}) => {
|
|
55
|
+
// Local mirror of `value`, updated INSTANTLY on every native input event. Callers commonly
|
|
56
|
+
// debounce their own onChange (e.g. CheckoutFinancePanelNext's 50ms setCommonUserConfig,
|
|
57
|
+
// which also triggers a MobX-driven re-render of a much bigger subtree) — without this, the
|
|
58
|
+
// thumb still drags natively/smoothly (the browser owns that), but the gradient fill and any
|
|
59
|
+
// bubble label are driven by the `value` PROP, which only catches up once the debounced commit
|
|
60
|
+
// finally lands, so the fill visibly lags/stutters behind the thumb during a fast drag. Synced
|
|
61
|
+
// back to the prop via useEffect for externally-driven changes (e.g. a reset button).
|
|
62
|
+
const [localValue, setLocalValue] = useState(value);
|
|
63
|
+
useEffect(() => { setLocalValue(value); }, [value]);
|
|
64
|
+
|
|
55
65
|
const span = max - min;
|
|
56
|
-
const pct = span > 0 ? ((
|
|
66
|
+
const pct = span > 0 ? ((localValue - min) / span) * 100 : 0;
|
|
57
67
|
return (
|
|
58
68
|
<div>
|
|
59
69
|
<div style={{ position: 'relative', paddingTop: bubble ? 44 : 0, paddingBottom: bubble ? bubblePaddingBottom : 0 }}>
|
|
@@ -61,7 +71,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
61
71
|
// thumb is 22px wide: interpolate the bubble anchor between half-thumb insets so it
|
|
62
72
|
// tracks the thumb center (a plain pct% drifts at the rail ends)
|
|
63
73
|
<span className="slider-bubble num" style={{ left: `calc(11px + (100% - 22px) * ${pct / 100})` }}>
|
|
64
|
-
{fmt(
|
|
74
|
+
{fmt(localValue)}
|
|
65
75
|
</span>
|
|
66
76
|
)}
|
|
67
77
|
<input
|
|
@@ -70,8 +80,12 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
70
80
|
min={min}
|
|
71
81
|
max={max}
|
|
72
82
|
step={step}
|
|
73
|
-
value={
|
|
74
|
-
onChange={(e) =>
|
|
83
|
+
value={localValue}
|
|
84
|
+
onChange={(e) => {
|
|
85
|
+
const v = Number(e.target.value);
|
|
86
|
+
setLocalValue(v);
|
|
87
|
+
onChange(v);
|
|
88
|
+
}}
|
|
75
89
|
style={{ background: `linear-gradient(90deg, var(--md-primary) ${pct}%, var(--md-sc-highest) ${pct}%)` }}
|
|
76
90
|
/>
|
|
77
91
|
</div>
|
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
|
];
|
|
@@ -2126,6 +2126,12 @@ export interface FinanceDetailsModalProps {
|
|
|
2126
2126
|
/** opened directly via the page's Finanzierungs-/Leasingdetails link — the sheet opens
|
|
2127
2127
|
* scrolled to the breakdown instead of the "Rate anpassen" controls at its top. */
|
|
2128
2128
|
initialShowBreakdown?: boolean;
|
|
2129
|
+
/** skips the smooth scrollIntoView/scrollSheetToBreakdown animation initialShowBreakdown
|
|
2130
|
+
* otherwise triggers on open (still sets showBreakdown itself) — for a consumer whose sheet
|
|
2131
|
+
* has nothing ABOVE the breakdown to scroll past (e.g. checkout's stripped-down instance,
|
|
2132
|
+
* with the rate hero/sliders/toggles above it hidden), that animation has nowhere real to go
|
|
2133
|
+
* and only reads as a stray jump. */
|
|
2134
|
+
skipInitialScroll?: boolean;
|
|
2129
2135
|
/** mobile only — price-rating label, drives the eval pill/bar (same as the collapsed card). */
|
|
2130
2136
|
ratingLabel?: string;
|
|
2131
2137
|
/** Kaufen tab only — real carStore.isAvailable (same source as VdpTrustRow's "Sofort
|
|
@@ -2154,6 +2160,10 @@ export interface FinanceDetailsModalProps {
|
|
|
2154
2160
|
leasingAvailable?: boolean;
|
|
2155
2161
|
/** i18n function (drilled from the page). */
|
|
2156
2162
|
t: TranslationFunction;
|
|
2163
|
+
/** overrides the desktop dialog heading (default: the mode's own, shorter "Details" text) —
|
|
2164
|
+
* a consumer whose own trigger already carries a specific label (e.g. checkout's cf-details
|
|
2165
|
+
* button, "Finanzierungsdetails"/"Leasingdetails") can pass that same text through here. */
|
|
2166
|
+
titleOverride?: string;
|
|
2157
2167
|
}
|
|
2158
2168
|
|
|
2159
2169
|
/**
|
|
@@ -2197,6 +2207,7 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2197
2207
|
onAnnualMileageChange,
|
|
2198
2208
|
onClose,
|
|
2199
2209
|
initialShowBreakdown,
|
|
2210
|
+
skipInitialScroll,
|
|
2200
2211
|
ratingLabel,
|
|
2201
2212
|
available,
|
|
2202
2213
|
onModeChange,
|
|
@@ -2211,6 +2222,7 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2211
2222
|
onToggleAddServices,
|
|
2212
2223
|
leasingAvailable = true,
|
|
2213
2224
|
t,
|
|
2225
|
+
titleOverride,
|
|
2214
2226
|
}) => {
|
|
2215
2227
|
// same "UVP-Rate"/list-price footnote badge + popover as FinanceCalculator's own hero — this
|
|
2216
2228
|
// modal's mobile "Rate anpassen" sheet renders its own separate copy of that hero row, so it
|
|
@@ -2314,14 +2326,14 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2314
2326
|
React.useEffect(() => {
|
|
2315
2327
|
if (!open) return;
|
|
2316
2328
|
setShowBreakdown(!!initialShowBreakdown);
|
|
2317
|
-
if (!initialShowBreakdown) return;
|
|
2329
|
+
if (!initialShowBreakdown || skipInitialScroll) return;
|
|
2318
2330
|
const timer = window.setTimeout(() => {
|
|
2319
2331
|
if (mobileBreakdownRef.current?.offsetParent) scrollSheetToBreakdown();
|
|
2320
2332
|
else desktopBreakdownRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
2321
2333
|
}, 50);
|
|
2322
2334
|
return () => window.clearTimeout(timer);
|
|
2323
2335
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2324
|
-
}, [open, initialShowBreakdown]);
|
|
2336
|
+
}, [open, initialShowBreakdown, skipInitialScroll]);
|
|
2325
2337
|
// in-sheet details link: expanding scrolls down to the breakdown, collapsing back to the top.
|
|
2326
2338
|
const revealBreakdownRef = React.useRef(false);
|
|
2327
2339
|
React.useEffect(() => {
|
|
@@ -2331,6 +2343,24 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2331
2343
|
else animateSheetScroll(() => 0);
|
|
2332
2344
|
}, [showBreakdown, scrollSheetToBreakdown, animateSheetScroll]);
|
|
2333
2345
|
|
|
2346
|
+
// iOS Safari (26+, "Allow Website Tinting") paints its bottom toolbar area with the page's
|
|
2347
|
+
// <meta name="theme-color"> (site-wide blue #005CCB) — under the open white sheet that showed
|
|
2348
|
+
// as a solid blue band right below the CTA. While the sheet is open, theme-color is white;
|
|
2349
|
+
// on close the previous value(s) are restored. Other pages/states are untouched.
|
|
2350
|
+
React.useEffect(() => {
|
|
2351
|
+
if (!open || typeof document === 'undefined') return;
|
|
2352
|
+
const metas = Array.from(document.querySelectorAll<HTMLMetaElement>('meta[name="theme-color"]'));
|
|
2353
|
+
const prev = metas.map((m) => m.getAttribute('content'));
|
|
2354
|
+
metas.forEach((m) => m.setAttribute('content', '#FFFFFF'));
|
|
2355
|
+
return () => {
|
|
2356
|
+
metas.forEach((m, i) => {
|
|
2357
|
+
const v = prev[i];
|
|
2358
|
+
if (v == null) m.removeAttribute('content');
|
|
2359
|
+
else m.setAttribute('content', v);
|
|
2360
|
+
});
|
|
2361
|
+
};
|
|
2362
|
+
}, [open]);
|
|
2363
|
+
|
|
2334
2364
|
// mobile-only: swipe-down-to-dismiss on the grabber/header (the mockup's drag handle).
|
|
2335
2365
|
// The sheet follows the finger (imperative transform — no re-renders while dragging);
|
|
2336
2366
|
// released past 90px it slides out and closes, otherwise it springs back. The element
|
|
@@ -2371,7 +2401,7 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2371
2401
|
if (!open) return null;
|
|
2372
2402
|
const isLease = mode === 'leasing';
|
|
2373
2403
|
const isCash = mode === 'cash';
|
|
2374
|
-
const title = isLease ? t('autobahn:modal.leasingDetails') : t('autobahn:modal.financingDetails');
|
|
2404
|
+
const title = titleOverride || (isLease ? t('autobahn:modal.leasingDetails') : t('autobahn:modal.financingDetails'));
|
|
2375
2405
|
const mobileTitle = isCash
|
|
2376
2406
|
? t('autobahn:modal.sheetTitleCash')
|
|
2377
2407
|
: isLease
|
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
|
import { gasConsumptionTemplate } from './cbdSelectors';
|
|
10
11
|
|
|
11
12
|
interface IDecoratedProps {
|
|
@@ -520,6 +521,9 @@ const getDecoratedLightProps = (
|
|
|
520
521
|
title: t('cbd:mainData_accidentDamaged'),
|
|
521
522
|
icon: 'wrench',
|
|
522
523
|
get value() {
|
|
524
|
+
const strict = strictAccidentStatus(car);
|
|
525
|
+
if (strict === 'notSpecified') return t('vehicleProps:value.na');
|
|
526
|
+
if (strict) return strict === 'accident' ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
523
527
|
return damaged ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
524
528
|
}
|
|
525
529
|
},
|
|
@@ -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
|
import { gasConsumptionTemplate } from './cbdSelectors';
|
|
13
14
|
|
|
14
15
|
const formatDeliveryPeriod = (t: (key: string, options?: object) => string, deliveryPeriod: string) => {
|
|
@@ -196,6 +197,9 @@ const getDecoratedProps = (
|
|
|
196
197
|
title: t('cbd:mainData_accidentDamaged'),
|
|
197
198
|
icon: 'wrench',
|
|
198
199
|
get value() {
|
|
200
|
+
const strict = strictAccidentStatus(car);
|
|
201
|
+
if (strict === 'notSpecified') return t('vehicleProps:value.na');
|
|
202
|
+
if (strict) return strict === 'accident' ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
199
203
|
return damaged ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
200
204
|
}
|
|
201
205
|
},
|