@bytebrand/fe-ui-core 4.6.2 → 4.6.4

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",
3
- "version": "4.6.2",
3
+ "version": "4.6.4",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -137,6 +137,7 @@ class AccordionWidget extends React.Component<IAccardionSectionProps, IAccardion
137
137
  const engineProps = getVehicleDetails(consumption.fuel, 'engineData', engineData.hybridPlugin);
138
138
  const environmentProps = getVehicleDetails(consumption.fuel, 'environment', engineData.hybridPlugin);
139
139
  const wltpProps = getWltpValues(consumption.fuel, engineData.hybridPlugin);
140
+ // const costModelProps = getCostModelValues();
140
141
  const dimensionProps = dimensionDetails;
141
142
  const availAbilityProps = availAbilityDetails;
142
143
  const colorAndMaterialProps = colorAndMaterialDetails;
@@ -67,7 +67,11 @@ export const transformDataForDecoratedCar = (car: any) => {
67
67
  maximumWeightCapacity: _get(car, 'sizeVolumeWeight.cargoCapacity', null),
68
68
  tareWeight: _get(car, 'sizeVolumeWeight.emptyWeight', null),
69
69
  bootCapacity: _get(car, 'sizeVolumeWeight.cargoCapacity', null),
70
- capacityLoad: _get(car, 'sizeVolumeWeight.completeCapacity', null)
70
+ capacityLoad: _get(car, 'sizeVolumeWeight.completeCapacity', null),
71
+ wltpCombined: _get(car, 'consumption.wltpCombined', null),
72
+ wltpPowerCombined: _get(car, 'consumption.wltpPowerCombined', null),
73
+ wltpCo2: _get(car, 'consumption.wltpCo2', _get(car, 'environmentEmissions.wltpCo2')),
74
+ pluginHybrid: _get(car, 'engineData.pluginHybrid', null)
71
75
  };
72
76
  };
73
77
 
