@bytebrand/fe-ui-core 4.8.1 → 4.8.2

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.
@@ -47,7 +47,7 @@ describe('MaterialDatePicker', () => {
47
47
  fireEvent.click(okButton);
48
48
  fireEvent.focusOut(input);
49
49
 
50
- expect(handleChange).toHaveBeenCalledTimes(3);
50
+ expect(handleChange).toHaveBeenCalledTimes(4);
51
51
  expect(handleOpen).toHaveBeenCalledTimes(1);
52
52
  expect(handleBlur).toHaveBeenCalledTimes(1);
53
53
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.8.1",
3
+ "version": "4.8.2",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -13,7 +13,6 @@
13
13
  "@babel/preset-react": "^7.18.6",
14
14
  "@babel/preset-typescript": "^7.21.0",
15
15
  "@bytebrand/car-schema-selectors": "^2.0.7",
16
- "@bytebrand/fe-financing": "^5.10.6",
17
16
  "@bytebrand/fe-histoslider": "3.0.0",
18
17
  "@bytebrand/i18n-dictionaries": "^0.7.5",
19
18
  "@emotion/react": "^11.9.3",
@@ -355,4 +355,14 @@ export interface IWltpConsumption {
355
355
  wltpPowerCombined?: number;
356
356
  wltpWeightedCombined?: number;
357
357
  wltpWeightedPowerCombined?: number;
358
+ }
359
+
360
+ export interface IFinancingUtils {
361
+ co2DefaultCostsLow: number;
362
+ co2DefaultCostsMedium: number;
363
+ co2DefaultCostsHigh: number;
364
+ getVehicleTax: (fuelType: string, cubicCapacity: number, co2: number, firstRegistration: number) => number;
365
+ getFuelPrice: (fuelSelector: string, consumption: IWltpConsumption, hybridPlugin?: boolean) => number;
366
+ getBaseFuelPrice: (fuelSelector: string, hybridPlugin?: boolean) => { fuelPrice: number, powerPrice?: number };
367
+ getCo2Price: (wltpCo2: number) => { co2PriceLow: number, co2PriceMedium: number, co2PriceHigh: number };
358
368
  }
@@ -7,9 +7,8 @@ import { formatTimestamp } from '../utils/DateUtils';
7
7
  import { formatMileage } 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
- import { IDecoratedProp, ICar } from '../types/types';
10
+ import { IDecoratedProp, ICar, IFinancingUtils } from '../types/types';
11
11
  import { getFormattedPrice } from '../utils/CommonUtils';
12
- import { getVehicleTax, getFuelPrice, co2DefaultCostsLow, co2DefaultCostsMedium, co2DefaultCostsHigh, getBaseFuelPrice, getCo2Price } from '@bytebrand/fe-financing';
13
12
 
14
13
  const formatDeliveryPeriod = (t: (key: string, options?: object) => string, deliveryPeriod: string) => {
15
14
  const count: number = +DELIVERY_PERIODS_EXTRA.find((period: any) => period.value === deliveryPeriod).label;
@@ -72,7 +71,8 @@ const getDecoratedProps = (
72
71
  car: ICar, // @TODO should have a proper interface
73
72
  t: (key: string, options?: object) => string,
74
73
  language: string = 'en',
75
- simplifiedLabels: boolean = false // shortened labels for repsonsive layout (see 'power'),
74
+ simplifiedLabels: boolean = false, // shortened labels for repsonsive layout (see 'power'),
75
+ financingUtils?: IFinancingUtils
76
76
  ): IDecoratedProp => {
77
77
  const {
78
78
  offer = {},
@@ -1548,6 +1548,7 @@ const getDecoratedProps = (
1548
1548
  const consumption = {
1549
1549
  wltpCombined, wltpPowerCombined, wltpWeightedCombined, wltpWeightedPowerCombined
1550
1550
  }
1551
+ const { getFuelPrice } = financingUtils;
1551
1552
  const fuelCost = getFuelPrice(fuel, consumption, hybridPlugin);
1552
1553
  return Number.isFinite(fuelCost)
1553
1554
  ? t('vehicleProps:value.pricePerYear', { price: getFormattedPrice(fuelCost, '$,.2f') })
@@ -1555,9 +1556,14 @@ const getDecoratedProps = (
1555
1556
  }
1556
1557
  },
1557
1558
  wltpCo2CostsLow: {
1558
- title: t('vehicleProps:title.wltpCo2LowPrice', { price: co2DefaultCostsLow }),
1559
+ get title() {
1560
+ const { co2DefaultCostsLow } = financingUtils;
1561
+ return t('vehicleProps:title.wltpCo2LowPrice', { price: co2DefaultCostsLow })
1562
+ },
1559
1563
  get value() {
1560
1564
  const wltpCo2 = car.environmentEmissions.wltpCo2;
1565
+
1566
+ const { getCo2Price } = financingUtils;
1561
1567
  const { co2PriceLow } = getCo2Price(wltpCo2);
1562
1568
  return Number.isFinite(co2PriceLow)
1563
1569
  ? t('vehicleProps:value.wltpCo2Price', { price: getFormattedPrice(co2PriceLow, '$,.2f') })
@@ -1565,9 +1571,14 @@ const getDecoratedProps = (
1565
1571
  }
1566
1572
  },
1567
1573
  wltpCo2CostsMiddle: {
1568
- title: t('vehicleProps:title.wltpCo2MidPrice', { price: co2DefaultCostsMedium }),
1574
+ get title() {
1575
+ const { co2DefaultCostsMedium } = financingUtils;
1576
+ return t('vehicleProps:title.wltpCo2MidPrice', { price: co2DefaultCostsMedium })
1577
+ },
1569
1578
  get value() {
1570
1579
  const wltpCo2 = car.environmentEmissions.wltpCo2;
1580
+
1581
+ const { getCo2Price } = financingUtils;
1571
1582
  const { co2PriceMedium } = getCo2Price(wltpCo2);
1572
1583
  return Number.isFinite(co2PriceMedium)
1573
1584
  ? t('vehicleProps:value.wltpCo2Price', { price: getFormattedPrice(co2PriceMedium, '$,.2f') })
@@ -1575,9 +1586,14 @@ const getDecoratedProps = (
1575
1586
  }
1576
1587
  },
1577
1588
  wltpCo2CostsHigh: {
1578
- title: t('vehicleProps:title.wltpCo2HighPrice', { price: co2DefaultCostsHigh }),
1589
+ get title() {
1590
+ const { co2DefaultCostsHigh } = financingUtils;
1591
+ return t('vehicleProps:title.wltpCo2HighPrice', { price: co2DefaultCostsHigh })
1592
+ },
1579
1593
  get value() {
1580
1594
  const wltpCo2 = car.environmentEmissions.wltpCo2;
1595
+
1596
+ const { getCo2Price } = financingUtils;
1581
1597
  const { co2PriceHigh } = getCo2Price(wltpCo2);
1582
1598
  return Number.isFinite(co2PriceHigh)
1583
1599
  ? t('vehicleProps:value.wltpCo2Price', { price: getFormattedPrice(co2PriceHigh, '$,.2f') })
@@ -1590,6 +1606,8 @@ const getDecoratedProps = (
1590
1606
  const fuel = car.consumption.fuel;
1591
1607
  const { hybridPlugin } = car.engineData;
1592
1608
 
1609
+ const { getBaseFuelPrice } = financingUtils;
1610
+
1593
1611
  const basePowerPrice = getBaseFuelPrice(fuel, hybridPlugin).powerPrice;
1594
1612
  const powerPrice = car.costModel.powerPrice ? car.costModel.powerPrice : basePowerPrice;
1595
1613
 
@@ -1604,6 +1622,8 @@ const getDecoratedProps = (
1604
1622
  const fuel = car.consumption.fuel;
1605
1623
  const { hybridPlugin } = car.engineData;
1606
1624
 
1625
+ const { getBaseFuelPrice } = financingUtils;
1626
+
1607
1627
  const baseFuelPrice = getBaseFuelPrice(fuel, hybridPlugin);
1608
1628
 
1609
1629
  const fuelPrice = car.costModel.fuelPrice ? car.costModel.fuelPrice : baseFuelPrice;
@@ -1627,6 +1647,7 @@ const getDecoratedProps = (
1627
1647
  const cubicCapacity = car.engineData.cubicCapacity;
1628
1648
  const fuel = car.consumption.fuel;
1629
1649
  const wltpCo2 = car.environmentEmissions.wltpCo2;
1650
+ const { getVehicleTax } = financingUtils;
1630
1651
  const tax = car.costModel.tax ? car.costModel.tax : getVehicleTax(fuel, cubicCapacity, wltpCo2, firstRegistration);
1631
1652
  return Number.isFinite(tax)
1632
1653
  ? t('vehicleProps:value.price', { price: getFormattedPrice(tax, '$,.2f') })