@bytebrand/fe-ui-core-autobahn 1.0.214 → 1.0.216

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 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,17 @@ export interface CarCardProps {
98
99
  * (still onOpenRateAdjust).
99
100
  */
100
101
  onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
102
+ /**
103
+ * the price-rating badge + bar were clicked — open this car's VDP at its "Preis & Marktwert"
104
+ * section (URL fragment PRICE_SECTION_HASH, #vdp-preis). Page-owned like onShowFinancingDetails;
105
+ * when omitted the badge is not a link (a click opens the car via onOpen, as before).
106
+ */
107
+ onShowPriceRating?: (car: AutobahnCar) => void;
108
+ /**
109
+ * Tab the price block opens on (default Finanzierung) — e.g. the SRP's leasing-only results
110
+ * open every card on Leasing. Ignored for a car without a lease rate (it has no Leasing tab).
111
+ */
112
+ initialMode?: PaymentMode;
101
113
  }
102
114
 
103
115
  const CarCard: React.FunctionComponent<CarCardProps> = ({
@@ -113,8 +125,10 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
113
125
  onCall,
114
126
  onOpenRateAdjust,
115
127
  onShowFinancingDetails,
128
+ onShowPriceRating,
129
+ initialMode,
116
130
  }) => {
117
- const [mode, setMode] = useState<PaymentMode>('financing');
131
+ const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
118
132
  const [photoIndex, setPhotoIndex] = useState(0);
119
133
  const [viewerOpen, setViewerOpen] = useState(false);
120
134
  const mediaRef = useRef<HTMLDivElement | null>(null);
@@ -157,6 +171,8 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
157
171
  // active that's already 3, so NEU is dropped rather than causing a 4th to overflow.
158
172
  const activeDealChips = [showDrop || showSave, showPct, !!car.zeroDown].filter(Boolean).length;
159
173
  const showNeu = asGoodAsNew && car.isNew && activeDealChips < 3;
174
+ // tabs the price block can switch to (PriceTabs shows Leasing only when the car has a lease rate)
175
+ const paymentModes: PaymentMode[] = car.lease != null ? ['financing', 'leasing', 'buy'] : ['financing', 'buy'];
160
176
  return (
161
177
  <article
162
178
  className="mcard mcard--interactive cc-card"
@@ -279,21 +295,50 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
279
295
  <div className="cc-price" style={{ marginTop: 0, borderTop: '1px solid var(--md-outline-variant)' }}>
280
296
  <PriceTabs car={car} mode={mode} onModeChange={setMode} t={t} />
281
297
  <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 10 }}>
282
- <PriceHero car={car} mode={mode} t={t} alwaysShowUnit />
283
- <PriceEvalCol car={car} t={t} />
298
+ {/* every tab's hero stacked in one grid cell (.cc-hero-stack), only the active one
299
+ visible, bottom-aligned — Kaufen's struck list price sits on its own line above
300
+ the price, so without this the row (and the card) grew/shrank by that line on
301
+ every tab switch. Same trick as .cc-terms-stack below. */}
302
+ <div className="cc-hero-stack">
303
+ {paymentModes.map((m) => (
304
+ <div
305
+ key={m}
306
+ className={'cc-hero-slot' + (m === mode ? '' : ' cc-hero-slot--hidden')}
307
+ aria-hidden={m === mode ? undefined : true}
308
+ >
309
+ <PriceHero car={car} mode={m} t={t} alwaysShowUnit />
310
+ </div>
311
+ ))}
312
+ </div>
313
+ <PriceEvalCol car={car} t={t} onActivate={onShowPriceRating ? () => onShowPriceRating(car) : undefined} />
284
314
  </div>
