@bytebrand/fe-ui-core-autobahn 1.0.210 → 1.0.211
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 +12 -43
- package/cards/CarCardSkeleton.tsx +103 -0
- package/cards/CarRowSkeleton.tsx +152 -0
- package/cards/cardParts.tsx +1 -6
- 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/constants/app.ts +1 -11
- package/constants/core.ts +1 -12
- package/data/toAutobahnCar.ts +16 -2
- package/iconsvg/IconSVG.tsx +1 -5
- package/locales/de/autobahn.json +46 -12
- package/locales/en/autobahn.json +45 -11
- package/package.json +2 -2
- package/theme/md3.css +5321 -1207
- package/ui/CreditCostNotice.tsx +44 -44
- 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 +56 -13
- package/vdp/types.ts +5 -5
- package/vehiclesProps/accidentDisclosure.ts +25 -0
- package/vehiclesProps/decoratedLightProps.tsx +4 -0
- package/vehiclesProps/decoratedProps.tsx +4 -0
|
@@ -45,6 +45,11 @@ export interface UsePortalMenuPositionArgs {
|
|
|
45
45
|
/** the trigger's wrapping element — always rendered (regardless of `open`), measured for position. */
|
|
46
46
|
rootRef: React.RefObject<HTMLElement>;
|
|
47
47
|
menuAlign?: 'left' | 'right';
|
|
48
|
+
/** 'auto' (default): flips ABOVE the trigger when there isn't room below (see ESTIMATED_MENU_HEIGHT
|
|
49
|
+
* below). 'down': always opens below, never flips — for a trigger where the caller knows the
|
|
50
|
+
* page has room below and an upward flip would overlap unrelated content above it (e.g. a
|
|
51
|
+
* trigger sitting right under a sticky/close heading). */
|
|
52
|
+
openDirection?: 'auto' | 'down';
|
|
48
53
|
/** called when the trigger scrolls out of view entirely, or a real user scroll happens after
|
|
49
54
|
* the post-open grace window — the menu has nothing sensible left to anchor to or chase. */
|
|
50
55
|
onCloseAway: () => void;
|
|
@@ -71,14 +76,32 @@ export interface UsePortalMenuPositionResult<TMenuEl extends HTMLElement = HTMLD
|
|
|
71
76
|
// reasonable estimate; it decides whether to flip ABOVE the trigger. The real size is then
|
|
72
77
|
// clamped to the space actually available (see `maxHeight` above), not just guessed at.
|
|
73
78
|
const ESTIMATED_MENU_HEIGHT = 300;
|
|
79
|
+
// .mselect-menu's own padding + border (6px*2 + 1px*2) — the consumers add it back on top of
|
|
80
|
+
// `maxHeight` for the box, so the space it fits into has to leave room for it.
|
|
81
|
+
const MENU_CHROME = 14;
|
|
74
82
|
// a scroll within this window of opening REPOSITIONS instead of closing — see the effect below.
|
|
75
83
|
const SELF_SCROLL_GRACE_MS = 500;
|
|
76
84
|
|
|
85
|
+
// Module-level (not hook-local) so Dropdown.tsx's own searchable-open scroll effect can reuse the
|
|
86
|
+
// exact same measurement — the sticky app header (.topbar, position:sticky/top:0) sits over the
|
|
87
|
+
// top of the viewport on every page that uses it (TopBar's autoHideOnScroll is opt-in, off by
|
|
88
|
+
// default — most pages keep it permanently docked), so anything that scrolls/positions content
|
|
89
|
+
// near the top of the viewport needs to stop at its live bottom edge, not y=0. Reading the
|
|
90
|
+
// header's live bottom edge (0 when absent, e.g. inside a modal, or when autoHideOnScroll has slid
|
|
91
|
+
// it away) gives a correct boundary without hardcoding a pixel height that could drift from the
|
|
92
|
+
// header's own CSS.
|
|
93
|
+
export const getSafeTop = (): number => {
|
|
94
|
+
if (typeof document === 'undefined') return 0;
|
|
95
|
+
const header = document.querySelector('.topbar');
|
|
96
|
+
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
97
|
+
};
|
|
98
|
+
|
|
77
99
|
export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivElement>({
|
|
78
100
|
enabled,
|
|
79
101
|
open,
|
|
80
102
|
rootRef,
|
|
81
103
|
menuAlign = 'left',
|
|
104
|
+
openDirection = 'auto',
|
|
82
105
|
onCloseAway,
|
|
83
106
|
}: UsePortalMenuPositionArgs): UsePortalMenuPositionResult<TMenuEl> {
|
|
84
107
|
const menuElRef = React.useRef<TMenuEl | null>(null);
|
|
@@ -115,18 +138,6 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
115
138
|
};
|
|
116
139
|
}, [enabled, open, portalRoot]);
|
|
117
140
|
|
|
118
|
-
// the portal menu's z-index (1400, .mselect-menu--portal) is intentionally higher than every
|
|
119
|
-
// other fixed overlay it must paint over (checkout sheets/modals) — which also means it would
|
|
120
|
-
// paint over the sticky app header (.topbar, position:sticky/top:0/z-index:50) if left
|
|
121
|
-
// unconstrained. Reading the header's live bottom edge (0 when absent, e.g. inside a modal, or
|
|
122
|
-
// when TopBar's autoHideOnScroll has slid it away) gives a correct top boundary without
|
|
123
|
-
// hardcoding a pixel height that could drift from the header's own CSS.
|
|
124
|
-
const getSafeTop = (): number => {
|
|
125
|
-
if (typeof document === 'undefined') return 0;
|
|
126
|
-
const header = document.querySelector('.topbar');
|
|
127
|
-
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
141
|
const [menuPos, setMenuPos] = React.useState<PortalMenuPos | null>(null);
|
|
131
142
|
|
|
132
143
|
const positionMenu = React.useCallback(() => {
|
|
@@ -144,13 +155,14 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
144
155
|
}
|
|
145
156
|
const spaceBelow = window.innerHeight - rect.bottom - GAP;
|
|
146
157
|
const spaceAbove = rect.top - safeTop - GAP;
|
|
147
|
-
const openAbove = spaceBelow < ESTIMATED_MENU_HEIGHT && spaceAbove > spaceBelow;
|
|
158
|
+
const openAbove = openDirection === 'down' ? false : (spaceBelow < ESTIMATED_MENU_HEIGHT && spaceAbove > spaceBelow);
|
|
148
159
|
// cap the menu to the space it ACTUALLY has in whichever direction it opens, instead of
|
|
149
160
|
// trusting a static CSS max-height on its own — near the header or viewport edge that static
|
|
150
161
|
// cap can still be taller than what's really available, which is what let the menu paint over
|
|
151
162
|
// the header in the first place. The consumer's own overflow-y:auto takes it from there once
|
|
152
163
|
// content exceeds this.
|
|
153
|
-
|
|
164
|
+
// `available` is the LIST's height: the box (list + MENU_CHROME) must end inside the viewport.
|
|
165
|
+
const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, (openAbove ? spaceAbove : spaceBelow) - MENU_CHROME));
|
|
154
166
|
setMenuPos({
|
|
155
167
|
width: rect.width,
|
|
156
168
|
left: menuAlign === 'right' ? 'auto' : rect.left,
|
|
@@ -159,7 +171,7 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
159
171
|
bottom: openAbove ? window.innerHeight - rect.top + GAP : 'auto',
|
|
160
172
|
maxHeight: available,
|
|
161
173
|
});
|
|
162
|
-
}, [enabled, menuAlign, onCloseAway, rootRef]);
|
|
174
|
+
}, [enabled, menuAlign, openDirection, onCloseAway, rootRef]);
|
|
163
175
|
|
|
164
176
|
// Synchronous (pre-paint) position computation. useLayoutEffect — not useEffect — matters here:
|
|
165
177
|
// it runs right after the DOM mutation that mounted the portal but BEFORE the browser paints, so
|
|
@@ -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, CreditCostNotice, CreditKeyFigures, hasCreditKeyFigures } from '../ui';
|
|
@@ -53,8 +53,18 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
53
53
|
bubble,
|
|
54
54
|
bubblePaddingBottom = 34,
|
|
55
55
|
}) => {
|
|
56
|
+
// Local mirror of `value`, updated INSTANTLY on every native input event. Callers commonly
|
|
57
|
+
// debounce their own onChange (e.g. CheckoutFinancePanelNext's 50ms setCommonUserConfig,
|
|
58
|
+
// which also triggers a MobX-driven re-render of a much bigger subtree) — without this, the
|
|
59
|
+
// thumb still drags natively/smoothly (the browser owns that), but the gradient fill and any
|
|
60
|
+
// bubble label are driven by the `value` PROP, which only catches up once the debounced commit
|
|
61
|
+
// finally lands, so the fill visibly lags/stutters behind the thumb during a fast drag. Synced
|
|
62
|
+
// back to the prop via useEffect for externally-driven changes (e.g. a reset button).
|
|
63
|
+
const [localValue, setLocalValue] = useState(value);
|
|
64
|
+
useEffect(() => { setLocalValue(value); }, [value]);
|
|
65
|
+
|
|
56
66
|
const span = max - min;
|
|
57
|
-
const pct = span > 0 ? ((
|
|
67
|
+
const pct = span > 0 ? ((localValue - min) / span) * 100 : 0;
|
|
58
68
|
return (
|
|
59
69
|
<div>
|
|
60
70
|
<div style={{ position: 'relative', paddingTop: bubble ? 44 : 0, paddingBottom: bubble ? bubblePaddingBottom : 0 }}>
|
|
@@ -62,7 +72,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
62
72
|
// thumb is 22px wide: interpolate the bubble anchor between half-thumb insets so it
|
|
63
73
|
// tracks the thumb center (a plain pct% drifts at the rail ends)
|
|
64
74
|
<span className="slider-bubble num" style={{ left: `calc(11px + (100% - 22px) * ${pct / 100})` }}>
|
|
65
|
-
{fmt(
|
|
75
|
+
{fmt(localValue)}
|
|
66
76
|
</span>
|
|
67
77
|
)}
|
|
68
78
|
<input
|
|
@@ -71,8 +81,12 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
71
81
|
min={min}
|
|
72
82
|
max={max}
|
|
73
83
|
step={step}
|
|
74
|
-
value={
|
|
75
|
-
onChange={(e) =>
|
|
84
|
+
value={localValue}
|
|
85
|
+
onChange={(e) => {
|
|
86
|
+
const v = Number(e.target.value);
|
|
87
|
+
setLocalValue(v);
|
|
88
|
+
onChange(v);
|
|
89
|
+
}}
|
|
76
90
|
style={{ background: `linear-gradient(90deg, var(--md-primary) ${pct}%, var(--md-sc-highest) ${pct}%)` }}
|
|
77
91
|
/>
|
|
78
92
|
</div>
|
package/vdp/VdpModules.tsx
CHANGED
|
@@ -93,7 +93,7 @@ export const VdpHeaderSummary: React.FunctionComponent<VdpHeaderCardProps> = ({
|
|
|
93
93
|
['zap', extractPS(vehicle.power)],
|
|
94
94
|
['fuel', stripParen(vehicle.fuel)],
|
|
95
95
|
['cog', vehicle.gear],
|
|
96
|
-
['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })],
|
|
96
|
+
...(vehicle.owners == null ? [] : ([['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })]] as const)),
|
|
97
97
|
];
|
|
98
98
|
return (
|
|
99
99
|
<>
|
|
@@ -143,7 +143,7 @@ export const VdpFactsGrid: React.FunctionComponent<VdpHeaderCardProps> = ({ vehi
|
|
|
143
143
|
['calendar', vehicle.reg],
|
|
144
144
|
['cog', vehicle.gear],
|
|
145
145
|
['fuel', stripParen(vehicle.fuel)],
|
|
146
|
-
['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })],
|
|
146
|
+
...(vehicle.owners == null ? [] : ([['user', t('autobahn:header.owners', { owners: vehicle.owners, count: vehicle.owners })]] as const)),
|
|
147
147
|
...(vehicle.body ? ([['car-front', vehicle.body]] as const) : []),
|
|
148
148
|
];
|
|
149
149
|
return (
|
|
@@ -217,7 +217,7 @@ export const VdpHeaderCondition: React.FunctionComponent<VdpHeaderCardProps> = (
|
|
|
217
217
|
// only the Garantie tile has one, linking out to auto.de's warranty policy page.
|
|
218
218
|
const tiles: ReadonlyArray<readonly [string, string, string, string?]> = [
|
|
219
219
|
['wrench', t('autobahn:header.huLabel'), condition.hu === 'Neu' ? t('autobahn:header.huNew') : t('autobahn:header.huUntil', { date: condition.hu })],
|
|
220
|
-
['shield-check', t('autobahn:header.accidentFree'), condition.unfallfrei ? t('autobahn:header.yes') : t('autobahn:header.no')],
|
|
220
|
+
['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')],
|
|
221
221
|
['clipboard-check', t('autobahn:header.serviceHistory'), condition.scheckheft ? t('autobahn:header.yes') : t('autobahn:header.no')],
|
|
222
222
|
['award', t('autobahn:header.warranty'), condition.garantie, 'https://www.auto.de/garantie/'],
|
|
223
223
|
];
|
|
@@ -2174,6 +2174,12 @@ export interface FinanceDetailsModalProps {
|
|
|
2174
2174
|
/** opened directly via the page's Finanzierungs-/Leasingdetails link — the sheet opens
|
|
2175
2175
|
* scrolled to the breakdown instead of the "Rate anpassen" controls at its top. */
|
|
2176
2176
|
initialShowBreakdown?: boolean;
|
|
2177
|
+
/** skips the smooth scrollIntoView/scrollSheetToBreakdown animation initialShowBreakdown
|
|
2178
|
+
* otherwise triggers on open (still sets showBreakdown itself) — for a consumer whose sheet
|
|
2179
|
+
* has nothing ABOVE the breakdown to scroll past (e.g. checkout's stripped-down instance,
|
|
2180
|
+
* with the rate hero/sliders/toggles above it hidden), that animation has nowhere real to go
|
|
2181
|
+
* and only reads as a stray jump. */
|
|
2182
|
+
skipInitialScroll?: boolean;
|
|
2177
2183
|
/** mobile only — price-rating label, drives the eval pill/bar (same as the collapsed card). */
|
|
2178
2184
|
ratingLabel?: string;
|
|
2179
2185
|
/** Kaufen tab only — real carStore.isAvailable (same source as VdpTrustRow's "Sofort
|
|
@@ -2202,6 +2208,10 @@ export interface FinanceDetailsModalProps {
|
|
|
2202
2208
|
leasingAvailable?: boolean;
|
|
2203
2209
|
/** i18n function (drilled from the page). */
|
|
2204
2210
|
t: TranslationFunction;
|
|
2211
|
+
/** overrides the desktop dialog heading (default: the mode's own, shorter "Details" text) —
|
|
2212
|
+
* a consumer whose own trigger already carries a specific label (e.g. checkout's cf-details
|
|
2213
|
+
* button, "Finanzierungsdetails"/"Leasingdetails") can pass that same text through here. */
|
|
2214
|
+
titleOverride?: string;
|
|
2205
2215
|
}
|
|
2206
2216
|
|
|
2207
2217
|
/**
|
|
@@ -2245,6 +2255,7 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2245
2255
|
onAnnualMileageChange,
|
|
2246
2256
|
onClose,
|
|
2247
2257
|
initialShowBreakdown,
|
|
2258
|
+
skipInitialScroll,
|
|
2248
2259
|
ratingLabel,
|
|
2249
2260
|
available,
|
|
2250
2261
|
onModeChange,
|
|
@@ -2259,6 +2270,7 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2259
2270
|
onToggleAddServices,
|
|
2260
2271
|
leasingAvailable = true,
|
|
2261
2272
|
t,
|
|
2273
|
+
titleOverride,
|
|
2262
2274
|
}) => {
|
|
2263
2275
|
// same "UVP-Rate"/list-price footnote badge + popover as FinanceCalculator's own hero — this
|
|
2264
2276
|
// modal's mobile "Rate anpassen" sheet renders its own separate copy of that hero row, so it
|
|
@@ -2362,14 +2374,14 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2362
2374
|
React.useEffect(() => {
|
|
2363
2375
|
if (!open) return;
|
|
2364
2376
|
setShowBreakdown(!!initialShowBreakdown);
|
|
2365
|
-
if (!initialShowBreakdown) return;
|
|
2377
|
+
if (!initialShowBreakdown || skipInitialScroll) return;
|
|
2366
2378
|
const timer = window.setTimeout(() => {
|
|
2367
2379
|
if (mobileBreakdownRef.current?.offsetParent) scrollSheetToBreakdown();
|
|
2368
2380
|
else desktopBreakdownRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
2369
2381
|
}, 50);
|
|
2370
2382
|
return () => window.clearTimeout(timer);
|
|
2371
2383
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2372
|
-
}, [open, initialShowBreakdown]);
|
|
2384
|
+
}, [open, initialShowBreakdown, skipInitialScroll]);
|
|
2373
2385
|
// in-sheet details link: expanding scrolls down to the breakdown, collapsing back to the top.
|
|
2374
2386
|
const revealBreakdownRef = React.useRef(false);
|
|
2375
2387
|
React.useEffect(() => {
|
|
@@ -2379,6 +2391,24 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2379
2391
|
else animateSheetScroll(() => 0);
|
|
2380
2392
|
}, [showBreakdown, scrollSheetToBreakdown, animateSheetScroll]);
|
|
2381
2393
|
|
|
2394
|
+
// iOS Safari (26+, "Allow Website Tinting") paints its bottom toolbar area with the page's
|
|
2395
|
+
// <meta name="theme-color"> (site-wide blue #005CCB) — under the open white sheet that showed
|
|
2396
|
+
// as a solid blue band right below the CTA. While the sheet is open, theme-color is white;
|
|
2397
|
+
// on close the previous value(s) are restored. Other pages/states are untouched.
|
|
2398
|
+
React.useEffect(() => {
|
|
2399
|
+
if (!open || typeof document === 'undefined') return;
|
|
2400
|
+
const metas = Array.from(document.querySelectorAll<HTMLMetaElement>('meta[name="theme-color"]'));
|
|
2401
|
+
const prev = metas.map((m) => m.getAttribute('content'));
|
|
2402
|
+
metas.forEach((m) => m.setAttribute('content', '#FFFFFF'));
|
|
2403
|
+
return () => {
|
|
2404
|
+
metas.forEach((m, i) => {
|
|
2405
|
+
const v = prev[i];
|
|
2406
|
+
if (v == null) m.removeAttribute('content');
|
|
2407
|
+
else m.setAttribute('content', v);
|
|
2408
|
+
});
|
|
2409
|
+
};
|
|
2410
|
+
}, [open]);
|
|
2411
|
+
|
|
2382
2412
|
// mobile-only: swipe-down-to-dismiss on the grabber/header (the mockup's drag handle).
|
|
2383
2413
|
// The sheet follows the finger (imperative transform — no re-renders while dragging);
|
|
2384
2414
|
// released past 90px it slides out and closes, otherwise it springs back. The element
|
|
@@ -2419,7 +2449,7 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2419
2449
|
if (!open) return null;
|
|
2420
2450
|
const isLease = mode === 'leasing';
|
|
2421
2451
|
const isCash = mode === 'cash';
|
|
2422
|
-
const title = isLease ? t('autobahn:modal.leasingDetails') : t('autobahn:modal.financingDetails');
|
|
2452
|
+
const title = titleOverride || (isLease ? t('autobahn:modal.leasingDetails') : t('autobahn:modal.financingDetails'));
|
|
2423
2453
|
const mobileTitle = isCash
|
|
2424
2454
|
? t('autobahn:modal.sheetTitleCash')
|
|
2425
2455
|
: isLease
|
|
@@ -3955,14 +3985,21 @@ export const ReviewsTeaser: React.FunctionComponent<ReviewsTeaserProps> = ({ cou
|
|
|
3955
3985
|
};
|
|
3956
3986
|
|
|
3957
3987
|
export interface CustomerRatingsProps {
|
|
3958
|
-
/** the loaded reviews (REAL —
|
|
3988
|
+
/** the loaded reviews (REAL — Bewertung Welt via fe-landing's /angebot/customer-quotes). */
|
|
3959
3989
|
reviews: VdpReview[];
|
|
3960
3990
|
/**
|
|
3961
|
-
* Overall auto.de
|
|
3962
|
-
*
|
|
3963
|
-
*
|
|
3991
|
+
* Overall auto.de rating to display instead of the average of the few loaded
|
|
3992
|
+
* reviews (which skews to 5,0 — only 4-5 star quotes are loaded). The page passes
|
|
3993
|
+
* the real site-wide aggregate.
|
|
3964
3994
|
*/
|
|
3965
3995
|
average?: number;
|
|
3996
|
+
/**
|
|
3997
|
+
* Site-wide review count shown next to the average (Bewertung Welt `summary`). When set,
|
|
3998
|
+
* the header shows it instead of reviews.length and the expander reads "Weitere N …".
|
|
3999
|
+
*/
|
|
4000
|
+
total?: number;
|
|
4001
|
+
/** portals the average/total come from, e.g. "Google & Trustpilot" (default "Google"). */
|
|
4002
|
+
sourceLabel?: string;
|
|
3966
4003
|
/** i18n function (drilled from the page). */
|
|
3967
4004
|
t: TranslationFunction;
|
|
3968
4005
|
}
|
|
@@ -3975,10 +4012,11 @@ export interface CustomerRatingsProps {
|
|
|
3975
4012
|
* the WordPress json-quotes feed); the page loads them and passes them in. When no
|
|
3976
4013
|
* reviews load, the page renders nothing (no fabricated content).
|
|
3977
4014
|
*/
|
|
3978
|
-
export const CustomerRatings: React.FunctionComponent<CustomerRatingsProps> = ({ reviews, average, t }) => {
|
|
4015
|
+
export const CustomerRatings: React.FunctionComponent<CustomerRatingsProps> = ({ reviews, average, total, sourceLabel, t }) => {
|
|
3979
4016
|
const [showAll, setShowAll] = useState(false);
|
|
3980
4017
|
if (!reviews || !reviews.length) return null;
|
|
3981
4018
|
const count = reviews.length;
|
|
4019
|
+
const headerCount = total != null && total > 0 ? total : count;
|
|
3982
4020
|
const avg = average != null ? average : reviews.reduce((s, r) => s + (r.rating || 0), 0) / count;
|
|
3983
4021
|
const shown = showAll ? reviews : reviews.slice(0, 4);
|
|
3984
4022
|
return (
|
|
@@ -3994,7 +4032,7 @@ export const CustomerRatings: React.FunctionComponent<CustomerRatingsProps> = ({
|
|
|
3994
4032
|
<span>
|
|
3995
4033
|
<Stars value={avg} size={16} />
|
|
3996
4034
|
<span className="md-label-sm" style={{ display: 'block' }}>
|
|
3997
|
-
{t('autobahn:reviews.ratingCount', { count })} · via Google
|
|
4035
|
+
{t('autobahn:reviews.ratingCount', { count: headerCount })} · via {sourceLabel || 'Google'}
|
|
3998
4036
|
</span>
|
|
3999
4037
|
</span>
|
|
4000
4038
|
</div>
|
|
@@ -4047,7 +4085,12 @@ export const CustomerRatings: React.FunctionComponent<CustomerRatingsProps> = ({
|
|
|
4047
4085
|
</div>
|
|
4048
4086
|
{reviews.length > 4 && (
|
|
4049
4087
|
<button className="mbtn mbtn--text" style={{ marginTop: 4 }} onClick={() => setShowAll((a) => !a)}>
|
|
4050
|
-
{showAll
|
|
4088
|
+
{showAll
|
|
4089
|
+
? t('autobahn:ratings.showLess')
|
|
4090
|
+
// with a site-wide total in the header, "Alle N" would contradict it — only the loaded ones expand
|
|
4091
|
+
: headerCount !== count
|
|
4092
|
+
? t('autobahn:ratings.showMoreLoaded', { count: count - 4 })
|
|
4093
|
+
: t('autobahn:ratings.showMore', { count })}
|
|
4051
4094
|
<Icon name={showAll ? 'chevron-up' : 'chevron-down'} size={16} />
|
|
4052
4095
|
</button>
|
|
4053
4096
|
)}
|
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
|
},
|