@bytebrand/fe-ui-core 4.7.0 → 4.8.0
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
|
@@ -4,7 +4,7 @@ import { Visible } from 'react-grid-system';
|
|
|
4
4
|
import _get from 'lodash/get';
|
|
5
5
|
|
|
6
6
|
import { getPowerLabel } from '../../framework/vehiclesProps/decoratedProps';
|
|
7
|
-
import { getVehicleDetails, getOverviewDetails, dimensionDetails, availAbilityDetails, colorAndMaterialDetails, getWltpValues } from '../../framework/vehiclesProps/vehicleDetails';
|
|
7
|
+
import { getVehicleDetails, getOverviewDetails, dimensionDetails, availAbilityDetails, colorAndMaterialDetails, getWltpValues, getCostModelValues } from '../../framework/vehiclesProps/vehicleDetails';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
IEquipmentProps,
|
|
@@ -137,7 +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
|
-
|
|
140
|
+
const costModelProps = getCostModelValues();
|
|
141
141
|
const dimensionProps = dimensionDetails;
|
|
142
142
|
const availAbilityProps = availAbilityDetails;
|
|
143
143
|
const colorAndMaterialProps = colorAndMaterialDetails;
|
|
@@ -148,6 +148,7 @@ class AccordionWidget extends React.Component<IAccardionSectionProps, IAccardion
|
|
|
148
148
|
{this.renderTable(decoratedProps, dimensionProps, t('accordion.tableDimensions'))}
|
|
149
149
|
{this.renderTable(decoratedProps, wltpProps, t('accordion.tableEnvironmentWLTP'))}
|
|
150
150
|
{this.renderTable(decoratedProps, environmentProps, t('accordion.tableEnvironment'))}
|
|
151
|
+
{this.renderTable(decoratedProps, costModelProps, t('accordion.tableCostsPerYear'))}
|
|
151
152
|
{this.renderTable(decoratedProps, availAbilityProps, t('accordion.tableAvailability'))}
|
|
152
153
|
{this.renderTable(decoratedProps, colorAndMaterialProps, t('accordion.tableMaterial'))}
|
|
153
154
|
{this.renderExtendTable(carEquipment, t('accordion.tableEqipment'))}
|
|
@@ -349,3 +349,10 @@ export interface ITFunction {
|
|
|
349
349
|
<T = string>(key: string, options?: object): T;
|
|
350
350
|
<T = string>(keys: string[], options?: object): T;
|
|
351
351
|
}
|
|
352
|
+
|
|
353
|
+
export interface IWltpConsumption {
|
|
354
|
+
wltpCombined?: number;
|
|
355
|
+
wltpPowerCombined?: number;
|
|
356
|
+
wltpWeightedCombined?: number;
|
|
357
|
+
wltpWeightedPowerCombined?: number;
|
|
358
|
+
}
|
|
@@ -9,6 +9,7 @@ import { EMISSION_STICKERS_ICONS, WP_EMISSION_STICKERS_ICONS } from '../constant
|
|
|
9
9
|
import { DELIVERY_PERIODS_EXTRA } from '../constants';
|
|
10
10
|
import { IDecoratedProp, ICar } from '../types/types';
|
|
11
11
|
import { getFormattedPrice } from '../utils/CommonUtils';
|
|
12
|
+
import { IWltpConsumption } from '../types/types';
|
|
12
13
|
|
|
13
14
|
const formatDeliveryPeriod = (t: (key: string, options?: object) => string, deliveryPeriod: string) => {
|
|
14
15
|
const count: number = +DELIVERY_PERIODS_EXTRA.find((period: any) => period.value === deliveryPeriod).label;
|
|
@@ -71,7 +72,9 @@ const getDecoratedProps = (
|
|
|
71
72
|
car: ICar, // @TODO should have a proper interface
|
|
72
73
|
t: (key: string, options?: object) => string,
|
|
73
74
|
language: string = 'en',
|
|
74
|
-
simplifiedLabels: boolean = false // shortened labels for repsonsive layout (see 'power')
|
|
75
|
+
simplifiedLabels: boolean = false, // shortened labels for repsonsive layout (see 'power'),
|
|
76
|
+
getFuelPrice?: (fuelSelector: string, consumption: IWltpConsumption, hybridPlugin?: boolean) => number,
|
|
77
|
+
getVehicleTax?: (fuelType: string, cubicCapacity: number, co2: number, firstRegistration: number) => number
|
|
75
78
|
): IDecoratedProp => {
|
|
76
79
|
const {
|
|
77
80
|
offer = {},
|
|
@@ -1538,25 +1541,25 @@ const getDecoratedProps = (
|
|
|
1538
1541
|
: t('vehicleProps:value.na');
|
|
1539
1542
|
}
|
|
1540
1543
|
},
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1544
|
+
wltpEnergyCosts: {
|
|
1545
|
+
title: t('vehicleProps:title.wltpEnergyCosts'),
|
|
1546
|
+
get value() {
|
|
1547
|
+
const { fuel } = car.consumption;
|
|
1548
|
+
const { wltpCombined, wltpPowerCombined, wltpWeightedCombined, wltpWeightedPowerCombined } = car.consumption;
|
|
1549
|
+
const { hybridPlugin } = car.engineData;
|
|
1550
|
+
const consumption = {
|
|
1551
|
+
wltpCombined, wltpPowerCombined, wltpWeightedCombined, wltpWeightedPowerCombined
|
|
1552
|
+
}
|
|
1553
|
+
const fuelCost = getFuelPrice(fuel, consumption, hybridPlugin);
|
|
1554
|
+
return Number.isFinite(fuelCost)
|
|
1555
|
+
? t('vehicleProps:value.price', { price: getFormattedPrice(fuelCost, '$,.2f') })
|
|
1556
|
+
: t('vehicleProps:value.na');
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1556
1559
|
wltpCo2CostsLow: {
|
|
1557
1560
|
title: t('vehicleProps:title.wltpCo2LowPrice'),
|
|
1558
1561
|
get value() {
|
|
1559
|
-
const
|
|
1562
|
+
const basePrice = car.costModel.co2Costs.low.basePrice || 30;
|
|
1560
1563
|
return Number.isFinite(basePrice)
|
|
1561
1564
|
? t('vehicleProps:value.price', { price: getFormattedPrice(basePrice, '$,.2f') })
|
|
1562
1565
|
: t('vehicleProps:value.na');
|
|
@@ -1565,7 +1568,7 @@ const getDecoratedProps = (
|
|
|
1565
1568
|
wltpCo2CostsMiddle: {
|
|
1566
1569
|
title: t('vehicleProps:title.wltpCo2MidPrice'),
|
|
1567
1570
|
get value() {
|
|
1568
|
-
const
|
|
1571
|
+
const basePrice = car.costModel.co2Costs.middle.basePrice || 50;
|
|
1569
1572
|
return Number.isFinite(basePrice)
|
|
1570
1573
|
? t('vehicleProps:value.price', { price: getFormattedPrice(basePrice, '$,.2f') })
|
|
1571
1574
|
: t('vehicleProps:value.na');
|
|
@@ -1574,7 +1577,7 @@ const getDecoratedProps = (
|
|
|
1574
1577
|
wltpCo2CostsHigh: {
|
|
1575
1578
|
title: t('vehicleProps:title.wltpCo2HighPrice'),
|
|
1576
1579
|
get value() {
|
|
1577
|
-
const
|
|
1580
|
+
const basePrice = car.costModel.co2Costs.high.basePrice || 70;
|
|
1578
1581
|
return Number.isFinite(basePrice)
|
|
1579
1582
|
? t('vehicleProps:value.price', { price: getFormattedPrice(basePrice, '$,.2f') })
|
|
1580
1583
|
: t('vehicleProps:value.na');
|
|
@@ -1592,7 +1595,22 @@ const getDecoratedProps = (
|
|
|
1592
1595
|
fuelPrice: {
|
|
1593
1596
|
title: t('vehicleProps:title.fuelPrice'),
|
|
1594
1597
|
get value() {
|
|
1595
|
-
const
|
|
1598
|
+
const fuel = car.consumption.fuel;
|
|
1599
|
+
const wltpCombined = car.consumption.wltpCombined || car.consumption.wltpWeightedCombined;
|
|
1600
|
+
const wltpPowerCombined = car.consumption.wltpPowerCombined || car.consumption.wltpWeightedPowerCombined;
|
|
1601
|
+
const wltpWeightedCombined = car.consumption.wltpWeightedCombined;
|
|
1602
|
+
const wltpWeightedPowerCombined = car.consumption.wltpWeightedPowerCombined;
|
|
1603
|
+
|
|
1604
|
+
const wltpConsumption = {
|
|
1605
|
+
wltpCombined,
|
|
1606
|
+
wltpPowerCombined,
|
|
1607
|
+
wltpWeightedCombined,
|
|
1608
|
+
wltpWeightedPowerCombined
|
|
1609
|
+
};
|
|
1610
|
+
|
|
1611
|
+
const { hybridPlugin } = car.engineData;
|
|
1612
|
+
|
|
1613
|
+
const fuelPrice = car.costModel.fuelPrice ? car.costModel.fuelPrice : getFuelPrice(fuel, wltpConsumption, hybridPlugin);
|
|
1596
1614
|
return Number.isFinite(fuelPrice)
|
|
1597
1615
|
? t('vehicleProps:value.fuelPrice', { price: getFormattedPrice(fuelPrice, '$,.2f') })
|
|
1598
1616
|
: t('vehicleProps:value.na');
|
|
@@ -1610,7 +1628,10 @@ const getDecoratedProps = (
|
|
|
1610
1628
|
wltpCostModelTax: {
|
|
1611
1629
|
title: t('vehicleProps:title.wltpVehicleTax'),
|
|
1612
1630
|
get value() {
|
|
1613
|
-
const
|
|
1631
|
+
const cubicCapacity = car.engineData.cubicCapacity;
|
|
1632
|
+
const fuel = car.consumption.fuel;
|
|
1633
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
1634
|
+
const tax = car.costModel.tax ? car.costModel.tax : getVehicleTax(fuel, cubicCapacity, wltpCo2, firstRegistration);
|
|
1614
1635
|
return Number.isFinite(tax)
|
|
1615
1636
|
? t('vehicleProps:value.price', { price: getFormattedPrice(tax, '$,.2f') })
|
|
1616
1637
|
: t('vehicleProps:value.na');
|
|
@@ -48,7 +48,7 @@ const environmentPluginHybridWLTP = ['wltpWeightedCombined', 'wltpTotalRange', '
|
|
|
48
48
|
'fuelPrice', 'powerPrice', 'consumptionPriceYear', 'wltpEnergyEfficiencyClass'];
|
|
49
49
|
const environmentElectroBenzinDieselEthanolHybridWLTP = ['wltpCombined', 'wltpCo2', 'wltpSlow', 'wltpMedium', 'wltpFast', 'wltpVeryFast', 'fuelPrice', 'consumptionPriceYear', 'wltpEnergyEfficiencyClass'];
|
|
50
50
|
const environmentHydrogenWLTP = ['wltpCombinedGas', 'wltpCo2', 'wltpSlowGas', 'wltpMediumGas', 'wltpFastGas', 'wltpVeryFastGas', 'fuelPrice', 'consumptionPriceYear', 'wltpEnergyEfficiencyClass'];
|
|
51
|
-
|
|
51
|
+
const costModel = ['wltpEnergyCosts', 'wltpCo2CostsLow', 'wltpCo2CostsMiddle', 'wltpCo2CostsHigh', 'wltpCostModelTax'];
|
|
52
52
|
|
|
53
53
|
export const engineDetails: IEngineDetails = [
|
|
54
54
|
{
|
|
@@ -356,9 +356,9 @@ export const getWltpValues = (selector: any, hybridPlugin: any = false) => {
|
|
|
356
356
|
}, []);
|
|
357
357
|
};
|
|
358
358
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
359
|
+
export const getCostModelValues = () => {
|
|
360
|
+
return costModel;
|
|
361
|
+
}
|
|
362
362
|
|
|
363
363
|
export const getOverviewDetails = (selector: any) => {
|
|
364
364
|
if (Object.keys(filtered(selector)).length === 0) {
|