@bytebrand/fe-ui-core-autobahn 1.0.102 → 1.0.103

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core-autobahn",
3
- "version": "1.0.102",
3
+ "version": "1.0.103",
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",
@@ -25,6 +25,23 @@ export const formatMileage = (millage: number | string) => {
25
25
  return millage.toLocaleString('en-US').replace(/,/g, '.');
26
26
  };
27
27
 
28
+ // Same thresholds as the "NEU" badge (ADV-166, see fe-main/fe-landing/fe-wp-widgets
29
+ // DataTransformers.ts) minus its extra "recently listed" (modificationDate) check —
30
+ // this is about the car itself being practically brand-new, not about listing recency.
31
+ // Missing firstRegistration passes the age check (can't disqualify what we don't know).
32
+ const EFFECTIVELY_NEW_MAX_MILEAGE_KM = 1000;
33
+ const EFFECTIVELY_NEW_MAX_AGE_MONTHS = 12;
34
+ const AVG_MS_PER_MONTH = 1000 * 60 * 60 * 24 * 30.44;
35
+
36
+ export const isEffectivelyNewCar = (mileageKm?: number | string | null, firstRegistration?: number | Date | string | null): boolean => {
37
+ if (!(Number(mileageKm) < EFFECTIVELY_NEW_MAX_MILEAGE_KM)) return false;
38
+ if (!firstRegistration) return true;
39
+ const registeredAtMs = firstRegistration instanceof Date ? firstRegistration.getTime() : Number(firstRegistration) * 1000;
40
+ if (!Number.isFinite(registeredAtMs)) return true;
41
+ const ageMonths = (Date.now() - registeredAtMs) / AVG_MS_PER_MONTH;
42
+ return ageMonths < EFFECTIVELY_NEW_MAX_AGE_MONTHS;
43
+ };
44
+
28
45
  export const getFormattedNumber = (num: number) => Number.isFinite(num) ? num.toLocaleString('de-DE') : null;
29
46
 
30
47
  export const numberWithDot = (value: number | string) => {
package/utils/index.ts CHANGED
@@ -43,6 +43,7 @@ export {
43
43
  checkRangeValuesOnEqual,
44
44
  fixNumber,
45
45
  formatMileage,
46
+ isEffectivelyNewCar,
46
47
  getChipFilterValue,
47
48
  getFormattedPrice,
48
49
  getGroupValuesForQuery,
@@ -4,7 +4,7 @@ import moment from 'moment';
4
4
  import Icon from '../compat/IconContainer/IconContainer';
5
5
  import CO2Efficiency from '../compat/Co2Widget/CO2Efficiency';
6
6
  import { formatTimestamp } from '../utils/DateUtils';
7
- import { formatMileage } from '../utils/CommonUtils';
7
+ import { formatMileage, isEffectivelyNewCar } from '../utils/CommonUtils';
8
8
  import { EMISSION_STICKERS_ICONS, WP_EMISSION_STICKERS_ICONS } from '../constants/Search';
9
9
  import { DELIVERY_PERIODS_EXTRA } from '../constants';
10
10
  import { IDecoratedProp, ICar, IFinancingUtils } from '../types/types';
@@ -1120,7 +1120,10 @@ const getDecoratedProps = (
1120
1120
  maintenanceGuide: {
1121
1121
  title: t('vehicleProps:title.maintenanceGuide'),
1122
1122
  get value() {
1123
- const fullserviceHistory = car.careService.fullServiceHistory;
1123
+ // A practically brand-new car (near-zero mileage, recent/no first registration)
1124
+ // is always treated as full-service-history, regardless of the raw dealer flag —
1125
+ // there's simply been no time yet for a service history to matter.
1126
+ const fullserviceHistory = isEffectivelyNewCar(mileage, firstRegistration) ? true : car.careService.fullServiceHistory;
1124
1127
  return isPropDefined(fullserviceHistory)
1125
1128
  ? (fullserviceHistory ? t('vehicleProps:value.yes') : t('vehicleProps:value.no'))
1126
1129
  : t('vehicleProps:value.na');