285
315
  {/* same fallback CardCtaRow already uses below: pages that haven't wired a real
286
- "Rate anpassen" sheet yet still get a working "Details" link (opens the car). */}
287
- <PriceTerms
288
- car={car}
289
- mode={mode}
290
- onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
291
- onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, mode) : undefined}
292
- t={t}
293
- />
294
- {/* ADV-405/407 Kreditkosten-Hinweis: below the conditions line, above the CTA row (mobile)
295
- / eco line (desktop); not on Kaufen, which shows no financing terms either. */}
296
- {mode !== 'buy' && <CreditCostNotice t={t} size="small" cls="cc-ccn" />}
316
+ "Rate anpassen" sheet yet still get a working "Details" link (opens the car).
317
+ Every tab's terms line is rendered into the same grid cell (.cc-terms-stack) and
318
+ only the active one is visible — the cell is as tall as the tallest line, so the
319
+ card keeps one height across Finanzierung/Leasing/Kaufen (Leasing's longer line
320
+ wraps to 2 lines on narrow phones). No change to the visible line itself. */}
321
+ <div className="cc-terms-stack">
322
+ {paymentModes.map((m) => (
323
+ <div
324
+ key={m}
325
+ className={'cc-terms-slot' + (m === mode ? '' : ' cc-terms-slot--hidden')}
326
+ aria-hidden={m === mode ? undefined : true}
327
+ >
328
+ <PriceTerms
329
+ car={car}
330
+ mode={m}
331
+ onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
332
+ onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, m) : undefined}
333
+ t={t}
334
+ />
335
+ {/* ADV-405/407 Kreditkosten-Hinweis under the financing/leasing conditions line. Inside the
336
+ slot, so the stack keeps one height across the tabs (no jump on Kaufen); hidden slots
337
+ are visibility:hidden + aria-hidden like their terms line. */}
338
+ {m !== 'buy' && <CreditCostNotice t={t} size="small" cls="cc-ccn" />}
339
+ </div>
340
+ ))}
341
+ </div>
297
342
  </div>
298
343
  {/* Mobile-only row (CardCtaRow itself carries the show-mobile class) — always
299
344
  rendered, with real fallbacks the page can override once it wires its own
package/cards/CarRow.tsx CHANGED
@@ -24,6 +24,7 @@ import React, { useState, useEffect, useRef } from 'react';
24
24
  import { TranslationFunction } from '../types';
25
25
 
26
26
  import { CardCarousel, IconButton, SaveChip, Button, Icon, StatChip } from '../ui';
27
+ import { ratingLinkProps } from '../ui/ratingLink';
27
28
  import {
28
29
  EcoLine,
29
30
  PriceMeter,
@@ -41,6 +42,7 @@ import {
41
42
  ZeroDownChip,
42
43
  fmtKm,
43
44
  PaymentMode,
45
+ startPaymentMode,
44
46
  ratingTone,
45
47
  } from './cardParts';
46
48
  import { AutobahnCar } from './types';
@@ -80,6 +82,10 @@ export interface CarRowProps {
80
82
  * links render as plain text (see PricePaths' own fallback).
81
83
  */
82
84
  onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
85
+ /** the price-rating chip + bar were clicked — see CarCard's identically-named prop. */
86
+ onShowPriceRating?: (car: AutobahnCar) => void;
87
+ /** Tab the mobile price tabs open on — see CarCard's identically-named prop. */
88
+ initialMode?: PaymentMode;
83
89
  }
84
90
 
85
91
  const CarRow: React.FunctionComponent<CarRowProps> = ({
@@ -92,10 +98,23 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
92
98
  t,
93
99
  adminAction,
94
100
  onShowFinancingDetails,
101
+ onShowPriceRating,
102
+ initialMode,
95
103
  }) => {
96
- const [mode, setMode] = useState<PaymentMode>('financing');
104
+ const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
97
105
  const [photoIndex, setPhotoIndex] = useState(0);
98
106
  const mediaRef = useRef<HTMLDivElement | null>(null);
107
+ // The price-rating chip + bar link to the car's "Preis & Marktwert" section (page-owned
108
+ // onShowPriceRating, ratingLinkProps). Without it they stay plain: a click opens the car, as
109
+ // before. `noTabStop`: clickable, but not a second tab stop next to the chip.
110
+ const ratingLink = (className: string, noTabStop: boolean = false): React.HTMLAttributes<HTMLElement> => {
111
+ if (!onShowPriceRating || !car.rating) return {};
112
+ const props = ratingLinkProps(
113
+ () => onShowPriceRating(car),
114
+ t('autobahn:finance.priceRatingLink', { rating: t('autobahn:tier.' + car.rating) }),
115
+ );
116
+ return noTabStop ? { className, onClick: props.onClick, 'aria-hidden': true } : { className, ...props };
117
+ };
99
118
  // always call the LATEST onMediaEnter without re-arming the observer on every render (the
100
119
  // page callers construct a fresh closure each render) — the effect itself only needs to run
101
120
  // once per mount. Identical pattern to CarCard.tsx — see its own comment for the rationale.
@@ -275,13 +294,18 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
275
294
  <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 }}>
