@bytebrand/fe-ui-core 4.7.0 → 4.8.1
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 +2 -1
- package/source/components/AccordionWidget/AccordionWidget.tsx +3 -2
- package/source/components/VehicleSmallCard/VehicleData/VehicleInfo/VehicleInfo.tsx +1 -1
- package/source/framework/DataTransformers.ts +1 -1
- package/source/framework/constants.ts +0 -4
- package/source/framework/types/types.ts +7 -0
- package/source/framework/vehiclesProps/decoratedLightProps.tsx +7 -85
- package/source/framework/vehiclesProps/decoratedProps.tsx +49 -32
- package/source/framework/vehiclesProps/vehicleDetails.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/fe-ui-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "UI components for the auto.de project",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"module": "dist/common.js",
|
|
@@ -13,6 +13,7 @@
|
|
|
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",
|
|
16
17
|
"@bytebrand/fe-histoslider": "3.0.0",
|
|
17
18
|
"@bytebrand/i18n-dictionaries": "^0.7.5",
|
|
18
19
|
"@emotion/react": "^11.9.3",
|
|
@@ -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'))}
|
|
@@ -65,7 +65,7 @@ const VehicleInfo: React.FC<IVehicleInfoProps> = (props) => {
|
|
|
65
65
|
},
|
|
66
66
|
environmentEmissions: {
|
|
67
67
|
co2: environmentEmissions.co2,
|
|
68
|
-
wltpCo2: environmentEmissions.wltpCo2
|
|
68
|
+
wltpCo2: environmentEmissions.wltpCo2
|
|
69
69
|
},
|
|
70
70
|
consumption: {
|
|
71
71
|
fuel: consumption.fuel,
|
|
@@ -68,7 +68,7 @@ export const transformDataForDecoratedCar = (car: any) => {
|
|
|
68
68
|
tareWeight: _get(car, 'sizeVolumeWeight.emptyWeight', null),
|
|
69
69
|
bootCapacity: _get(car, 'sizeVolumeWeight.cargoCapacity', null),
|
|
70
70
|
capacityLoad: _get(car, 'sizeVolumeWeight.completeCapacity', null),
|
|
71
|
-
wltpCo2:
|
|
71
|
+
wltpCo2: _get(car, 'environmentEmissions.wltpCo2', null),
|
|
72
72
|
pluginHybrid: _get(car, 'engineData.pluginHybrid', null),
|
|
73
73
|
wltpCombined: _get(car, 'consumption.wltpCombined', _get(car, 'consumption.wltpWeightedCombined', null)),
|
|
74
74
|
wltpPowerCombined: _get(car, 'consumption.wltpPowerCombined', _get(car, 'consumption.wltpWeightedPowerCombined', null)),
|
|
@@ -19,10 +19,6 @@ export const FIFTEEN = 15; // font-size
|
|
|
19
19
|
export const FOURTEEN = 14;
|
|
20
20
|
export const HUNDRED = 100;
|
|
21
21
|
export const THOUSAND = 1000;
|
|
22
|
-
export const WLTP_COMBINED_DEFAULT = 19.9;
|
|
23
|
-
export const WLTP_POWER_COMBINED_DEFAULT = 29.9;
|
|
24
|
-
export const WLTP_CO2_DEFAULT = 499;
|
|
25
|
-
export const WLTP_CO2_ELECTRIC_DEFAULT = 0;
|
|
26
22
|
|
|
27
23
|
export const CONTAINER_STYLES = {
|
|
28
24
|
display: 'flex',
|
|
@@ -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
|
+
}
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
// import { cbdGearbox, cbdFuel } from './cbdSelectors'
|
|
4
4
|
import { formatMileage } from '../utils/CommonUtils';
|
|
5
5
|
import { formatTimestamp } from '../utils/DateUtils';
|
|
6
|
-
import { DELIVERY_PERIODS_EXTRA
|
|
6
|
+
import { DELIVERY_PERIODS_EXTRA } from '../constants';
|
|
7
7
|
import moment from 'moment';
|
|
8
8
|
import { IDecoratedProp } from '../types/types';
|
|
9
9
|
|
|
@@ -122,7 +122,7 @@ const getDecoratedLightProps = (
|
|
|
122
122
|
const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
|
|
123
123
|
const translatedUnit = t(`cbd:${consumptionUnit}`);
|
|
124
124
|
const wltpConsumptionCombined = car.consumption.wltpCombined || car.consumption.wltpWeightedCombined;
|
|
125
|
-
const wltpCo2 = car.environmentEmissions.wltpCo2
|
|
125
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
126
126
|
const consumptionPowerCombined = car.consumption.consumptionCombined;
|
|
127
127
|
|
|
128
128
|
const co2 = car.environmentEmissions.co2;
|
|
@@ -149,17 +149,6 @@ const getDecoratedLightProps = (
|
|
|
149
149
|
? t('vehicleProps:value.co2Combined', { co2: co2.toLocaleString(language) })
|
|
150
150
|
: t('vehicleProps:value.na');
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
const wltpCo2DefaultWtdValue = t('vehicleProps:value.wltpCo2WtdCombined', { co2: WLTP_CO2_DEFAULT.toLocaleString(language) });
|
|
154
|
-
const wltpCo2DefaultValue = t('vehicleProps:value.wltpCo2Combined', { co2: WLTP_CO2_DEFAULT.toLocaleString(language) });
|
|
155
|
-
const wltpPowerCombinedDefaultValue = t('vehicleProps:value.wltpPowerCombined', { consumption: WLTP_POWER_COMBINED_DEFAULT.toLocaleString(language), unit: translatedUnit });
|
|
156
|
-
const wltpCombinedDefaultValue = t('vehicleProps:value.consumptionCombined', { consumption: WLTP_COMBINED_DEFAULT.toLocaleString(language), unit: translatedUnit });
|
|
157
|
-
|
|
158
|
-
const eightMonthsAgo = new Date();
|
|
159
|
-
eightMonthsAgo.setMonth(eightMonthsAgo.getMonth() - 8); // Subtract 8 months from the current date
|
|
160
|
-
|
|
161
|
-
const registrationDate = new Date(firstRegistration * 1000);
|
|
162
|
-
|
|
163
152
|
const hybridPlugin = car.engineData.hybridPlugin;
|
|
164
153
|
const wltpWeightedPowerCombined = car.consumption.wltpWeightedPowerCombined;
|
|
165
154
|
const wltpWeightedCombined = car.consumption.wltpWeightedCombined;
|
|
@@ -175,13 +164,7 @@ const getDecoratedLightProps = (
|
|
|
175
164
|
{wltpCo2PluginValue}
|
|
176
165
|
</React.Fragment>
|
|
177
166
|
}
|
|
178
|
-
|
|
179
|
-
return <React.Fragment>
|
|
180
|
-
{`${wltpPowerCombinedDefaultValue}, `}
|
|
181
|
-
{`${wltpCombinedDefaultValue}, `}
|
|
182
|
-
{wltpCo2DefaultWtdValue}
|
|
183
|
-
</React.Fragment>
|
|
184
|
-
}
|
|
167
|
+
|
|
185
168
|
return Number.isFinite(consumptionCombined) || Number.isFinite(consumptionPowerCombined)
|
|
186
169
|
? <React.Fragment>
|
|
187
170
|
{consumptionPowerCombined ? consumptionPowerCombinedContent : t('vehicleProps:value.na')} <br />{consumptionValue} <br /> {co2Value}
|
|
@@ -194,10 +177,6 @@ const getDecoratedLightProps = (
|
|
|
194
177
|
return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
|
|
195
178
|
}
|
|
196
179
|
|
|
197
|
-
if ((!wltpConsumptionValue || !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
198
|
-
return <>{wltpCombinedDefaultValue} {wltpCo2DefaultValue}</>;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
180
|
return <>{consumptionValue} <br /> {co2Value}</>;
|
|
202
181
|
}
|
|
203
182
|
},
|
|
@@ -211,15 +190,7 @@ const getDecoratedLightProps = (
|
|
|
211
190
|
const translatedUnit = t(`cbd:${consumptionUnit}`);
|
|
212
191
|
const co2 = car.environmentEmissions.co2;
|
|
213
192
|
const wltpConsumptionPowerCombined = car.consumption.wltpPowerCombined || car.consumption.wltpWeightedPowerCombined;
|
|
214
|
-
const wltpCo2 = car.
|
|
215
|
-
|
|
216
|
-
const wltpCo2ElectricDefaultValue = t('vehicleProps:value.wltpCo2Combined', { co2: WLTP_CO2_ELECTRIC_DEFAULT.toLocaleString(language) });
|
|
217
|
-
const wltpPowerCombinedDefaultValue = t('vehicleProps:value.wltpPowerCombined', { consumption: WLTP_POWER_COMBINED_DEFAULT.toLocaleString(language), unit: translatedUnit });
|
|
218
|
-
|
|
219
|
-
const eightMonthsAgo = new Date();
|
|
220
|
-
eightMonthsAgo.setMonth(eightMonthsAgo.getMonth() - 8); // Subtract 8 months from the current date
|
|
221
|
-
|
|
222
|
-
const registrationDate = new Date(firstRegistration * 1000);
|
|
193
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
223
194
|
|
|
224
195
|
const wltpConsumptionValue = Number.isFinite(wltpConsumptionPowerCombined)
|
|
225
196
|
? t('vehicleProps:value.wltpPowerCombined', { consumption: wltpConsumptionPowerCombined.toLocaleString(language), unit: translatedUnit })
|
|
@@ -241,10 +212,6 @@ const getDecoratedLightProps = (
|
|
|
241
212
|
return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
|
|
242
213
|
}
|
|
243
214
|
|
|
244
|
-
if ((!wltpConsumptionValue && !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
245
|
-
return <>{wltpPowerCombinedDefaultValue}, {wltpCo2ElectricDefaultValue}</>;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
215
|
return <>{consumptionValue} <br /> {co2Value} </>;
|
|
249
216
|
}
|
|
250
217
|
},
|
|
@@ -277,7 +244,7 @@ const getDecoratedLightProps = (
|
|
|
277
244
|
: null;
|
|
278
245
|
|
|
279
246
|
const co2 = car.environmentEmissions.co2;
|
|
280
|
-
const wltpCo2 = car.
|
|
247
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
281
248
|
|
|
282
249
|
const co2Value = Number.isFinite(co2)
|
|
283
250
|
? t('vehicleProps:value.co2Combined', { co2: co2.toLocaleString(language) })
|
|
@@ -291,15 +258,6 @@ const getDecoratedLightProps = (
|
|
|
291
258
|
? t('vehicleProps:value.wltpCo2WtdCombined', { co2: wltpCo2.toLocaleString(language), unit: translatedUnit })
|
|
292
259
|
: null;
|
|
293
260
|
|
|
294
|
-
const wltpCo2DefaultWtdValue = t('vehicleProps:value.wltpCo2WtdCombined', { co2: WLTP_CO2_DEFAULT.toLocaleString(language) });
|
|
295
|
-
const wltpCo2DefaultValue = t('vehicleProps:value.wltpCo2Combined', { co2: WLTP_CO2_DEFAULT.toLocaleString(language) });
|
|
296
|
-
const wltpPowerCombinedDefaultValue = t('vehicleProps:value.wltpPowerCombined', { consumption: WLTP_POWER_COMBINED_DEFAULT.toLocaleString(language), unit: translatedUnit });
|
|
297
|
-
const wltpCombinedDefaultValue = t('vehicleProps:value.consumptionCombined', { consumption: WLTP_COMBINED_DEFAULT.toLocaleString(language), unit: translatedUnit });
|
|
298
|
-
|
|
299
|
-
const eightMonthsAgo = new Date();
|
|
300
|
-
eightMonthsAgo.setMonth(eightMonthsAgo.getMonth() - 8); // Subtract 8 months from the current date
|
|
301
|
-
const registrationDate = new Date(firstRegistration * 1000);
|
|
302
|
-
|
|
303
261
|
const hybridPlugin = car.engineData.hybridPlugin;
|
|
304
262
|
|
|
305
263
|
if (hybridPlugin) {
|
|
@@ -310,13 +268,6 @@ const getDecoratedLightProps = (
|
|
|
310
268
|
{wltpCo2PluginValue}
|
|
311
269
|
</React.Fragment>
|
|
312
270
|
}
|
|
313
|
-
if ((!wltpWeightedPowerCombinedContent || !wltpWeightedCombinedContent || !wltpCo2PluginValue) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
314
|
-
return <React.Fragment>
|
|
315
|
-
{`${wltpPowerCombinedDefaultValue}, `}
|
|
316
|
-
{`${wltpCombinedDefaultValue}, `}
|
|
317
|
-
{wltpCo2DefaultWtdValue}
|
|
318
|
-
</React.Fragment>
|
|
319
|
-
}
|
|
320
271
|
}
|
|
321
272
|
|
|
322
273
|
if (wltpConsumptionPowerCombinedContent && wltpConsumptionCombinedContent && wltpCo2Value) {
|
|
@@ -327,13 +278,6 @@ const getDecoratedLightProps = (
|
|
|
327
278
|
</React.Fragment>
|
|
328
279
|
}
|
|
329
280
|
|
|
330
|
-
if ((!wltpConsumptionPowerCombinedContent || !wltpConsumptionCombinedContent || !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
331
|
-
return <React.Fragment>
|
|
332
|
-
{`${wltpCombinedDefaultValue}, `}
|
|
333
|
-
{wltpCo2DefaultValue}
|
|
334
|
-
</React.Fragment>
|
|
335
|
-
}
|
|
336
|
-
|
|
337
281
|
return Number.isFinite(consumptionCombined) || Number.isFinite(consumptionPowerCombined)
|
|
338
282
|
? <React.Fragment>
|
|
339
283
|
{consumptionPowerCombined ? consumptionPowerCombinedContent : t('vehicleProps:value.na')} <br />{consumptionCombinedContent} <br /> {co2Value}
|
|
@@ -352,7 +296,7 @@ const getDecoratedLightProps = (
|
|
|
352
296
|
const translatedUnit = t(`cbd:${consumptionUnit}`);
|
|
353
297
|
const co2 = car.environmentEmissions.co2;
|
|
354
298
|
const wltpConsumptionCombined = car.consumption.wltpCombined;
|
|
355
|
-
const wltpCo2 = car.
|
|
299
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
356
300
|
|
|
357
301
|
const consumptionValue = Number.isFinite(consumptionHydrogenCombined)
|
|
358
302
|
? t('vehicleProps:value.consumptionGas', { consumption: consumptionHydrogenCombined.toLocaleString(language), unit: translatedUnit })
|
|
@@ -369,21 +313,10 @@ const getDecoratedLightProps = (
|
|
|
369
313
|
? t('vehicleProps:value.wltpCo2Combined', { co2: wltpCo2.toLocaleString(language) })
|
|
370
314
|
: null;
|
|
371
315
|
|
|
372
|
-
const wltpCo2DefaultValue = t('vehicleProps:value.wltpCo2Combined', { co2: WLTP_CO2_DEFAULT.toLocaleString(language) });
|
|
373
|
-
const wltpCombinedDefaultValue = t('vehicleProps:value.wltpCombinedGas', { consumption: WLTP_COMBINED_DEFAULT.toLocaleString(language), unit: translatedUnit });
|
|
374
|
-
|
|
375
|
-
const eightMonthsAgo = new Date();
|
|
376
|
-
eightMonthsAgo.setMonth(eightMonthsAgo.getMonth() - 8); // Subtract 8 months from the current date
|
|
377
|
-
const registrationDate = new Date(firstRegistration * 1000);
|
|
378
|
-
|
|
379
316
|
if (wltpConsumptionValue && wltpCo2Value) {
|
|
380
317
|
return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
|
|
381
318
|
}
|
|
382
319
|
|
|
383
|
-
if ((!wltpConsumptionValue || !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
384
|
-
return <>{wltpCombinedDefaultValue}, {wltpCo2DefaultValue}</>;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
320
|
return <>{consumptionValue} <br /> {co2Value}</>;
|
|
388
321
|
}
|
|
389
322
|
},
|
|
@@ -397,7 +330,7 @@ const getDecoratedLightProps = (
|
|
|
397
330
|
const translatedUnit = t(`cbd:${consumptionUnit}`);
|
|
398
331
|
const co2 = car.environmentEmissions.co2;
|
|
399
332
|
const wltpConsumptionCombined = car.consumption.wltpCombined;
|
|
400
|
-
const wltpCo2 = car.
|
|
333
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
401
334
|
|
|
402
335
|
const consumptionValue = Number.isFinite(consumptionGasCombined)
|
|
403
336
|
? t('vehicleProps:value.consumptionGas', { consumption: consumptionGasCombined.toLocaleString(language), unit: translatedUnit })
|
|
@@ -415,21 +348,10 @@ const getDecoratedLightProps = (
|
|
|
415
348
|
? t('vehicleProps:value.wltpCo2Combined', { co2: wltpCo2.toLocaleString(language) })
|
|
416
349
|
: null;
|
|
417
350
|
|
|
418
|
-
const wltpCo2DefaultValue = t('vehicleProps:value.wltpCo2Combined', { co2: WLTP_CO2_DEFAULT.toLocaleString(language) });
|
|
419
|
-
const wltpCombinedDefaultValue = t('vehicleProps:value.wltpCombinedGas', { consumption: WLTP_COMBINED_DEFAULT.toLocaleString(language), unit: translatedUnit });
|
|
420
|
-
|
|
421
|
-
const eightMonthsAgo = new Date();
|
|
422
|
-
eightMonthsAgo.setMonth(eightMonthsAgo.getMonth() - 8); // Subtract 8 months from the current date
|
|
423
|
-
const registrationDate = new Date(firstRegistration * 1000);
|
|
424
|
-
|
|
425
351
|
if (wltpConsumptionValue && wltpCo2Value) {
|
|
426
352
|
return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
|
|
427
353
|
}
|
|
428
354
|
|
|
429
|
-
if ((!wltpConsumptionValue || !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
430
|
-
return <>{wltpCombinedDefaultValue}, {wltpCo2DefaultValue}</>;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
355
|
return <>{consumptionValue} <br /> {co2Value}</>;
|
|
434
356
|
}
|
|
435
357
|
},
|
|
@@ -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 { getVehicleTax, getFuelPrice, co2DefaultCostsLow, co2DefaultCostsMedium, co2DefaultCostsHigh, getBaseFuelPrice, getCo2Price } from '@bytebrand/fe-financing';
|
|
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,7 @@ 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'),
|
|
75
76
|
): IDecoratedProp => {
|
|
76
77
|
const {
|
|
77
78
|
offer = {},
|
|
@@ -1168,7 +1169,7 @@ const getDecoratedProps = (
|
|
|
1168
1169
|
wltpCo2Discharged: {
|
|
1169
1170
|
title: t('vehicleProps:title.wltpCo2Discharged'),
|
|
1170
1171
|
get value() {
|
|
1171
|
-
const wltpCo2 = car.environmentEmissions.
|
|
1172
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
1172
1173
|
const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
|
|
1173
1174
|
const translatedUnit = t(`cbd:${consumptionUnit}`);
|
|
1174
1175
|
return Number.isFinite(wltpCo2)
|
|
@@ -1538,52 +1539,60 @@ const getDecoratedProps = (
|
|
|
1538
1539
|
: t('vehicleProps:value.na');
|
|
1539
1540
|
}
|
|
1540
1541
|
},
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1542
|
+
wltpEnergyCosts: {
|
|
1543
|
+
title: t('vehicleProps:title.wltpEnergyCosts'),
|
|
1544
|
+
get value() {
|
|
1545
|
+
const { fuel } = car.consumption;
|
|
1546
|
+
const { wltpCombined, wltpPowerCombined, wltpWeightedCombined, wltpWeightedPowerCombined } = car.consumption;
|
|
1547
|
+
const { hybridPlugin } = car.engineData;
|
|
1548
|
+
const consumption = {
|
|
1549
|
+
wltpCombined, wltpPowerCombined, wltpWeightedCombined, wltpWeightedPowerCombined
|
|
1550
|
+
}
|
|
1551
|
+
const fuelCost = getFuelPrice(fuel, consumption, hybridPlugin);
|
|
1552
|
+
return Number.isFinite(fuelCost)
|
|
1553
|
+
? t('vehicleProps:value.pricePerYear', { price: getFormattedPrice(fuelCost, '$,.2f') })
|
|
1554
|
+
: t('vehicleProps:value.na');
|
|
1555
|
+
}
|
|
1556
|
+
},
|
|
1556
1557
|
wltpCo2CostsLow: {
|
|
1557
|
-
title: t('vehicleProps:title.wltpCo2LowPrice'),
|
|
1558
|
+
title: t('vehicleProps:title.wltpCo2LowPrice', { price: co2DefaultCostsLow }),
|
|
1558
1559
|
get value() {
|
|
1559
|
-
const
|
|
1560
|
-
|
|
1561
|
-
|
|
1560
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
1561
|
+
const { co2PriceLow } = getCo2Price(wltpCo2);
|
|
1562
|
+
return Number.isFinite(co2PriceLow)
|
|
1563
|
+
? t('vehicleProps:value.wltpCo2Price', { price: getFormattedPrice(co2PriceLow, '$,.2f') })
|
|
1562
1564
|
: t('vehicleProps:value.na');
|
|
1563
1565
|
}
|
|
1564
1566
|
},
|
|
1565
1567
|
wltpCo2CostsMiddle: {
|
|
1566
|
-
title: t('vehicleProps:title.wltpCo2MidPrice'),
|
|
1568
|
+
title: t('vehicleProps:title.wltpCo2MidPrice', { price: co2DefaultCostsMedium }),
|
|
1567
1569
|
get value() {
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
|
|
1570
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
1571
|
+
const { co2PriceMedium } = getCo2Price(wltpCo2);
|
|
1572
|
+
return Number.isFinite(co2PriceMedium)
|
|
1573
|
+
? t('vehicleProps:value.wltpCo2Price', { price: getFormattedPrice(co2PriceMedium, '$,.2f') })
|
|
1571
1574
|
: t('vehicleProps:value.na');
|
|
1572
1575
|
}
|
|
1573
1576
|
},
|
|
1574
1577
|
wltpCo2CostsHigh: {
|
|
1575
|
-
title: t('vehicleProps:title.wltpCo2HighPrice'),
|
|
1578
|
+
title: t('vehicleProps:title.wltpCo2HighPrice', { price: co2DefaultCostsHigh }),
|
|
1576
1579
|
get value() {
|
|
1577
|
-
const
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
1581
|
+
const { co2PriceHigh } = getCo2Price(wltpCo2);
|
|
1582
|
+
return Number.isFinite(co2PriceHigh)
|
|
1583
|
+
? t('vehicleProps:value.wltpCo2Price', { price: getFormattedPrice(co2PriceHigh, '$,.2f') })
|
|
1580
1584
|
: t('vehicleProps:value.na');
|
|
1581
1585
|
}
|
|
1582
1586
|
},
|
|
1583
1587
|
powerPrice: {
|
|
1584
1588
|
title: t('vehicleProps:title.powerPrice'),
|
|
1585
1589
|
get value() {
|
|
1586
|
-
const
|
|
1590
|
+
const fuel = car.consumption.fuel;
|
|
1591
|
+
const { hybridPlugin } = car.engineData;
|
|
1592
|
+
|
|
1593
|
+
const basePowerPrice = getBaseFuelPrice(fuel, hybridPlugin).powerPrice;
|
|
1594
|
+
const powerPrice = car.costModel.powerPrice ? car.costModel.powerPrice : basePowerPrice;
|
|
1595
|
+
|
|
1587
1596
|
return Number.isFinite(powerPrice)
|
|
1588
1597
|
? t('vehicleProps:value.powerPrice', { price: getFormattedPrice(powerPrice, '$,.2f') })
|
|
1589
1598
|
: t('vehicleProps:value.na');
|
|
@@ -1592,7 +1601,12 @@ const getDecoratedProps = (
|
|
|
1592
1601
|
fuelPrice: {
|
|
1593
1602
|
title: t('vehicleProps:title.fuelPrice'),
|
|
1594
1603
|
get value() {
|
|
1595
|
-
const
|
|
1604
|
+
const fuel = car.consumption.fuel;
|
|
1605
|
+
const { hybridPlugin } = car.engineData;
|
|
1606
|
+
|
|
1607
|
+
const baseFuelPrice = getBaseFuelPrice(fuel, hybridPlugin);
|
|
1608
|
+
|
|
1609
|
+
const fuelPrice = car.costModel.fuelPrice ? car.costModel.fuelPrice : baseFuelPrice;
|
|
1596
1610
|
return Number.isFinite(fuelPrice)
|
|
1597
1611
|
? t('vehicleProps:value.fuelPrice', { price: getFormattedPrice(fuelPrice, '$,.2f') })
|
|
1598
1612
|
: t('vehicleProps:value.na');
|
|
@@ -1610,7 +1624,10 @@ const getDecoratedProps = (
|
|
|
1610
1624
|
wltpCostModelTax: {
|
|
1611
1625
|
title: t('vehicleProps:title.wltpVehicleTax'),
|
|
1612
1626
|
get value() {
|
|
1613
|
-
const
|
|
1627
|
+
const cubicCapacity = car.engineData.cubicCapacity;
|
|
1628
|
+
const fuel = car.consumption.fuel;
|
|
1629
|
+
const wltpCo2 = car.environmentEmissions.wltpCo2;
|
|
1630
|
+
const tax = car.costModel.tax ? car.costModel.tax : getVehicleTax(fuel, cubicCapacity, wltpCo2, firstRegistration);
|
|
1614
1631
|
return Number.isFinite(tax)
|
|
1615
1632
|
? t('vehicleProps:value.price', { price: getFormattedPrice(tax, '$,.2f') })
|
|
1616
1633
|
: 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', 'wltpCo2CostsMiddle', 'wltpCo2CostsLow', '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) {
|