@bytebrand/fe-ui-core-autobahn 1.0.12 → 1.0.13
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/cardParts.tsx +7 -5
- package/cards/types.ts +6 -0
- package/data/toAutobahnCar.ts +11 -1
- package/package.json +1 -1
package/cards/cardParts.tsx
CHANGED
|
@@ -29,11 +29,9 @@ const _leasCfg = (defaultConfig as any).leasing || {};
|
|
|
29
29
|
/** financing terms inputs (rendered via t in PricePaths), e.g. "0 € Anzahlung · 48 Monate Laufzeit". */
|
|
30
30
|
const _finFirstInstallment = (_finCfg.firstInstallment || 0).toLocaleString('de-DE');
|
|
31
31
|
const _finMonths = _finCfg.rawPaybackPeriod || _finCfg.paybackPeriod || 48;
|
|
32
|
-
/** leasing terms
|
|
32
|
+
/** leasing terms fallbacks (used when the car doesn't carry its own), e.g. "10.000 km/Jahr · 48 Monate". */
|
|
33
33
|
const _leasPeriod = _leasCfg.rawPaybackPeriod || _leasCfg.paybackPeriod;
|
|
34
34
|
const _leasMileage = _leasCfg.annualMileage || _leasCfg.mileage;
|
|
35
|
-
const _hasLeasTerms = Boolean(_leasMileage && _leasPeriod);
|
|
36
|
-
const _leasMileageStr = _leasMileage ? Number(_leasMileage).toLocaleString('de-DE') : '';
|
|
37
35
|
|
|
38
36
|
/** mileage → 'X.XXX km' (de-DE grouping). */
|
|
39
37
|
export function fmtKm(n: number): string {
|
|
@@ -428,6 +426,10 @@ export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t })
|
|
|
428
426
|
const finFirstInstallment =
|
|
429
427
|
car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
|
|
430
428
|
const finMonths = car.finMonths ?? _finMonths;
|
|
429
|
+
const leasMileage = car.leaseMileage ?? _leasMileage;
|
|
430
|
+
const leasMonths = car.leaseMonths ?? _leasPeriod;
|
|
431
|
+
const hasLeasTerms = Boolean(leasMileage && leasMonths);
|
|
432
|
+
const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
|
|
431
433
|
return (
|
|
432
434
|
<div className="pricepaths">
|
|
433
435
|
<div className="pp-hero">
|
|
@@ -447,9 +449,9 @@ export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t })
|
|
|
447
449
|
{hasLease && (
|
|
448
450
|
<div className="pp-lease-row">
|
|
449
451
|
<PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." />
|
|
450
|
-
{
|
|
452
|
+
{hasLeasTerms && (
|
|
451
453
|
<div className="pp-sub-terms">
|
|
452
|
-
{t('autobahn:card.price.leaseTerms', { mileage:
|
|
454
|
+
{t('autobahn:card.price.leaseTerms', { mileage: leasMileageStr, months: leasMonths })}
|
|
453
455
|
</div>
|
|
454
456
|
)}
|
|
455
457
|
</div>
|
package/cards/types.ts
CHANGED
|
@@ -114,6 +114,12 @@ export interface AutobahnCar {
|
|
|
114
114
|
marketHigh?: number;
|
|
115
115
|
/** leasing monthly rate in EUR. */
|
|
116
116
|
lease?: number;
|
|
117
|
+
/**
|
|
118
|
+
* leasing terms the `lease` rate was computed with — per-car merged config,
|
|
119
|
+
* same as finFirstInstallment/finMonths. Absent → default-config terms.
|
|
120
|
+
*/
|
|
121
|
+
leaseMileage?: number;
|
|
122
|
+
leaseMonths?: number;
|
|
117
123
|
/** number of buyers currently watching this car. */
|
|
118
124
|
watchers?: number;
|
|
119
125
|
/** number of recent views (drives the 'vor N Std' cue). */
|
package/data/toAutobahnCar.ts
CHANGED
|
@@ -308,8 +308,11 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
|
|
|
308
308
|
// financing terms the monthly rate was computed with — same merged per-car
|
|
309
309
|
// config (dealer rate + the user's saved localStorage adjustments, ADV-157).
|
|
310
310
|
// Emitted only when real; the cards fall back to the default-config terms.
|
|
311
|
+
// paybackPeriod FIRST: it carries the user's saved term, while rawPaybackPeriod
|
|
312
|
+
// is stamped from the dealer rate at normalize time and never reflects
|
|
313
|
+
// adjustments (normalizeRateObject.ts `rawPaybackPeriod: paybackPeriod`).
|
|
311
314
|
const finFirstInstallment = num(price?.financing?.firstInstallment);
|
|
312
|
-
const finMonths = num(price?.financing?.
|
|
315
|
+
const finMonths = num(price?.financing?.paybackPeriod) ?? num(price?.financing?.rawPaybackPeriod);
|
|
313
316
|
// price ← price.currentSalesPrice (DataTransformers.ts:352).
|
|
314
317
|
const purchase = num(price?.currentSalesPrice) ?? 0;
|
|
315
318
|
|
|
@@ -357,6 +360,11 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
|
|
|
357
360
|
// (instead of computing/showing a leasing rate the car isn't eligible for).
|
|
358
361
|
const leasingActive = !!(price && price.leasing && price.leasing.isActive);
|
|
359
362
|
const lease = leasingActive ? num(price?.leasing?.monthlyInstallment) : undefined;
|
|
363
|
+
// leasing terms the lease rate was computed with — same merged per-car config
|
|
364
|
+
// as the financing terms above (annualMileage/paybackPeriod carry the user's
|
|
365
|
+
// saved adjustments). Only meaningful alongside an active lease rate.
|
|
366
|
+
const leaseMileage = leasingActive ? num(price?.leasing?.annualMileage) : undefined;
|
|
367
|
+
const leaseMonths = leasingActive ? num(price?.leasing?.paybackPeriod) : undefined;
|
|
360
368
|
|
|
361
369
|
// --- optional: list price / savings — ONLY from a real strike price ---
|
|
362
370
|
// transformDataForVehicles exposes oldMonthlyInstallment / highestPrice via
|
|
@@ -444,6 +452,8 @@ export function toAutobahnCar(storeCar: any, deps: ToAutobahnCarDeps = {}): Auto
|
|
|
444
452
|
...(listPrice != null ? { listPrice } : {}),
|
|
445
453
|
...(savings != null ? { savings } : {}),
|
|
446
454
|
...(lease != null ? { lease } : {}),
|
|
455
|
+
...(leaseMileage != null ? { leaseMileage } : {}),
|
|
456
|
+
...(leaseMonths != null ? { leaseMonths } : {}),
|
|
447
457
|
...(drop != null ? { drop } : {}),
|
|
448
458
|
...(dropPct != null ? { dropPct } : {}),
|
|
449
459
|
...(zeroDown ? { zeroDown } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/fe-ui-core-autobahn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "auto.de md3 (Autobahn) design system — UI primitives, cards, chrome, VDP modules, theme CSS and locales. Ships raw TypeScript source (like fe-ui-core before it); each consumer's bundler compiles it.",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"license": "UNLICENSED",
|