@bytebrand/fe-ui-core-autobahn 1.0.190 → 1.0.192
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 +395 -388
- 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 +43 -11
- package/locales/en/autobahn.json +41 -9
- package/package.json +2 -2
- package/theme/md3.css +15690 -11573
- 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
package/chrome/TopBar.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { TranslationFunction } from '../types';
|
|
|
3
3
|
|
|
4
4
|
import { Button, Icon, IconButton } from '../ui';
|
|
5
5
|
import logoUrl from '../assets/autode-logo.svg';
|
|
6
|
+
import AccountMenuIcon, { AccountMenuIconName } from './AccountMenuIcon';
|
|
6
7
|
|
|
7
8
|
/** Where the logo navigates on click. '/' is NOT an SPA route — traefik serves the WordPress
|
|
8
9
|
* homepage there (generate-routes.py: wp-home at higher priority) — so the logo must be a FULL
|
|
@@ -39,6 +40,10 @@ const R_MY_ORDERS = '/account/my-orders';
|
|
|
39
40
|
const R_DASHBOARD = '/account/dashboard';
|
|
40
41
|
const R_IMAGE_SETTINGS = '/account/image-settings';
|
|
41
42
|
const R_KONTAKT = '/account/kontakt';
|
|
43
|
+
const R_COMPARE = '/compare';
|
|
44
|
+
|
|
45
|
+
/** lib Icon strokes are in lucide's 24-unit viewBox: drawn at 22px this is the Konto menu's 1.8px. */
|
|
46
|
+
const ACCT_ICON_STROKE = (1.8 * 24) / 22;
|
|
42
47
|
|
|
43
48
|
/** Languages offered in the account menu (legacy supports de/en/ru). Labels are proper nouns
|
|
44
49
|
* (endonyms) and stay untranslated. */
|
|
@@ -83,18 +88,28 @@ export interface TopBarProps {
|
|
|
83
88
|
variant?: TopBarVariant;
|
|
84
89
|
/** real auth state (authStore.isAuthorized) — guest vs profile menu. */
|
|
85
90
|
isAuthorized?: boolean;
|
|
86
|
-
/**
|
|
91
|
+
/** name in the authed menu's head (the profile's first + last name, else authStore.userEmail). */
|
|
87
92
|
userLabel?: string;
|
|
88
93
|
/** Merkliste count (favoriteStore.favoritesIDs.length) — badge on the heart + menu row. */
|
|
89
94
|
favoritesCount?: number;
|
|
90
95
|
/** unread Suchaufträge count — badge on the bell. Defaults to 0 (no badge). */
|
|
91
96
|
notificationCount?: number;
|
|
92
|
-
/** placed-orders count (profileStore.totalOrdered) —
|
|
97
|
+
/** placed-orders count (profileStore.totalOrdered) — the "Meine Bestellung" row shows only above 0. */
|
|
93
98
|
ordersCount?: number;
|
|
99
|
+
/** saved searches (filterStore.savedSearchStrings.length) — badge on the "Gespeicherte Suchen" row. */
|
|
100
|
+
savedSearchesCount?: number;
|
|
101
|
+
/** cars picked for comparison (compareStore.vehiclesIDsToCompare.length) — badge on "Fahrzeuge vergleichen". */
|
|
102
|
+
compareCount?: number;
|
|
94
103
|
/** active language tag (appStore.language) — ticks the current language row. */
|
|
95
104
|
language?: string;
|
|
96
|
-
/** dealer
|
|
105
|
+
/** any dealer account (authStore.isDealer: main, admin, employee, accountant) — Meine Fahrzeuge. */
|
|
106
|
+
isDealer?: boolean;
|
|
107
|
+
/** dealer-main account (authStore.isDealerMain) — Bildeinstellungen and the dealer switch. */
|
|
97
108
|
isDealerMain?: boolean;
|
|
109
|
+
/** dealer admin (authStore.isDealerAdmin) — Bildeinstellungen, like isDealerMain. */
|
|
110
|
+
isDealerAdmin?: boolean;
|
|
111
|
+
/** dealer employee (authStore.isEmployee) — the "Meine Händler" switch, like isDealerMain. */
|
|
112
|
+
isEmployee?: boolean;
|
|
98
113
|
/** attached dealerships (profileStore.dealers: { dealer: {id, email}, isActive }[]). */
|
|
99
114
|
dealers?: ReadonlyArray<{ dealer: { id: string; email: string }; isActive: boolean }>;
|
|
100
115
|
/** switch the active dealership (App.setMainDealer → profileStore.switchDealer). */
|
|
@@ -138,8 +153,13 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
138
153
|
favoritesCount = 0,
|
|
139
154
|
notificationCount = 0,
|
|
140
155
|
ordersCount = 0,
|
|
156
|
+
savedSearchesCount = 0,
|
|
157
|
+
compareCount = 0,
|
|
141
158
|
language = 'de',
|
|
159
|
+
isDealer = false,
|
|
142
160
|
isDealerMain = false,
|
|
161
|
+
isDealerAdmin = false,
|
|
162
|
+
isEmployee = false,
|
|
143
163
|
dealers = [],
|
|
144
164
|
onDealerSelect,
|
|
145
165
|
onSignOut,
|
|
@@ -150,8 +170,14 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
150
170
|
}) => {
|
|
151
171
|
const [menu, setMenu] = useState(false); // mobile hamburger dropdown
|
|
152
172
|
const [account, setAccount] = useState(false); // account popover
|
|
173
|
+
const [dealersOpen, setDealersOpen] = useState(false); // Konto menu: "Meine Händler" expanded
|
|
153
174
|
const [hidden, setHidden] = useState(false); // autoHideOnScroll: header slid out of view
|
|
154
175
|
|
|
176
|
+
// the dealer list opens collapsed every time the Konto menu opens
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
if (!account) setDealersOpen(false);
|
|
179
|
+
}, [account]);
|
|
180
|
+
|
|
155
181
|
// scroll-direction tracking for autoHideOnScroll — down hides, up shows, and it never hides
|
|
156
182
|
// near the very top (HIDE_AT) so the header doesn't disappear on the first tiny scroll nudge.
|
|
157
183
|
const lastScrollY = useRef(0);
|
|
@@ -206,280 +232,129 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
206
232
|
</nav>
|
|
207
233
|
);
|
|
208
234
|
|
|
209
|
-
/** one
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
margin: opts && opts.primary ? '0 0 6px' : 0,
|
|
227
|
-
cursor: 'pointer',
|
|
228
|
-
font: 'inherit',
|
|
229
|
-
fontWeight: opts && opts.primary ? 700 : 500,
|
|
230
|
-
justifyContent: opts && opts.primary ? 'center' : 'flex-start',
|
|
231
|
-
textAlign: 'left',
|
|
232
|
-
}}
|
|
233
|
-
>
|
|
234
|
-
{opts && opts.icon && <Icon name={opts.icon} size={17} style={{ flex: 'none' }} />}
|
|
235
|
-
<span style={{ flex: 1 }}>{label}</span>
|
|
236
|
-
{opts && typeof opts.badge === 'number' && (
|
|
237
|
-
<span className="md-label-sm" style={{ fontWeight: 700 }}>{opts.badge}</span>
|
|
235
|
+
/** one Konto-menu row (Figma "acct-row"): 22px icon, label, count badge when above 0. `icon` is a
|
|
236
|
+
* menu glyph; `lucide` is a lib Icon for the guest rows Figma doesn't draw. `checked` (dealer rows)
|
|
237
|
+
* marks the active choice with the same check as the language rows; `nested` rows sit under an
|
|
238
|
+
* expanded row, their label in line with its label. */
|
|
239
|
+
const acctRow = (
|
|
240
|
+
key: string,
|
|
241
|
+
label: string,
|
|
242
|
+
onClick: () => void,
|
|
243
|
+
opts: { icon?: AccountMenuIconName; lucide?: string; badge?: number; checked?: boolean; nested?: boolean } = {},
|
|
244
|
+
): JSX.Element => (
|
|
245
|
+
<button key={key} type="button" className={opts.nested ? 'acct-row acct-row--nested' : 'acct-row'} onClick={onClick} aria-pressed={opts.checked}>
|
|
246
|
+
{opts.icon && <AccountMenuIcon name={opts.icon} />}
|
|
247
|
+
{opts.lucide && <Icon name={opts.lucide} size={22} stroke={ACCT_ICON_STROKE} cls="acct-icon" />}
|
|
248
|
+
<span className="acct-label">{label}</span>
|
|
249
|
+
{!!opts.badge && opts.badge > 0 && <span className="acct-badge">{opts.badge}</span>}
|
|
250
|
+
{opts.checked && (
|
|
251
|
+
<span className="acct-check"><Icon name="check" size={13} color="#fff" stroke={3} /></span>
|
|
238
252
|
)}
|
|
239
253
|
</button>
|
|
240
254
|
);
|
|
241
255
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
gap: 12,
|
|
263
|
-
width: '100%',
|
|
264
|
-
padding: '13px 4px',
|
|
265
|
-
border: 0,
|
|
266
|
-
background: 'transparent',
|
|
267
|
-
color: 'var(--md-on-surface)',
|
|
268
|
-
cursor: 'pointer',
|
|
269
|
-
font: 'inherit',
|
|
270
|
-
fontWeight: 500,
|
|
271
|
-
textAlign: 'left',
|
|
272
|
-
}}
|
|
273
|
-
>
|
|
274
|
-
{opts && opts.icon && <Icon name={opts.icon} size={19} style={{ flex: 'none', color: 'var(--md-on-surface-variant)' }} />}
|
|
275
|
-
<span style={{ flex: 1, fontSize: 15 }}>{label}</span>
|
|
276
|
-
{opts && typeof opts.badge === 'number' && opts.badge > 0 && (
|
|
277
|
-
<span className="md-label-sm" style={{ fontWeight: 700 }}>{opts.badge}</span>
|
|
278
|
-
)}
|
|
279
|
-
<Icon name="chevron-right" size={18} style={{ flex: 'none', color: 'var(--md-on-surface-variant)' }} />
|
|
280
|
-
</button>
|
|
256
|
+
/** language rows — not in the Figma menu, kept for phones: the header's DE/EN switch is hidden
|
|
257
|
+
* ≤600px, so this group (show-mobile) is the only language switch there. */
|
|
258
|
+
const renderLanguageRows = (): JSX.Element => (
|
|
259
|
+
<div className="acct-list show-mobile">
|
|
260
|
+
{LANGS.map(([code, label]) => (
|
|
261
|
+
<button
|
|
262
|
+
key={`lang-${code}`}
|
|
263
|
+
type="button"
|
|
264
|
+
className="acct-row"
|
|
265
|
+
aria-pressed={language === code}
|
|
266
|
+
onClick={() => { setAccount(false); if (onLangSelect) onLangSelect(code); }}
|
|
267
|
+
>
|
|
268
|
+
<span className="acct-flag"><Flag code={code} /></span>
|
|
269
|
+
<span className="acct-label">{label}</span>
|
|
270
|
+
{language === code && (
|
|
271
|
+
<span className="acct-check"><Icon name="check" size={13} color="#fff" stroke={3} /></span>
|
|
272
|
+
)}
|
|
273
|
+
</button>
|
|
274
|
+
))}
|
|
275
|
+
</div>
|
|
281
276
|
);
|
|
282
277
|
|
|
283
|
-
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
onClick={() => { setAccount(false); if (onLangSelect) onLangSelect(code); }}
|
|
293
|
-
style={{
|
|
294
|
-
display: 'flex',
|
|
295
|
-
alignItems: 'center',
|
|
296
|
-
gap: 12,
|
|
297
|
-
width: '100%',
|
|
298
|
-
padding: '10px 4px',
|
|
299
|
-
border: 0,
|
|
300
|
-
background: 'transparent',
|
|
301
|
-
cursor: 'pointer',
|
|
302
|
-
font: 'inherit',
|
|
303
|
-
textAlign: 'left',
|
|
304
|
-
}}
|
|
305
|
-
>
|
|
306
|
-
<Flag code={code} />
|
|
307
|
-
<span style={{ flex: 1, fontSize: 15, color: 'var(--md-on-surface)' }}>{label}</span>
|
|
308
|
-
{active && (
|
|
309
|
-
<span
|
|
310
|
-
style={{
|
|
311
|
-
width: 20, height: 20, borderRadius: '50%', background: 'var(--md-primary)',
|
|
312
|
-
display: 'flex', alignItems: 'center', justifyContent: 'center', flex: 'none',
|
|
313
|
-
}}
|
|
314
|
-
>
|
|
315
|
-
<Icon name="check" size={13} color="#fff" stroke={3} />
|
|
316
|
-
</span>
|
|
317
|
-
)}
|
|
318
|
-
</button>
|
|
319
|
-
);
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
/** Mobile-only "Account Layer" — a full-width sheet under the header (Figma: "03 | Account
|
|
323
|
-
* Layer"), replacing the desktop popover's small 264px card on mobile widths. Shown/hidden
|
|
324
|
-
* purely via the `show-mobile`/`hide-mobile` CSS classes (this project's existing convention —
|
|
325
|
-
* see the hamburger button/topbar-menu above), not JS width checks. */
|
|
326
|
-
const renderMobileAccountLayer = (): JSX.Element => (
|
|
327
|
-
<div className="amenu-mobile show-mobile mcard" style={{ flexDirection: 'column' }}>
|
|
328
|
-
<div style={{ padding: '20px 20px 8px', textAlign: isAuthorized ? 'left' : 'center' }}>
|
|
278
|
+
/** Konto menu (Figma "Kontomenü (geöffnet)", 64243:14205 desktop / 64243:14299 mobile — the same
|
|
279
|
+
* 312px dropdown at every width): the name, then groups split by lines — Figma's rows for every
|
|
280
|
+
* user, Profil, then the role rows (Meine Fahrzeuge for every dealer account, the dealer switch
|
|
281
|
+
* for employees, Bildeinstellungen for dealers/admins). Rows Figma doesn't draw use the same style. */
|
|
282
|
+
const isDealerOrAdmin = isDealerMain || isDealerAdmin;
|
|
283
|
+
const showDealers = (isDealerMain || isEmployee) && dealers.length > 1;
|
|
284
|
+
const renderAccountMenu = (): JSX.Element => (
|
|
285
|
+
<div className="acct-menu">
|
|
286
|
+
<div className="acct-scroll">
|
|
329
287
|
{isAuthorized ? (
|
|
330
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
|
331
|
-
<span
|
|
332
|
-
style={{
|
|
333
|
-
width: 44, height: 44, borderRadius: '50%', flex: 'none',
|
|
334
|
-
background: 'color-mix(in srgb, var(--md-primary) 15%, transparent)',
|
|
335
|
-
color: 'var(--md-primary)', display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
336
|
-
fontWeight: 700, fontSize: 16,
|
|
337
|
-
}}
|
|
338
|
-
>
|
|
339
|
-
{avatarInitial}
|
|
340
|
-
</span>
|
|
341
|
-
<div style={{ flex: 1, minWidth: 0 }}>
|
|
342
|
-
<div className="md-title-sm" style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
|
343
|
-
{userLabel}
|
|
344
|
-
</div>
|
|
345
|
-
<a
|
|
346
|
-
onClick={() => goRoute(R_SETTINGS)}
|
|
347
|
-
className="md-label"
|
|
348
|
-
style={{ color: 'var(--md-primary)', cursor: 'pointer', fontWeight: 600 }}
|
|
349
|
-
>
|
|
350
|
-
{t('autobahn:chrome.myProfile')} ›
|
|
351
|
-
</a>
|
|
352
|
-
</div>
|
|
353
|
-
</div>
|
|
354
|
-
) : (
|
|
355
288
|
<>
|
|
356
|
-
<
|
|
357
|
-
|
|
358
|
-
width: 44, height: 44, borderRadius: '50%', margin: '0 auto 14px',
|
|
359
|
-
background: 'var(--md-outline-variant)', color: 'var(--md-on-surface-variant)',
|
|
360
|
-
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
361
|
-
}}
|
|
362
|
-
>
|
|
363
|
-
<Icon name="user" size={22} />
|
|
364
|
-
</span>
|
|
365
|
-
<div className="md-headline-sm" style={{ fontWeight: 700, marginBottom: 6 }}>
|
|
366
|
-
{t('autobahn:chrome.welcome')}
|
|
289
|
+
<div className="acct-head">
|
|
290
|
+
<span className="acct-name">{userLabel || t('autobahn:chrome.myAccount')}</span>
|
|
367
291
|
</div>
|
|
368
|
-
<div className="
|
|
369
|
-
{t('autobahn:chrome.
|
|
292
|
+
<div className="acct-list">
|
|
293
|
+
{acctRow('overview', t('autobahn:chrome.acct.overview'), () => goRoute(R_DASHBOARD), { icon: 'layout-grid' })}
|
|
294
|
+
{ordersCount > 0 &&
|
|
295
|
+
acctRow('myOrder', t('autobahn:chrome.acct.myOrder'), () => goRoute(R_MY_ORDERS), { icon: 'car-front' })}
|
|
296
|
+
{acctRow('savedSearches', t('autobahn:chrome.acct.savedSearches'), () => goRoute(R_SAVED_SEARCHES), { icon: 'bookmark', badge: savedSearchesCount })}
|
|
297
|
+
{acctRow('favorites', t('autobahn:chrome.acct.favorites'), () => goRoute(R_FAVOURITES), { icon: 'star', badge: favoritesCount })}
|
|
298
|
+
{acctRow('compare', t('autobahn:chrome.acct.compare'), () => goRoute(R_COMPARE), { icon: 'scale', badge: compareCount })}
|
|
299
|
+
</div>
|
|
300
|
+
<div className="acct-list">
|
|
301
|
+
{acctRow('profile', t('autobahn:chrome.acct.profile'), () => goRoute(R_SETTINGS), { icon: 'user' })}
|
|
302
|
+
</div>
|
|
303
|
+
{(isDealer || showDealers || isDealerOrAdmin) && (
|
|
304
|
+
<div className="acct-list">
|
|
305
|
+
{isDealer &&
|
|
306
|
+
acctRow('myVehicles', t('autobahn:chrome.myVehicles'), () => goRoute(R_MY_VEHICLES), { lucide: 'car' })}
|
|
307
|
+
{/* ADV-271 (comment of 01.11.2026): one "Meine Händler" row; a click expands the
|
|
308
|
+
dealers to pick from (the active one checked) and collapses them again */}
|
|
309
|
+
{showDealers && (
|
|
310
|
+
<>
|
|
311
|
+
<button
|
|
312
|
+
type="button"
|
|
313
|
+
className="acct-row"
|
|
314
|
+
aria-expanded={dealersOpen}
|
|
315
|
+
onClick={() => setDealersOpen((open) => !open)}
|
|
316
|
+
>
|
|
317
|
+
<AccountMenuIcon name="store" />
|
|
318
|
+
<span className="acct-label">{t('autobahn:chrome.myDealers')} ({dealers.length})</span>
|
|
319
|
+
<Icon name="chevron-down" size={20} cls={dealersOpen ? 'acct-chevron acct-chevron--open' : 'acct-chevron'} />
|
|
320
|
+
</button>
|
|
321
|
+
{dealersOpen &&
|
|
322
|
+
dealers.map((d) =>
|
|
323
|
+
acctRow(`dealer-${d.dealer.id}`, d.dealer.email, () => {
|
|
324
|
+
setAccount(false);
|
|
325
|
+
if (!d.isActive && onDealerSelect) onDealerSelect(d.dealer.id);
|
|
326
|
+
}, { checked: d.isActive, nested: true }),
|
|
327
|
+
)}
|
|
328
|
+
</>
|
|
329
|
+
)}
|
|
330
|
+
{isDealerOrAdmin &&
|
|
331
|
+
acctRow('imageSettings', t('autobahn:chrome.imageSettings'), () => goRoute(R_IMAGE_SETTINGS), { icon: 'settings' })}
|
|
332
|
+
</div>
|
|
333
|
+
)}
|
|
334
|
+
<div className="acct-list">
|
|
335
|
+
{acctRow('support', t('autobahn:chrome.acct.support'), () => goRoute(R_KONTAKT), { icon: 'help-circle' })}
|
|
336
|
+
</div>
|
|
337
|
+
{renderLanguageRows()}
|
|
338
|
+
<div className="acct-list">
|
|
339
|
+
{acctRow('signOut', t('autobahn:chrome.signOut'), () => { setAccount(false); if (onSignOut) onSignOut(); }, { icon: 'log-out' })}
|
|
370
340
|
</div>
|
|
371
|
-
</>
|
|
372
|
-
)}
|
|
373
|
-
</div>
|
|
374
|
-
|
|
375
|
-
<div style={{ padding: '4px 20px 8px' }}>
|
|
376
|
-
{isAuthorized ? (
|
|
377
|
-
<>
|
|
378
|
-
{!isDealerMain &&
|
|
379
|
-
mrow('m-dashboard', t('autobahn:chrome.dashboard'), () => goRoute(R_DASHBOARD), { icon: 'layout-grid' })}
|
|
380
|
-
{mrow('m-vehicles', t('autobahn:chrome.myVehicles'), () => goRoute(R_MY_VEHICLES), { icon: 'car' })}
|
|
381
|
-
{mrow('m-searches', t('autobahn:chrome.savedSearches'), () => goRoute(R_SAVED_SEARCHES), { icon: 'bell' })}
|
|
382
|
-
{mrow('m-favorites', t('autobahn:chrome.favorites'), () => goRoute(R_FAVOURITES), { icon: 'heart', badge: favoritesCount })}
|
|
383
|
-
{mrow('m-settings', t('autobahn:chrome.settings'), () => goRoute(R_SETTINGS), { icon: 'settings' })}
|
|
384
|
-
{mrow('m-help', t('autobahn:chrome.helpContact'), () => goRoute(R_KONTAKT), { icon: 'help-circle' })}
|
|
385
|
-
{isDealerMain && mrow('m-dealer', t('autobahn:chrome.dealerDashboard'), () => goRoute(R_DASHBOARD), { icon: 'store' })}
|
|
386
|
-
{mrow('m-signout', t('autobahn:chrome.signOut'), () => { setAccount(false); if (onSignOut) onSignOut(); }, { icon: 'log-out' })}
|
|
387
341
|
</>
|
|
388
342
|
) : (
|
|
389
343
|
<>
|
|
390
|
-
<
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
{
|
|
344
|
+
<div className="acct-list">
|
|
345
|
+
<div className="acct-cta">
|
|
346
|
+
<Button variant="filled" block onClick={() => goRoute(R_SIGN_IN)}>{t('autobahn:chrome.signIn')}</Button>
|
|
347
|
+
</div>
|
|
348
|
+
{acctRow('register', t('autobahn:chrome.register'), () => goRoute(R_SIGN_UP), { lucide: 'user-plus' })}
|
|
349
|
+
{acctRow('dealerSignUp', t('autobahn:chrome.dealerSignUp'), () => goRoute(R_DEALER), { lucide: 'store' })}
|
|
350
|
+
</div>
|
|
351
|
+
<div className="acct-list">
|
|
352
|
+
{acctRow('favorites', t('autobahn:chrome.acct.favorites'), () => goRoute(R_FAVOURITES), { icon: 'star', badge: favoritesCount })}
|
|
353
|
+
</div>
|
|
354
|
+
{renderLanguageRows()}
|
|
401
355
|
</>
|
|
402
356
|
)}
|
|
403
357
|
</div>
|
|
404
|
-
|
|
405
|
-
{divider('m-d1')}
|
|
406
|
-
|
|
407
|
-
<div style={{ padding: '8px 20px 20px' }}>
|
|
408
|
-
<div className="md-label-sm" style={{ color: 'var(--md-on-surface-variant)', padding: '4px 4px 6px' }}>
|
|
409
|
-
{t('autobahn:chrome.language')}
|
|
410
|
-
</div>
|
|
411
|
-
{LANGS.map(([code, label]) => mLangRow(code, label))}
|
|
412
|
-
</div>
|
|
413
|
-
</div>
|
|
414
|
-
);
|
|
415
|
-
|
|
416
|
-
const renderAccountMenu = (): JSX.Element => (
|
|
417
|
-
<div
|
|
418
|
-
className="amenu mcard hide-mobile"
|
|
419
|
-
style={{
|
|
420
|
-
position: 'absolute',
|
|
421
|
-
top: 'calc(100% + 8px)',
|
|
422
|
-
right: 0,
|
|
423
|
-
width: 264,
|
|
424
|
-
padding: 8,
|
|
425
|
-
zIndex: 60,
|
|
426
|
-
boxShadow: 'var(--md-elev-2)',
|
|
427
|
-
}}
|
|
428
|
-
>
|
|
429
|
-
{isAuthorized ? (
|
|
430
|
-
<>
|
|
431
|
-
<div className="md-label-sm" style={{ padding: '6px 14px 8px', color: 'var(--md-on-surface-variant)' }}>
|
|
432
|
-
{userLabel || t('autobahn:chrome.myAccount')}
|
|
433
|
-
</div>
|
|
434
|
-
{/* dealer-main users get the same route via the dedicated "Händler-Dashboard" row below */}
|
|
435
|
-
{!isDealerMain &&
|
|
436
|
-
row('autobahn:chrome.dashboard', t('autobahn:chrome.dashboard'), () => goRoute(R_DASHBOARD), { icon: 'layout-grid' })}
|
|
437
|
-
{row('autobahn:chrome.myVehicles', t('autobahn:chrome.myVehicles'), () => goRoute(R_MY_VEHICLES), { icon: 'car' })}
|
|
438
|
-
{ordersCount > 0 &&
|
|
439
|
-
row('autobahn:chrome.myOrders', t('autobahn:chrome.myOrders'), () => goRoute(R_MY_ORDERS), { icon: 'package', badge: ordersCount })}
|
|
440
|
-
{row('autobahn:chrome.savedSearches', t('autobahn:chrome.savedSearches'), () => goRoute(R_SAVED_SEARCHES), { icon: 'bell' })}
|
|
441
|
-
{row('autobahn:chrome.favorites', t('autobahn:chrome.favorites'), () => goRoute(R_FAVOURITES), { icon: 'heart', badge: favoritesCount })}
|
|
442
|
-
{row('autobahn:chrome.settings', t('autobahn:chrome.settings'), () => goRoute(R_SETTINGS), { icon: 'settings' })}
|
|
443
|
-
{row('autobahn:chrome.helpContact', t('autobahn:chrome.helpContact'), () => goRoute(R_KONTAKT), { icon: 'help-circle' })}
|
|
444
|
-
{isDealerMain && (
|
|
445
|
-
<>
|
|
446
|
-
{divider('d-dealer')}
|
|
447
|
-
{row('autobahn:chrome.dealerDashboard', t('autobahn:chrome.dealerDashboard'), () => goRoute(R_DASHBOARD), { icon: 'store' })}
|
|
448
|
-
{row('autobahn:chrome.imageSettings', t('autobahn:chrome.imageSettings'), () => goRoute(R_IMAGE_SETTINGS), { icon: 'image' })}
|
|
449
|
-
</>
|
|
450
|
-
)}
|
|
451
|
-
{dealers.length > 1 && (
|
|
452
|
-
<>
|
|
453
|
-
<div className="md-label-sm" style={{ padding: '8px 14px 4px', color: 'var(--md-on-surface-variant)' }}>
|
|
454
|
-
{t('autobahn:chrome.myDealers')} ({dealers.length})
|
|
455
|
-
</div>
|
|
456
|
-
{dealers.map((d) =>
|
|
457
|
-
row(`dealer-${d.dealer.id}`, d.dealer.email, () => {
|
|
458
|
-
setAccount(false);
|
|
459
|
-
if (!d.isActive && onDealerSelect) onDealerSelect(d.dealer.id);
|
|
460
|
-
}, { icon: d.isActive ? 'check' : 'store' }),
|
|
461
|
-
)}
|
|
462
|
-
</>
|
|
463
|
-
)}
|
|
464
|
-
{divider('d1')}
|
|
465
|
-
{row('autobahn:chrome.signOut', t('autobahn:chrome.signOut'), () => { setAccount(false); if (onSignOut) onSignOut(); }, { icon: 'log-out' })}
|
|
466
|
-
</>
|
|
467
|
-
) : (
|
|
468
|
-
<>
|
|
469
|
-
{row('autobahn:chrome.signIn', t('autobahn:chrome.signIn'), () => goRoute(R_SIGN_IN), { primary: true })}
|
|
470
|
-
{row('autobahn:chrome.register', t('autobahn:chrome.register'), () => goRoute(R_SIGN_UP), { icon: 'user-plus' })}
|
|
471
|
-
{row('autobahn:chrome.dealerSignUp', t('autobahn:chrome.dealerSignUp'), () => goRoute(R_DEALER), { icon: 'store' })}
|
|
472
|
-
{divider('d1')}
|
|
473
|
-
{row('autobahn:chrome.favorites', t('autobahn:chrome.favorites'), () => goRoute(R_FAVOURITES), { icon: 'heart', badge: favoritesCount })}
|
|
474
|
-
</>
|
|
475
|
-
)}
|
|
476
|
-
{divider('d2')}
|
|
477
|
-
<div className="md-label-sm" style={{ padding: '4px 14px', color: 'var(--md-on-surface-variant)' }}>{t('autobahn:chrome.language')}</div>
|
|
478
|
-
{LANGS.map(([code, label]) =>
|
|
479
|
-
row(`lang-${code}`, label, () => { setAccount(false); if (onLangSelect) onLangSelect(code); }, {
|
|
480
|
-
icon: language === code ? 'check' : 'globe',
|
|
481
|
-
}),
|
|
482
|
-
)}
|
|
483
358
|
</div>
|
|
484
359
|
);
|
|
485
360
|
|
|
@@ -569,11 +444,11 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
569
444
|
</div>
|
|
570
445
|
)}
|
|
571
446
|
|
|
572
|
-
{/* Konto trigger +
|
|
573
|
-
|
|
447
|
+
{/* Konto trigger + menu — visible at EVERY width: this menu is the only place sign-out /
|
|
448
|
+
settings / dealer switching exist, so it must never be display:none'd (the
|
|
574
449
|
pre-cutover hide-tablet left 601–980px with no logout at all). Desktop keeps the
|
|
575
450
|
tonal "Konto" pill; ≤600px it collapses to a plain icon (topbar-account-btn CSS) and
|
|
576
|
-
opens the
|
|
451
|
+
opens the same 312px menu (Figma draws the phone one the same). */}
|
|
577
452
|
<span style={{ position: 'relative', display: 'inline-flex' }}>
|
|
578
453
|
<button
|
|
579
454
|
className="mbtn mbtn--tonal mbtn--sm topbar-account-btn"
|
|
@@ -589,8 +464,6 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
589
464
|
</div>
|
|
590
465
|
</div>
|
|
591
466
|
|
|
592
|
-
{account && renderMobileAccountLayer()}
|
|
593
|
-
|
|
594
467
|
{/* click-away backdrop for the account popover */}
|
|
595
468
|
{account && (
|
|
596
469
|
<div
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import useModal from './useModal';
|
|
3
3
|
import { updateCookieList } from '../../utils/CommonUtils';
|
|
4
|
+
import { OPEN_COOKIE_SETTINGS_EVENT } from '../../utils/cookieConsent';
|
|
4
5
|
import Modal from './Modal';
|
|
6
|
+
import { TranslationFunction } from '../../types';
|
|
5
7
|
|
|
6
8
|
export interface ICookieModal {
|
|
7
9
|
handleSentryInit?: () => void;
|
|
10
|
+
/** the host's `t` with the `autobahn` namespace (`cookieModal.*`); without it the dialog is German */
|
|
11
|
+
t?: TranslationFunction;
|
|
8
12
|
}
|
|
9
13
|
|
|
10
|
-
const CookieModal = ({ handleSentryInit }: ICookieModal) => {
|
|
11
|
-
const { isVisible, toggleModal } = useModal();
|
|
14
|
+
const CookieModal = ({ handleSentryInit = () => {}, t }: ICookieModal) => {
|
|
15
|
+
const { isVisible, toggleModal, openModal } = useModal();
|
|
12
16
|
const [modal, setModal] = useState('');
|
|
13
17
|
|
|
14
18
|
useEffect(
|
|
@@ -22,6 +26,19 @@ const CookieModal = ({ handleSentryInit }: ICookieModal) => {
|
|
|
22
26
|
[]
|
|
23
27
|
);
|
|
24
28
|
|
|
29
|
+
// ADV-268: "Cookie-Einstellungen ändern" (account page) reopens the settings dialog
|
|
30
|
+
useEffect(
|
|
31
|
+
() => {
|
|
32
|
+
const onOpenSettings = () => {
|
|
33
|
+
setModal('MANAGE_COOKIE_MODAL');
|
|
34
|
+
openModal();
|
|
35
|
+
};
|
|
36
|
+
window.addEventListener(OPEN_COOKIE_SETTINGS_EVENT, onOpenSettings);
|
|
37
|
+
return () => window.removeEventListener(OPEN_COOKIE_SETTINGS_EVENT, onOpenSettings);
|
|
38
|
+
},
|
|
39
|
+
[]
|
|
40
|
+
);
|
|
41
|
+
|
|
25
42
|
useEffect(
|
|
26
43
|
() => {
|
|
27
44
|
if (!isVisible) return undefined;
|
|
@@ -45,6 +62,7 @@ const CookieModal = ({ handleSentryInit }: ICookieModal) => {
|
|
|
45
62
|
? <Modal
|
|
46
63
|
isVisible={isVisible}
|
|
47
64
|
handleSentryInit={handleSentryInit}
|
|
65
|
+
t={t}
|
|
48
66
|
toggleModal={toggleModal}
|
|
49
67
|
name={modal}
|
|
50
68
|
modalProps={modalProps}
|
|
@@ -52,8 +70,4 @@ const CookieModal = ({ handleSentryInit }: ICookieModal) => {
|
|
|
52
70
|
: <></>;
|
|
53
71
|
};
|
|
54
72
|
|
|
55
|
-
CookieModal.defaultProps = {
|
|
56
|
-
handleSentryInit: () => {}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
73
|
export default CookieModal;
|
|
@@ -16,6 +16,7 @@ import * as React from 'react';
|
|
|
16
16
|
import * as ReactDOM from 'react-dom';
|
|
17
17
|
|
|
18
18
|
import ModalsConfig from './ModalsConfig';
|
|
19
|
+
import { TranslationFunction } from '../../types';
|
|
19
20
|
import styles from './Modal.styl';
|
|
20
21
|
|
|
21
22
|
interface IBasicModal {
|
|
@@ -24,6 +25,7 @@ interface IBasicModal {
|
|
|
24
25
|
handleSentryInit?: () => void;
|
|
25
26
|
name: string;
|
|
26
27
|
modalProps?: any;
|
|
28
|
+
t?: TranslationFunction;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const OVERLAY: React.CSSProperties = {
|
|
@@ -40,16 +42,17 @@ const SURFACE: React.CSSProperties = {
|
|
|
40
42
|
maxWidth: 640, width: '100%', maxHeight: '92vh', overflowY: 'auto'
|
|
41
43
|
};
|
|
42
44
|
|
|
43
|
-
const BasicModal = ({ isVisible, toggleModal, name, modalProps, handleSentryInit }: IBasicModal) => {
|
|
45
|
+
const BasicModal = ({ isVisible, toggleModal, name, modalProps, handleSentryInit, t }: IBasicModal) => {
|
|
44
46
|
if (!isVisible || typeof document === 'undefined') return null;
|
|
47
|
+
const label = t ? t('autobahn:cookieModal.dialogLabel') : '';
|
|
45
48
|
return ReactDOM.createPortal(
|
|
46
49
|
// wrapped in .md3: autobahn.css scopes every token/utility class (incl.
|
|
47
50
|
// .mbtn used by the modal buttons) under `.md3` and intentionally does
|
|
48
51
|
// nothing outside it — a bare document.body portal loses the theme.
|
|
49
52
|
<div className='md3'>
|
|
50
|
-
<div className={styles.overlay} style={OVERLAY} role='dialog' aria-modal='true' aria-label='Cookie-Einstellungen'>
|
|
53
|
+
<div className={styles.overlay} style={OVERLAY} role='dialog' aria-modal='true' aria-label={label && !label.endsWith('cookieModal.dialogLabel') ? label : 'Cookie-Einstellungen'}>
|
|
51
54
|
<div className={styles.surface} style={SURFACE}>
|
|
52
|
-
{ModalsConfig[name] && ModalsConfig[name]({ ...modalProps, toggleModal, handleSentryInit })}
|
|
55
|
+
{ModalsConfig[name] && ModalsConfig[name]({ ...modalProps, toggleModal, handleSentryInit, t })}
|
|
53
56
|
</div>
|
|
54
57
|
</div>
|
|
55
58
|
</div>,
|