@@ -137,7 +137,7 @@ const getDecoratedLightProps = (
137
137
  : t('vehicleProps:value.na');
138
138
 
139
139
  if (wltpConsumptionValue && wltpCo2Value) {
140
- return <>{wltpConsumptionValue} - {wltpCo2Value}</>;
140
+ return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
141
141
  }
142
142
 
143
143
  return <>{consumptionValue} <br /> {co2Value}</>;
@@ -153,7 +153,7 @@ const getDecoratedLightProps = (
153
153
  const translatedUnit = t(`cbd:${consumptionUnit}`);
154
154
  const co2 = car.environmentEmissions.co2;
155
155
  const wltpConsumptionPowerCombined = car.consumption.wltpPowerCombined;
156
- const wltpCo2 = car.consumption.wltpCo2;
156
+ const wltpCo2 = car.consumption.wltpCo2 || car.environmentEmissions.wltpCo2;
157
157
 
158
158
  const wltpConsumptionValue = Number.isFinite(wltpConsumptionPowerCombined)
159
159
  ? t('vehicleProps:value.consumptionPower', { consumption: wltpConsumptionPowerCombined.toLocaleString(language), unit: translatedUnit })
@@ -172,7 +172,7 @@ const getDecoratedLightProps = (
172
172
  : t('vehicleProps:value.na');
173
173
 
174
174
  if (wltpConsumptionValue && wltpCo2Value) {
175
- return <>{wltpConsumptionValue} - {wltpCo2Value}</>;
175
+ return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
176
176
  }
177
177
 
178
178
  return <>{consumptionValue} <br /> {co2Value} </>;
@@ -201,7 +201,7 @@ const getDecoratedLightProps = (
201
201
  : null;
202
202
 
203
203
  const co2 = car.environmentEmissions.co2;
204
- const wltpCo2 = car.consumption.wltpCo2;
204
+ const wltpCo2 = car.consumption.wltpCo2 || car.environmentEmissions.wltpCo2;
205
205
 
206
206
  const co2Value = Number.isFinite(co2)
207
207
  ? t('vehicleProps:value.co2Combined', { co2: co2.toLocaleString(language) })
@@ -215,7 +215,7 @@ const getDecoratedLightProps = (
215
215
 
216
216
  if (wltpConsumptionCombinedContent && wltpCo2Value) {
217
217
  return <React.Fragment>
218
- {wltpConsumptionPowerCombinedContent && hybridPlugin ? `${wltpConsumptionPowerCombinedContent} - ` : ''}
218
+ {wltpConsumptionPowerCombinedContent && hybridPlugin ? `${wltpConsumptionPowerCombinedContent}, ` : ''}
219
219
  {wltpConsumptionCombinedContent}, {wltpCo2Value}
220
220
  </React.Fragment>
221
221
  }
@@ -238,7 +238,7 @@ const getDecoratedLightProps = (
238
238
  const translatedUnit = t(`cbd:${consumptionUnit}`);
239
239
  const co2 = car.environmentEmissions.co2;
240
240
  const wltpConsumptionCombined = car.consumption.wltpCombined;
241
- const wltpCo2 = car.consumption.wltpCo2;
241
+ const wltpCo2 = car.consumption.wltpCo2 || car.environmentEmissions.wltpCo2;
242
242
 
243
243
  const consumptionValue = Number.isFinite(consumptionHydrogenCombined)
244
244
  ? t('vehicleProps:value.consumptionGas', { consumption: consumptionHydrogenCombined.toLocaleString(language), unit: translatedUnit })
@@ -256,7 +256,7 @@ const getDecoratedLightProps = (
256
256
  : null;
257
257
 
258
258
  if (wltpConsumptionValue && wltpCo2Value) {
259
- return <>{wltpConsumptionValue} - {wltpCo2Value}</>;
259
+ return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
260
260
  }
261
261
 
262
262
  return <>{consumptionValue} <br /> {co2Value}</>;
@@ -272,7 +272,7 @@ const getDecoratedLightProps = (
272
272
  const translatedUnit = t(`cbd:${consumptionUnit}`);
273
273
  const co2 = car.environmentEmissions.co2;
274
274
  const wltpConsumptionCombined = car.consumption.wltpCombined;
275
- const wltpCo2 = car.consumption.wltpCo2;
275
+ const wltpCo2 = car.consumption.wltpCo2 || car.environmentEmissions.wltpCo2;
276
276
 
277
277
  const consumptionValue = Number.isFinite(consumptionGasCombined)
278
278
  ? t('vehicleProps:value.consumptionGas', { consumption: consumptionGasCombined.toLocaleString(language), unit: translatedUnit })
@@ -291,7 +291,7 @@ const getDecoratedLightProps = (
291
291
  : null;
292
292
 
293
293
  if (wltpConsumptionValue && wltpCo2Value) {
294
- return <>{wltpConsumptionValue} - {wltpCo2Value}</>;
294
+ return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
295
295
  }
296
296
 
297
297
  return <>{consumptionValue} <br /> {co2Value}</>;
@@ -8,6 +8,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
10
  import { IDecoratedProp, ICar } from '../types/types';
11
+ import { getFormattedPrice } from '../utils/CommonUtils';
11
12
 
12
13
  const formatDeliveryPeriod = (t: (key: string, options?: object) => string, deliveryPeriod: string) => {
13
14
  const count: number = +DELIVERY_PERIODS_EXTRA.find((period: any) => period.value === deliveryPeriod).label;
@@ -699,7 +700,7 @@ const getDecoratedProps = (
699
700
  : t('vehicleProps:value.na');
700
701
 
701
702
  if (wltpConsumptionValue && wltpCo2Value) {
702
- return <>{wrapValue(wltpConsumptionValue)} - {wrapValue(wltpCo2Value)}</>;
703
+ return <>{wrapValue(wltpConsumptionValue)}, {wrapValue(wltpCo2Value)}</>;
703
704
  }
704
705
 
705
706
  return <>{wrapValue(consumptionValue)} <br /> {wrapValue(co2Value)}</>;
@@ -733,7 +734,7 @@ const getDecoratedProps = (
733
734
  : t('vehicleProps:value.na');
734
735
 
735
736
  if (wltpConsumptionValue && wltpCo2Value) {
736
- return <>{wrapValue(wltpConsumptionValue)} - {wrapValue(wltpCo2Value)}</>;
737
+ return <>{wrapValue(wltpConsumptionValue)}, {wrapValue(wltpCo2Value)}</>;
737
738
  }
738
739
 
739
740
  return <>{wrapValue(consumptionValue)} <br /> {wrapValue(co2Value)}</>;
@@ -767,7 +768,7 @@ const getDecoratedProps = (
767
768
  : null;
768
769
 
769
770
  if (wltpConsumptionValue && wltpCo2Value) {
770
- return <>{wrapValue(wltpConsumptionValue)} - {wrapValue(wltpCo2Value)}</>;
771
+ return <>{wrapValue(wltpConsumptionValue)}, {wrapValue(wltpCo2Value)}</>;
771
772
  }
772
773
 
773
774
  return <>{wrapValue(consumptionValue)} <br /> {wrapValue(co2Value)}</>;
@@ -802,7 +803,7 @@ const getDecoratedProps = (
802
803
  : null;
803
804
 
804
805
  if (wltpConsumptionValue && wltpCo2Value) {
805
- return <>{wrapValue(wltpConsumptionValue)} - {wrapValue(wltpCo2Value)}</>;
806
+ return <>{wrapValue(wltpConsumptionValue)}, {wrapValue(wltpCo2Value)}</>;
806
807
  }
807
808
 
808
809
  return <>{wrapValue(consumptionValue)} <br /> {wrapValue(co2Value)}</>;
@@ -1343,78 +1344,58 @@ const getDecoratedProps = (
1343
1344
  : t('vehicleProps:value.na');
1344
1345
  }
1345
1346
  },
1346
- fuelPrice: {
1347
- title: '',
1347
+ // wltpEnergyCosts: {
1348
+ // title: t('vehicleProps:title.wltpEnergyCosts'),
1349
+ // get value() {
1350
+ // const { fuel } = car.consumption;
1351
+ // const { wltpCombined, wltpPowerCombined, wltpWeightedCombined, wltpWeightedPowerCombined } = car.consumption;
1352
+ // const { hybridPlugin } = car.engineData;
1353
+ // const consumption = {
1354
+ // wltpCombined, wltpPowerCombined, wltpWeightedCombined, wltpWeightedPowerCombined
1355
+ // }
1356
+ // const fuelCost = getFuelPrice(fuel, consumption, hybridPlugin);
1357
+ // return Number.isFinite(fuelCost)
1358
+ // ? t('vehicleProps:value.price', { price: getFormattedPrice(fuelCost, '$,.2f') })
1359
+ // : t('vehicleProps:value.na');
1360
+ // }
1361
+ // },
1362
+ wltpCo2CostsLow: {
1363
+ title: t('vehicleProps:title.wltpCo2LowPrice'),
1348
1364
  get value() {
1349
- return ''
1350
- }
1351
- },
1352
- powerPrice: {
1353
- title: '',
1354
- get value() {
1355
- return ''
1356
- }
1357
- },
1358
- consumptionPriceYear: {
1359
- title: '',
1360
- get value() {
1361
- return ''
1362
- }
1363
- },
1364
- co2CostLowBasePrice: {
1365
- title: '',
1366
- get value() {
1367
- return ''
1368
- }
1369
- },
1370
- co2CostMiddleBasePrice: {
1371
- title: '',
1372
- get value() {
1373
- return ''
1374
- }
1375
- },
1376
- co2CostHighBasePrice: {
1377
- title: '',
1378
- get value() {
1379
- return ''
1380
- }
1381
- },
1382
- co2CostLowAccumulatedPrice: {
1383
- title: '',
1384
- get value() {
1385
- return ''
1386
- }
1387
- },
1388
- co2CostMiddleAccumulatedPrice: {
1389
- title: '',
1390
- get value() {
1391
- return ''
1392
- }
1393
- },
1394
- co2CostHighAccumulatedPrice: {
1395
- title: '',
1396
- get value() {
1397
- return ''
1365
+ const { basePrice } = car.costModel.co2Costs.low;
1366
+ return Number.isFinite(basePrice)
1367
+ ? t('vehicleProps:value.price', { price: getFormattedPrice(basePrice, '$,.2f') })
1368
+ : t('vehicleProps:value.na');
1398
1369
  }
1399
1370
  },
1400
- timeFrameFrom: {
1401
- title: '',
1371
+ wltpCo2CostsMiddle: {
1372
+ title: t('vehicleProps:title.wltpCo2MidPrice'),
1402
1373
  get value() {
1403
- return ''
1374
+ const { basePrice } = car.costModel.co2Costs.middle;
1375
+ return Number.isFinite(basePrice)
1376
+ ? t('vehicleProps:value.price', { price: getFormattedPrice(basePrice, '$,.2f') })
1377
+ : t('vehicleProps:value.na');
1404
1378
  }
1405
1379
  },
1406
- timeFrameT0: {
1407
- title: '',
1380
+ wltpCo2CostsHigh: {
1381
+ title: t('vehicleProps:title.wltpCo2HighPrice'),
1408
1382
  get value() {
1409
- return ''
1383
+ const { basePrice } = car.costModel.co2Costs.high;
1384
+ return Number.isFinite(basePrice)
1385
+ ? t('vehicleProps:value.price', { price: getFormattedPrice(basePrice, '$,.2f') })
1386
+ : t('vehicleProps:value.na');
1410
1387
  }
1411
1388
  },
1412
- consumptionCosts: {
1413
- title: '',
1389
+ wltpCostModelTax: {
1390
+ title: t('vehicleProps:title.wltpVehicleTax'),
1414
1391
  get value() {
1415
- return ''
1392
+ const { tax } = car.costModel;
1393
+ return Number.isFinite(tax)
1394
+ ? t('vehicleProps:value.price', { price: getFormattedPrice(tax, '$,.2f') })
1395
+ : t('vehicleProps:value.na');
1416
1396
  }
1417
1397
  }
1398
+
1418
1399
  };
1419
1400
  return props;
1420
1401
  };
@@ -47,9 +47,7 @@ const environmentPluginHybridWLTP = ['wltpWeightedCombined', 'wltpTotalRange', '
47
47
  'wltpCombined', 'wltpSlow', 'wltpMedium', 'wltpFast', 'wltpVeryFast', 'wltpEnergyEfficiencyClass', 'wltpDischargedEnergyEfficiencyClass'];
48
48
  const environmentElectroBenzinDieselEthanolHybridWLTP = ['wltpCombined', 'wltpCo2', 'wltpSlow', 'wltpMedium', 'wltpFast', 'wltpVeryFast', 'wltpEnergyEfficiencyClass'];
49
49
  const environmentHydrogenWLTP = ['wltpCombined', 'wltpCo2', 'wltpSlow', 'wltpMedium', 'wltpFast', 'wltpVeryFast', 'wltpEnergyEfficiencyClass'];
50
- const costModel = ['fuelPrice', 'powerPrice', 'consumptionPriceYear', 'co2CostLowBasePrice', 'co2CostMiddleBasePrice',
51
- 'co2CostHighBasePrice', 'co2CostLowAccumulatedPrice', 'co2CostMiddleAccumulatedPrice', 'co2CostHighAccumulatedPrice',
52
- 'timeFrameFrom', 'timeFrameT0', 'consumptionCosts',]
50
+ // const costModel = ['wltpEnergyCosts', 'wltpCo2CostsLow',, 'wltpCo2CostsMiddle', 'wltpCo2CostsHigh', 'wltpCostModelTax'];
53
51
 
54
52
  export const engineDetails: IEngineDetails = [
55
53
  {
@@ -357,9 +355,9 @@ export const getWltpValues = (selector: any, hybridPlugin: any = false) => {
357
355
  }, []);
358
356
  };
359
357
 
360
- export const getCostModelValues = () => {
361
- return costModel;
362
- }
358
+ // export const getCostModelValues = () => {
359
+ // return costModel;
360
+ // }
363
361
 
364
362
  export const getOverviewDetails = (selector: any) => {
365
363
  if (Object.keys(filtered(selector)).length === 0) {
@@ -16,6 +16,7 @@ export const vehicleProps = (car?: any, isOfferAvailable: boolean = true) => {
16
16
  const count: number = vehicleOption.deliveryPeriod &&
17
17
  isOfferAvailable &&
18
18
  vehicleOption.deliveryPeriod !== 'selector_unknown' ? +DELIVERY_PERIODS_EXTRA.find((period: any) => period.value === vehicleOption.deliveryPeriod).label : 0;
19
+
19
20
  const monthsTo: number = moment.utc().diff(moment.utc().subtract(count, 'd'), 'M', true);
20
21
  return {
21
22
  ...cbd,
@@ -37,7 +38,9 @@ export const vehicleProps = (car?: any, isOfferAvailable: boolean = true) => {
37
38
  promoSlider: {
38
39
  consumptionCombined: `${vehicleOption.consumptionCombined}l/100km (komb)*`,
39
40
  co2: `${vehicleOption.co2} g CO2/km (komb)*`,
40
- new: 'neu'
41
+ new: 'neu',
42
+ wltpCo2: `${vehicleOption.wltpCo2}g CO2/km (WLTP, komb.)*`,
43
+ wltpConsumptionCombined: `${vehicleOption.consumptionCombined}l/100km`
41
44
  },
42
45
  value: {
43
46
  mileage: `${vehicleOption.mileage} km`,
@@ -80,8 +83,8 @@ export const vehicleProps = (car?: any, isOfferAvailable: boolean = true) => {
80
83
  no: 'Nein',
81
84
  yes: 'Ja',
82
85
  batteryCapacity: `${vehicleOption.batteryCapacity} kWh`,
83
- wltpCo2Combined: `${vehicleOption}g CO2/km (WLTP, comb)*`,
84
- wltpCo2WtdCombined: `${vehicleOption}g CO2/km (WLTP, gew., comb)*`
86
+ wltpCo2Combined: `${vehicleOption.wltpCo2}g CO2/km (WLTP, comb)*`,
87
+ wltpCo2WtdCombined: `${vehicleOption.wltpCo2}g CO2/km (WLTP, gew., comb)*`
85
88
 
86
89
  },
87
90
  title: {