276
295
  <PriceHero car={car} mode={mode} t={t} alwaysShowUnit />
277
296
  {car.rating && (
278
- <StatChip tone={ratingTone(car.rating)} icon={ratingTone(car.rating) === 'good' ? 'check' : 'minus'}>
279
- {t('autobahn:tier.' + car.rating)}
280
- {ratingTone(car.rating) === 'good' && <sup>4</sup>}
281
- </StatChip>
297
+ <span {...ratingLink('rating-link')}>
298
+ <StatChip rating={car.rating} icon={ratingTone(car.rating) === 'good' ? 'check' : 'minus'}>
299
+ {t('autobahn:tier.' + car.rating)}
300
+ <sup>4</sup>
301
+ </StatChip>
302
+ </span>
282
303
  )}
283
304
  </div>
284
- <PriceMeter t={t} car={car} />
305
+ {/* the bar is clickable too, but not a second tab stop (the chip above is the link) */}
306
+ <div {...ratingLink('rating-link', true)}>
307
+ <PriceMeter t={t} car={car} />
308
+ </div>
285
309
  <div className="pp-cta">
286
310
  <Button
287
311
  variant="filled"
@@ -320,11 +344,11 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
320
344
  />
321
345
  <div className="pp-purchase hide-mobile">
322
346
  <PriceKauf car={car} t={t} />
323
- <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
347
+ <div style={{ display: 'flex', alignItems: 'center', gap: 10 }} {...ratingLink('rating-link')}>
324
348
  {car.rating && (
325
- <StatChip tone={ratingTone(car.rating)} icon={ratingTone(car.rating) === 'good' ? 'check' : 'minus'}>
349
+ <StatChip rating={car.rating} icon={ratingTone(car.rating) === 'good' ? 'check' : 'minus'}>
326
350
  {t('autobahn:tier.' + car.rating)}
327
- {ratingTone(car.rating) === 'good' && <sup>4</sup>}
351
+ <sup>4</sup>
328
352
  </StatChip>
329
353
  )}
330
354
  <div style={{ flex: 1 }}>
@@ -20,8 +20,9 @@ import { defaultConfig } from '@bytebrand/fe-financing';
20
20
 
21
21
  import { Icon, Button, CreditCostNotice, CreditKeyFigures, hasCreditKeyFigures } from '../ui';
22
22
  import type { CreditKeyFiguresData } from '../ui';
23
- import { EvalBar } from '../vdp/FinanceCalculator';
24
- import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS } from '../constants';
23
+ import { EvalBar, EvalPill } from '../vdp/FinanceCalculator';
24
+ import { ratingLinkProps } from '../ui/ratingLink';
25
+ import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS, NO_RATING_KEY, ratingColorsOf } from '../constants';
25
26
  import { AutobahnCar } from './types';
26
27
  // pure, non-React — shared with the Meta AIA marketing-image renderer (a plain Node service).
27
28
  export { ratingTone } from '../data/toAutobahnCar';
@@ -449,6 +450,8 @@ const TONE_TO_TIER: Record<string, number> = { top: 0, good: 1, fair: 2, raised:
449
450
  * Renders nothing when there is no rating/band (needs-data: we never draw a fake market position).
450
451
  */
451
452
  export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car }) => {
453
+ // "Keine Bewertung": the price is outside the bands, so no marker anywhere on the scale
454
+ if (car.rating === NO_RATING_KEY) return <EvalBar tier={null} />;
452
455
  const hasMarket =
453
456
  car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
454
457
  const bar = (tier: number) => {
@@ -460,7 +463,7 @@ export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: Translat
460
463
  <span key={i} className="fin-eval-seg" style={{ background: c }} />
461
464
  ))}
462
465
  <div
463
- className={`fin-eval-thumb${TIER_KEYS[tierIndex] === 'good' ? ' fin-eval-thumb--good' : ''}`}
466
+ className="fin-eval-thumb"
464
467
  style={{ left: `${leftPct}%`, borderColor: TIER_COLORS[tierIndex] }}
465
468
  />
466
469
  </div>
@@ -482,9 +485,38 @@ export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: Translat
482
485
  * Preisbewertung pill + segmented tier bar, grouped in one column exactly like the VDP
483
486
  * finance-calculator's mobile .fin-eval-col (FinanceCalculator.tsx/EvalBar) — the grid card's
484
487
  * replacement for the old StatChip pill + full-width gradient .pp-bar pairing. Renders nothing
