@bytebrand/fe-ui-core 4.6.13 → 4.7.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
|
@@ -18,6 +18,12 @@ export const FIVE = 5; // tab index
|
|
|
18
18
|
export const FIFTEEN = 15; // font-size
|
|
19
19
|
export const FOURTEEN = 14;
|
|
20
20
|
export const HUNDRED = 100;
|
|
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
|
+
|
|
21
27
|
export const CONTAINER_STYLES = {
|
|
22
28
|
display: 'flex',
|
|
23
29
|
flexDirection: 'row',
|
|
@@ -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 } from '../constants';
|
|
6
|
+
import { DELIVERY_PERIODS_EXTRA, WLTP_COMBINED_DEFAULT, WLTP_CO2_DEFAULT, WLTP_CO2_ELECTRIC_DEFAULT, WLTP_POWER_COMBINED_DEFAULT } from '../constants';
|
|
7
7
|
import moment from 'moment';
|
|
8
8
|
import { IDecoratedProp } from '../types/types';
|
|
9
9
|
|
|
@@ -123,6 +123,7 @@ const getDecoratedLightProps = (
|
|
|
123
123
|
const translatedUnit = t(`cbd:${consumptionUnit}`);
|
|
124
124
|
const wltpConsumptionCombined = car.consumption.wltpCombined || car.consumption.wltpWeightedCombined;
|
|
125
125
|
const wltpCo2 = car.environmentEmissions.wltpCo2 || car.consumption.wltpCo2;
|
|
126
|
+
const consumptionPowerCombined = car.consumption.consumptionCombined;
|
|
126
127
|
|
|
127
128
|
const co2 = car.environmentEmissions.co2;
|
|
128
129
|
|
|
@@ -142,10 +143,23 @@ const getDecoratedLightProps = (
|
|
|
142
143
|
? t('vehicleProps:value.consumptionCombined', { consumption: consumptionCombined.toLocaleString(language), unit: translatedUnit })
|
|
143
144
|
: t('vehicleProps:value.na');
|
|
144
145
|
|
|
146
|
+
const consumptionPowerCombinedContent = t('vehicleProps:value.consumptionPowerCombined', { consumption: consumptionPowerCombined.toLocaleString(language), unit: translatedUnit });
|
|
147
|
+
|
|
145
148
|
const co2Value = Number.isFinite(co2)
|
|
146
149
|
? t('vehicleProps:value.co2Combined', { co2: co2.toLocaleString(language) })
|
|
147
150
|
: t('vehicleProps:value.na');
|
|
148
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
|
+
|
|
149
163
|
const hybridPlugin = car.engineData.hybridPlugin;
|
|
150
164
|
const wltpWeightedPowerCombined = car.consumption.wltpWeightedPowerCombined;
|
|
151
165
|
const wltpWeightedCombined = car.consumption.wltpWeightedCombined;
|
|
@@ -154,17 +168,36 @@ const getDecoratedLightProps = (
|
|
|
154
168
|
const wltpWeightedCombinedContent = wltpWeightedCombined ? t('vehicleProps:value.wltpCombined', { consumption: wltpWeightedCombined.toLocaleString(language), unit: translatedUnit }) : null;
|
|
155
169
|
|
|
156
170
|
if (hybridPlugin) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
171
|
+
if (wltpWeightedPowerCombinedContent && wltpWeightedCombinedContent && wltpCo2PluginValue) {
|
|
172
|
+
return <React.Fragment>
|
|
173
|
+
{`${wltpWeightedPowerCombinedContent}, `}
|
|
174
|
+
{`${wltpWeightedCombinedContent}, `}
|
|
175
|
+
{wltpCo2PluginValue}
|
|
176
|
+
</React.Fragment>
|
|
177
|
+
}
|
|
178
|
+
if ((!wltpWeightedPowerCombinedContent || !wltpWeightedCombinedContent || !wltpCo2PluginValue) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
179
|
+
return <React.Fragment>
|
|
180
|
+
{`${wltpPowerCombinedDefaultValue}, `}
|
|
181
|
+
{`${wltpCombinedDefaultValue}, `}
|
|
182
|
+
{wltpCo2DefaultWtdValue}
|
|
183
|
+
</React.Fragment>
|
|
184
|
+
}
|
|
185
|
+
return Number.isFinite(consumptionCombined) || Number.isFinite(consumptionPowerCombined)
|
|
186
|
+
? <React.Fragment>
|
|
187
|
+
{consumptionPowerCombined ? consumptionPowerCombinedContent : t('vehicleProps:value.na')} <br />{consumptionValue} <br /> {co2Value}
|
|
188
|
+
</React.Fragment>
|
|
189
|
+
: t('vehicleProps:value.na');
|
|
190
|
+
|
|
162
191
|
}
|
|
163
192
|
|
|
164
193
|
if (wltpConsumptionValue && wltpCo2Value) {
|
|
165
194
|
return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
|
|
166
195
|
}
|
|
167
196
|
|
|
197
|
+
if ((!wltpConsumptionValue || !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
198
|
+
return <>{wltpCombinedDefaultValue} {wltpCo2DefaultValue}</>;
|
|
199
|
+
}
|
|
200
|
+
|
|
168
201
|
return <>{consumptionValue} <br /> {co2Value}</>;
|
|
169
202
|
}
|
|
170
203
|
},
|
|
@@ -177,9 +210,17 @@ const getDecoratedLightProps = (
|
|
|
177
210
|
const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
|
|
178
211
|
const translatedUnit = t(`cbd:${consumptionUnit}`);
|
|
179
212
|
const co2 = car.environmentEmissions.co2;
|
|
180
|
-
const wltpConsumptionPowerCombined = car.consumption.wltpPowerCombined;
|
|
213
|
+
const wltpConsumptionPowerCombined = car.consumption.wltpPowerCombined || car.consumption.wltpWeightedPowerCombined;
|
|
181
214
|
const wltpCo2 = car.consumption.wltpCo2 || car.environmentEmissions.wltpCo2;
|
|
182
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);
|
|
223
|
+
|
|
183
224
|
const wltpConsumptionValue = Number.isFinite(wltpConsumptionPowerCombined)
|
|
184
225
|
? t('vehicleProps:value.wltpPowerCombined', { consumption: wltpConsumptionPowerCombined.toLocaleString(language), unit: translatedUnit })
|
|
185
226
|
: null;
|
|
@@ -200,6 +241,10 @@ const getDecoratedLightProps = (
|
|
|
200
241
|
return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
|
|
201
242
|
}
|
|
202
243
|
|
|
244
|
+
if ((!wltpConsumptionValue && !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
245
|
+
return <>{wltpPowerCombinedDefaultValue}, {wltpCo2ElectricDefaultValue}</>;
|
|
246
|
+
}
|
|
247
|
+
|
|
203
248
|
return <>{consumptionValue} <br /> {co2Value} </>;
|
|
204
249
|
}
|
|
205
250
|
},
|
|
@@ -210,8 +255,10 @@ const getDecoratedLightProps = (
|
|
|
210
255
|
get value() {
|
|
211
256
|
const consumptionCombined = +car.consumption.consumptionCombined;
|
|
212
257
|
const consumptionPowerCombined = +car.consumption.consumptionPowerCombined;
|
|
213
|
-
const wltpConsumptionPowerCombined = car.consumption.wltpPowerCombined;
|
|
214
|
-
|
|
258
|
+
const wltpConsumptionPowerCombined = car.consumption.wltpPowerCombined || car.consumption.wltpWeightedPowerCombined;
|
|
259
|
+
|
|
260
|
+
const wltpConsumptionCombined = car.consumption.wltpCombined || car.consumption.wltpWeightedCombined;
|
|
261
|
+
|
|
215
262
|
const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
|
|
216
263
|
const translatedUnit = t(`cbd:${consumptionUnit}`);
|
|
217
264
|
const wltpWeightedPowerCombined = car.consumption.wltpWeightedPowerCombined;
|
|
@@ -237,24 +284,54 @@ const getDecoratedLightProps = (
|
|
|
237
284
|
: t('vehicleProps:value.na');
|
|
238
285
|
|
|
239
286
|
const wltpCo2Value = Number.isFinite(co2)
|
|
240
|
-
|
|
241
|
-
|
|
287
|
+
? t('vehicleProps:value.wltpCo2WtdCombined', { co2: wltpCo2.toLocaleString(language) })
|
|
288
|
+
: null;
|
|
289
|
+
|
|
290
|
+
const wltpCo2PluginValue = Number.isFinite(wltpCo2)
|
|
291
|
+
? t('vehicleProps:value.wltpCo2WtdCombined', { co2: wltpCo2.toLocaleString(language), unit: translatedUnit })
|
|
292
|
+
: null;
|
|
293
|
+
|
|
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);
|
|
242
302
|
|
|
243
303
|
const hybridPlugin = car.engineData.hybridPlugin;
|
|
244
304
|
|
|
245
|
-
if (
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
305
|
+
if (hybridPlugin) {
|
|
306
|
+
if (wltpWeightedPowerCombinedContent && wltpWeightedCombinedContent && wltpCo2PluginValue) {
|
|
307
|
+
return <React.Fragment>
|
|
308
|
+
{`${wltpWeightedPowerCombinedContent}, `}
|
|
309
|
+
{`${wltpWeightedCombinedContent}, `}
|
|
310
|
+
{wltpCo2PluginValue}
|
|
311
|
+
</React.Fragment>
|
|
312
|
+
}
|
|
313
|
+
if ((!wltpWeightedPowerCombinedContent || !wltpWeightedCombinedContent || !wltpCo2PluginValue) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
314
|
+
return <React.Fragment>
|
|
315
|
+
{`${wltpPowerCombinedDefaultValue}, `}
|
|
316
|
+
{`${wltpCombinedDefaultValue}, `}
|
|
317
|
+
{wltpCo2DefaultWtdValue}
|
|
251
318
|
</React.Fragment>
|
|
252
319
|
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (wltpConsumptionPowerCombinedContent && wltpConsumptionCombinedContent && wltpCo2Value) {
|
|
253
323
|
return <React.Fragment>
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
324
|
+
{`${wltpConsumptionPowerCombinedContent}, `}
|
|
325
|
+
{`${wltpWeightedCombinedContent}, `}
|
|
326
|
+
{wltpCo2PluginValue}
|
|
327
|
+
</React.Fragment>
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if ((!wltpConsumptionPowerCombinedContent || !wltpConsumptionCombinedContent || !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
331
|
+
return <React.Fragment>
|
|
332
|
+
{`${wltpCombinedDefaultValue}, `}
|
|
333
|
+
{wltpCo2DefaultValue}
|
|
334
|
+
</React.Fragment>
|
|
258
335
|
}
|
|
259
336
|
|
|
260
337
|
return Number.isFinite(consumptionCombined) || Number.isFinite(consumptionPowerCombined)
|
|
@@ -292,10 +369,21 @@ const getDecoratedLightProps = (
|
|
|
292
369
|
? t('vehicleProps:value.wltpCo2Combined', { co2: wltpCo2.toLocaleString(language) })
|
|
293
370
|
: null;
|
|
294
371
|
|
|
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
|
+
|
|
295
379
|
if (wltpConsumptionValue && wltpCo2Value) {
|
|
296
380
|
return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
|
|
297
381
|
}
|
|
298
382
|
|
|
383
|
+
if ((!wltpConsumptionValue || !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
384
|
+
return <>{wltpCombinedDefaultValue}, {wltpCo2DefaultValue}</>;
|
|
385
|
+
}
|
|
386
|
+
|
|
299
387
|
return <>{consumptionValue} <br /> {co2Value}</>;
|
|
300
388
|
}
|
|
301
389
|
},
|
|
@@ -327,10 +415,21 @@ const getDecoratedLightProps = (
|
|
|
327
415
|
? t('vehicleProps:value.wltpCo2Combined', { co2: wltpCo2.toLocaleString(language) })
|
|
328
416
|
: null;
|
|
329
417
|
|
|
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
|
+
|
|
330
425
|
if (wltpConsumptionValue && wltpCo2Value) {
|
|
331
426
|
return <>{wltpConsumptionValue}, {wltpCo2Value}</>;
|
|
332
427
|
}
|
|
333
428
|
|
|
429
|
+
if ((!wltpConsumptionValue || !wltpCo2Value) && (mileage <= 1000 || registrationDate >= eightMonthsAgo)) {
|
|
430
|
+
return <>{wltpCombinedDefaultValue}, {wltpCo2DefaultValue}</>;
|
|
431
|
+
}
|
|
432
|
+
|
|
334
433
|
return <>{consumptionValue} <br /> {co2Value}</>;
|
|
335
434
|
}
|
|
336
435
|
},
|
package/source/locales/data.ts
CHANGED
|
@@ -88,7 +88,7 @@ export const vehicleProps = (car?: any, isOfferAvailable: boolean = true) => {
|
|
|
88
88
|
wltpCo2WtdCombined: `${vehicleOption.wltpCo2}g CO2/km (WLTP, gew., komb)*`,
|
|
89
89
|
wltpCombined: `${vehicleOption.wltpCombined || vehicleOption.wltpWeightedCombined}l/100km`,
|
|
90
90
|
wltpPowerCombined: `${vehicleOption.wltpPowerCombined || vehicleOption.wltpWeightedPowerCombined}kWh/100km`,
|
|
91
|
-
wltpCombinedGas: `${vehicleOption.wltpCombined || vehicleOption.wltpWeightedCombined}
|
|
91
|
+
wltpCombinedGas: `${vehicleOption.wltpCombined || vehicleOption.wltpWeightedCombined}kg/100km`
|
|
92
92
|
},
|
|
93
93
|
title: {
|
|
94
94
|
'addOfferToMainSlide': 'Zum Schieberegler hinzufügen',
|