485
- * without a rating (needs-data: never invent a tier).
488
+ * without a rating (needs-data: never invent a tier). With `onActivate` the pill + bar are one link
489
+ * (ratingLinkProps): the page opens the car's VDP at its "Preis & Marktwert" section.
486
490
  */
487
- export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car, t }) => {
491
+ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction; onActivate?: () => void }> = ({
492
+ car,
493
+ t,
494
+ onActivate,
495
+ }) => {
496
+ const linkProps = (label: string) =>
497
+ onActivate
498
+ ? { className: 'fin-eval-col rating-link', ...ratingLinkProps(onActivate, t('autobahn:finance.priceRatingLink', { rating: label })) }
499
+ : { className: 'fin-eval-col' };
500
+ if (car.rating === NO_RATING_KEY) {
501
+ // "Keine Bewertung": grey pill, the usual bar without a marker
502
+ const noRatingLabel = t('autobahn:tier.' + NO_RATING_KEY);
503
+ const noRating = ratingColorsOf(NO_RATING_KEY);
504
+ return (
505
+ <div {...linkProps(noRatingLabel)}>
506
+ <div className="fin-eval-pill-cell">
507
+ <EvalPill
508
+ label={noRatingLabel}
509
+ color={noRating.color}
510
+ background={noRating.background}
511
+ ariaLabel={t('autobahn:finance.priceRatingAria', { rating: noRatingLabel })}
512
+ />
513
+ </div>
514
+ <div className="fin-eval-bar-cell">
515
+ <EvalBar tier={null} />
516
+ </div>
517
+ </div>
518
+ );
519
+ }
488
520
  const tier = car.rating ? TONE_TO_TIER[car.rating] : undefined;
489
521
  if (tier == null) return null;
490
522
  const hasMarket =
@@ -497,20 +529,18 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
497
529
  // each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
498
530
  // collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
499
531
  const tierLabel = t('autobahn:tier.' + car.rating);
500
- // 'good' collapses onto the 'top' tier's own color too (#168a45), matching the fixed
501
- // "Top-Preis" text above rather than tier 1's lighter TIER_COLORS[1] green.
502
- const pillColor = isGood ? TIER_COLORS[0] : TIER_COLORS[tier];
532
+ // the tier's own badge colours (--rating-*), the same as on every other page
533
+ const pill = ratingColorsOf(car.rating);
503
534
  return (
504
- <div className="fin-eval-col">
535
+ <div {...linkProps(tierLabel)}>
505
536
  <div className="fin-eval-pill-cell">
506
- <span
507
- className={`fin-eval-pill${isGood ? ' fin-eval-pill--good' : ''}`}
508
- style={{ color: pillColor, background: `color-mix(in srgb, ${pillColor} 16%, transparent)` }}
509
- aria-label={t('autobahn:finance.priceRatingAria', { rating: tierLabel })}
510
- >
511
- {tierLabel}
512
- {isGood && <sup>4</sup>}
513
- </span>
537
+ <EvalPill
538
+ label={tierLabel}
539
+ color={pill.color}
540
+ background={pill.background}
541
+ good={isGood}
542
+ ariaLabel={t('autobahn:finance.priceRatingAria', { rating: tierLabel })}
543
+ />
514
544
  </div>
515
545
  <div className="fin-eval-bar-cell">
516
546
  <EvalBar tier={tier} leftPct={leftPct} />
@@ -521,6 +551,11 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
521
551
 
522
552
  export type PaymentMode = 'financing' | 'leasing' | 'buy';
523
553
 
554
+ /** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
555
+ * without a lease rate — PriceTabs has no Leasing tab for it. */
556
+ export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
557
+ requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
558
+
524
559
  export interface PriceTabsProps {
525
560
  car: AutobahnCar;
526
561
  mode: PaymentMode;
@@ -755,7 +790,12 @@ export const PriceTerms: React.FunctionComponent<{
755
790
  onShowDetails?: () => void;
756
791
  t: TranslationFunction;
757
792
  }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
758
- if (mode === 'buy') return null;
793
+ // Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
794
+ // here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
795
+ // real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
796
+ // every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
797
+ // FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
798
+ if (mode === 'buy') return <div className="cc-terms" />;
759
799
  const finFirstInstallment =
760
800
  car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
761
801
  const finMonths = car.finMonths ?? _finMonths;
@@ -36,12 +36,10 @@
36
36
  color: $priceReviewColors[darkBackground]
37
37
  border: 2px solid $priceReviewColors[darkBackground]
38
38
 
39
- for colorName in $priceReviewColors
40
- $color = $priceReviewColors[colorName]
41
- if $color == $priceReviewColors.noRating
42
- $color = $priceReviewColors[darkBackground]
43
- $backgroundColor = $priceReviewColors[colorName]
39
+ // label: the rating's text colour; segment: its scale colour
40
+ for colorName in $priceReviewTextColors
44
41
  .{colorName}
45
- color: $color
42
+ color: $priceReviewTextColors[colorName]
43
+ for colorName in $priceReviewColors
46
44
  .{colorName}Background
47
- border: 2px solid $backgroundColor
45
+ border: 2px solid $priceReviewColors[colorName]
@@ -71,26 +71,28 @@
71
71
 
72
72
  .noRatingTooltip
73
73
  @extends .baseTooltip
74
- color: black
75
- border-color: $priceReviewColors[darkBackground]
74
+ color: $priceReviewTextColors[noRating]
75
+ border-color: #C8D1DE
76
76
 
77
77
  .tooltip
78
78
  @extends .baseTooltip
79
79
  color: white
80
80
 
81
+ // segment: the rating's scale colour; tooltip (text on white): its text colour
81
82
  for colorName in $priceReviewColors
82
83
  $color = $priceReviewColors[colorName]
84
+ $textColor = $priceReviewTextColors[colorName] || $color
83
85
  .{colorName}
84
86
  &.segment
85
87
  background-color $color
86
88
  .tooltipWrapper
87
89
  &:after
88
- background-color: $color
90
+ background-color: $textColor
89
91
  .tooltip
90
- border-color: $color
91
- color: $color
92
+ border-color: $textColor
93
+ color: $textColor
92
94
  &:after
93
- background-color: $color
95
+ background-color: $textColor
94
96
 
95
97
  .compact
96
98
  & .segment
@@ -1,12 +1,25 @@
1
1
 
2
+ // The old Preisbewertung popup (PriceRating, PriceRatingDetailed) in the price-rating colours every
3
+ // other page uses (Figma 474sauvNgCYK2mEq5iks9e 142:3643; the lib's constants/autobahn.ts and md3.css
4
+ // --rating-*). $priceReviewColors: the scale (TIER_COLORS, --rating-*-bar); noRating/darkBackground
5
+ // stay the empty-segment grey.
2
6
  $priceReviewColors = {
3
7
  noRating: rgba(76, 78, 100, 0.22)
4
8
  darkBackground: rgba(76, 78, 100, 0.22)
5
- highPrice: rgba(226, 108, 0, 1)
6
- increasedPrice: rgba(237, 157, 55, 1)
7
- fairPrice: rgba(173, 208, 66, 1)
8
- goodPrice: rgba(102, 212, 102, 1)
9
- topPrice: rgba(31, 193, 31, 1)
9
+ highPrice: #E60000
10
+ increasedPrice: #F26B43
11
+ fairPrice: #F7C544
12
+ goodPrice: #66B84D
13
+ topPrice: #168A45
14
+ }
15
+ // the rating labels' text (TIER_TEXT_COLORS / NO_RATING_COLOR, --rating-*-fg)
16
+ $priceReviewTextColors = {
17
+ noRating: #5B6B7F
18
+ highPrice: #E60000
19
+ increasedPrice: #F26B43
20
+ fairPrice: #FFB800
21
+ goodPrice: #66B84D
22
+ topPrice: #168A45
10
23
  }
11
24
 
12
25
 
package/constants/app.ts CHANGED
@@ -40,7 +40,17 @@ export const LOCAL_STORAGE_KEY = {
40
40
  i18n_KEY: 'i18nLanguage'
41
41
  };
42
42
 
43
- export const DEFAULT_LANG: string = typeof window !== 'undefined' ? localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : 'de';
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';
@@ -22,10 +22,49 @@ export const TIER_LABELS = ['Top Preis', 'Guter Preis', 'Fairer Preis', 'Erhöht
22
22
  // i18n key suffixes parallel to TIER_LABELS — components render t('autobahn:tier.<key>') so the
23
23
  // Preisbewertung label localizes (TIER_LABELS stays the German source-of-truth used for tier→index logic).
24
24
  export const TIER_KEYS = ['top', 'good', 'fair', 'raised', 'high'] as const;
25
+ /** the five segments (and the marker ring) of the price-rating bar */
25
26
  export const TIER_COLORS: readonly string[] = ['#168A45', '#66B84D', '#F7C544', '#F26B43', '#E60000'];
27
+ /**
28
+ * Price-rating badge colours, the same on every page (Figma 474sauvNgCYK2mEq5iks9e 142:3643
29
+ * "Die auto.de Bewertungskategorien"): the label's text colour on its background, per tier.
30
+ * md3.css repeats them as --rating-<key>-fg / --rating-<key>-bg for the CSS-only badges; fe-main's
31
+ * ratingPalette test keeps the two in step.
32
+ */
33
+ export const TIER_TEXT_COLORS: readonly string[] = ['#168A45', '#66B84D', '#FFB800', '#F26B43', '#E60000'];
26
34
  export const TIER_BACKGROUNDS: readonly string[] = ['#DFF3E5', '#E4F3DF', '#FFF6DB', '#FFEFD5', '#FFD3D3'];
27
35
  export type RatingTier = 0 | 1 | 2 | 3 | 4;
28
36
 
37
+ /**
38
+ * "Keine Bewertung": getPriceRating returned 0 for a real price, because the price is outside the
39
+ * rating bands (more than 25% above the market value). That is no tier, so it is never shown as
40
+ * one. It is a grey "Keine Bewertung" pill; the bar keeps its usual colours but has no marker,
41
+ * since the price has no place on the scale.
42
+ * mapRating emits NO_RATING_KEY as `rating` and NO_RATING_LABEL as `ratingLabel`; the label key is
43
+ * t('autobahn:tier.none').
44
+ */
45
+ export const NO_RATING_KEY = 'none';
46
+ export const NO_RATING_LABEL = 'Keine Bewertung';
47
+ /** "Keine Bewertung" badge text and background (Figma 142:3643, like TIER_TEXT_COLORS) */
48
+ export const NO_RATING_COLOR = '#5B6B7F';
49
+ export const NO_RATING_BACKGROUND = '#C8D1DE';
50
+
51
+ /** Badge text colour and background of a mapRating() `rating` key ('top' … 'high', or
52
+ * NO_RATING_KEY). An unknown key falls back to 'good', as evalTierOf does. */
53
+ export function ratingColorsOf(rating?: string): { color: string; background: string } {
54
+ if (rating === NO_RATING_KEY) return { color: NO_RATING_COLOR, background: NO_RATING_BACKGROUND };
55
+ const index = TIER_KEYS.indexOf(rating as (typeof TIER_KEYS)[number]);
56
+ const tier = index >= 0 ? index : 1;
57
+ return { color: TIER_TEXT_COLORS[tier], background: TIER_BACKGROUNDS[tier] };
58
+ }
59
+
60
+ /** Tier index (0 Top … 4 Hoch) of a mapRating() `ratingLabel`, or null for "Keine Bewertung".
61
+ * An unknown label falls back to 1, as the components always did. */
62
+ export function evalTierOf(ratingLabel?: string): RatingTier | null {
63
+ if (ratingLabel === NO_RATING_LABEL) return null;
64
+ const index = TIER_LABELS.indexOf(ratingLabel as (typeof TIER_LABELS)[number]);
65
+ return (index >= 0 ? index : 1) as RatingTier;
66
+ }
67
+
29
68
  /** SRP sort options (labels match the design; mapped to real sort params by the SRP container). */
30
69
  export const SORTS = [
31
70
  'Relevanz',
package/constants/core.ts CHANGED
@@ -35,7 +35,18 @@ export const LOCAL_STORAGE_KEY = {
35
35
  i18n_KEY: 'i18nLanguage'
36
36
  };
37
37
 
38
- export const DEFAULT_LANG: string = (typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null) ?? 'de';
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
@@ -226,18 +226,18 @@ export const FIELD_MAPPINGS: readonly FieldMapping[] = [
226
226
  status: 'wired',
227
227
  source: 'price.currentSalesPrice + price.mlCurrentSalesPricePredicted',
228
228
  transform:
229
- "getPriceRating(sale, predicted) [0..5] → autobahn tone: 5→'top' 4→'good' 3→'fair' 2→'raised' 1→'high'; 0(noRating)→neutral 'fair'",
229
+ "getPriceRating(sale, predicted) [0..5] → autobahn tone: 5→'top' 4→'good' 3→'fair' 2→'raised' 1→'high'; 0(noRating, price more than 25% above the market value)→'none' (Keine Bewertung)",
230
230
  confirmedAt:
231
231
  'VehicleInfo.tsx:160 (SRP card renders getPriceRating(currentSalesPrice, mlCurrentSalesPricePredicted)) · CommonUtils.ts:353-373 (getPriceRating) · price.ts:1 (priceRatings order) · DataTransformers.ts:354 (mlCurrentSalesPricePredicted)',
232
232
  notes:
233
- "REAL Preisbewertung. Card only special-cases tone==='fair' → warn pill; every other tone → good/green pill (CarCard.tsx:96-97). For noRating we pick the NEUTRAL middle tier, never a flattering one. predicted falls back to sale*1.07814 (PREDICTABLE_PRICE_INDEX) inside getPriceRating, exactly like the live card.",
233
+ "REAL Preisbewertung. Card only special-cases tone==='fair' → warn pill; every other tone → good/green pill (CarCard.tsx:96-97). noRating is no tier: 'none', a grey Keine Bewertung pill without a marker (it used to be folded into 'fair'). predicted falls back to sale*1.07814 (PREDICTABLE_PRICE_INDEX) inside getPriceRating, exactly like the live card.",
234
234
  },
235
235
  {
236
236
  field: 'ratingLabel',
237
237
  required: true,
238
238
  status: 'wired',
239
239
  source: 'derived from the rating tier',
240
- transform: "TIER_LABELS[tier] → 'Top Preis'|'Guter Preis'|'Fairer Preis'|'Erhöht'|'Hoher Preis'",
240
+ transform: "TIER_LABELS[tier] → 'Top Preis'|'Guter Preis'|'Fairer Preis'|'Erhöht'|'Hoher Preis', or NO_RATING_LABEL 'Keine Bewertung'",
241
241
  confirmedAt:
242
242
  'autobahn/constants.ts:17 (TIER_LABELS) · fe-ui-core locales/priceRating.ts:2-9 (legacy German labels: TOP/GUTER/FAIRER/ERHÖHTER/HOHER PREIS)',
243
243
  notes:
@@ -29,7 +29,7 @@ import { getPowerLabel } from '../utils/power';
29
29
 
30
30
  import { AutobahnCar, AutobahnPhev } from '../cards/types';
31
31
  import { leasingKeyFigures } from '../ui/CreditKeyFigures';
32
- import { TIER_LABELS, RatingTier, CO2_CLASSES, Co2Class } from '../constants/autobahn';
32
+ import { TIER_LABELS, RatingTier, CO2_CLASSES, Co2Class, NO_RATING_KEY, NO_RATING_LABEL } from '../constants/autobahn';
33
33
 
34
34
  /**
35
35
  * Last-resort placeholder shown in the carousel until the real images for a car
@@ -238,13 +238,13 @@ export function co2ClassLetter(code: any): Co2Class | '' {
238
238
  * topPrice(5)→0 'Top Preis' · goodPrice(4)→1 'Guter Preis' ·
239
239
  * fairPrice(3)→2 'Fairer Preis' · increasedPrice(2)→3 'Erhöht' ·
240
240
  * highPrice(1)→4 'Hoher Preis'.
241
- * noRating(0) has no real comparison → neutral 'Fairer Preis' (tier 2) WITHOUT a
242
- * flattering label (documented in fieldMapping.ts). The card only special-cases
243
- * the 'fair' tone (warn pill); every other tone is the good/green pill.
241
+ * noRating(0) means the price is outside the bands (more than 25% above the market value). It is
242
+ * no tier: it maps to NO_RATING_KEY 'none' / NO_RATING_LABEL 'Keine Bewertung', a grey pill and
243
+ * the usual bar without a marker. It used to be folded into 'Fairer Preis', so a car priced 57%
244
+ * above the market showed "Fairer Preis".
244
245
  *
245
- * AutobahnCar.rating is a free string; CarCard does `rating === 'fair' ? warn : good`.
246
- * We emit the autobahn tier key ('top'|'good'|'fair'|'raised'|'high') so the
247
- * neutral 'fair' maps to the warn pill exactly like the design intends.
246
+ * AutobahnCar.rating is a free string: the autobahn tier key ('top'|'good'|'fair'|'raised'|'high')
247
+ * or 'none'. Callers only compute it for a real, positive price; without one it stays ''.
248
248
  */
249
249
  const LEGACY_TO_TIER: Record<number, RatingTier> = {
250
250
  5: 0, // topPrice → Top Preis
@@ -263,18 +263,20 @@ const TIER_TONE: Record<RatingTier, string> = {
263
263
 
264
264
  export function mapRating(currentSalesPrice?: number, predicted?: number): { rating: string; ratingLabel: string } {
265
265
  const legacy = getPriceRating(currentSalesPrice as number, predicted as number); // 0..5
266
- // 0 = noRating: keep neutral (tier 2) — never invent a flattering rating.
267
- const tier: RatingTier = legacy === 0 ? 2 : LEGACY_TO_TIER[legacy] ?? 2;
266
+ const tier: RatingTier | undefined = LEGACY_TO_TIER[legacy];
267
+ if (tier == null) return { rating: NO_RATING_KEY, ratingLabel: NO_RATING_LABEL };
268
268
  return { rating: TIER_TONE[tier], ratingLabel: TIER_LABELS[tier] };
269
269
  }
270
270
 
271
271
  /**
272
272
  * Map the 5-tier rating to a 2-tone signal — only 'top'/'good' read as a genuinely good deal
273
273
  * (green); 'fair'/'raised'/'high' all get the warn/peach tone (Figma: "Erhöhter-Preis" is
274
- * peach, not green). Pure/non-React on purpose: shared by the web card's StatChip via
275
- * cards/cardParts.tsx's re-export.
274
+ * peach, not green). "Keine Bewertung" is neither: 'neutral' (grey). Pure/non-React on purpose.
275
+ * The rating chips take their colours per tier now (StatChip's `rating`, the --rating-* palette); this
276
+ * only picks their icon (check for a good deal, minus otherwise).
276
277
  */
277
- export function ratingTone(rating: string): 'good' | 'warn' {
278
+ export function ratingTone(rating: string): 'good' | 'warn' | 'neutral' {
279
+ if (rating === NO_RATING_KEY) return 'neutral';
278
280
  return rating === 'top' || rating === 'good' ? 'good' : 'warn';
279
281
  }
280
282
 
@@ -95,6 +95,7 @@
95
95
  "uvp": "UVP",
96
96
  "priceRating": "Preisbewertung",
97
97
  "priceRatingAria": "Preisbewertung: {{rating}}",
98
+ "priceRatingLink": "Preisbewertung: {{rating}} – zu Preis & Marktwert",
98
99
  "detailsShow": "Details anzeigen",
99
100
  "paymentLabel": "Zahlung",
100
101
  "paymentValue": "Überweisung",
@@ -143,7 +144,6 @@
143
144
  "title": "Das sagen unsere Kunden",
144
145
  "ratingCount": "{{count}} Bewertung",
145
146
  "ratingCount_plural": "{{count}} Bewertungen",
146
- "teaserCount": "{{count}} Google-Bewertungen",
147
147
  "sourceReview": "{{portal}}-Bewertung",
148
148
  "sources": {
149
149
  "open": "So entsteht unsere Bewertung",
@@ -560,7 +560,8 @@
560
560
  "good": "Guter Preis",
561
561
  "fair": "Fairer-Preis",
562
562
  "raised": "Erhöhter Preis",
563
- "high": "Hoher Preis"
563
+ "high": "Hoher Preis",
564
+ "none": "Keine Bewertung"
564
565
  },
565
566
  "sort": {
566
567
  "relevance": "Relevanz",
@@ -95,6 +95,7 @@
95
95
  "uvp": "RRP",
96
96
  "priceRating": "Price rating",
97
97
  "priceRatingAria": "Price rating: {{rating}}",
98
+ "priceRatingLink": "Price rating: {{rating}} – go to price & market value",
98
99
  "detailsShow": "Show details",
99
100
  "paymentLabel": "Payment",
100
101
  "paymentValue": "Bank transfer",
@@ -143,7 +144,6 @@
143
144
  "title": "What our customers say",
144
145
  "ratingCount": "{{count}} rating",
145
146
  "ratingCount_plural": "{{count}} ratings",
146
- "teaserCount": "{{count}} Google reviews",
147
147
  "sourceReview": "{{portal}} review",
148
148
  "sources": {
149
149
  "open": "How our rating is calculated",
@@ -560,7 +560,8 @@
560
560
  "good": "Good price",
561
561
  "fair": "Fair price",
562
562
  "raised": "Increased price",
563
- "high": "High price"
563
+ "high": "High price",
564
+ "none": "No rating"
564
565
  },
565
566
  "sort": {
566
567
  "relevance": "Relevance",