@bytebrand/fe-ui-core 4.8.29 → 4.8.31

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(4);
50
+ expect(handleChange).toHaveBeenCalledTimes(3);
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.29",
3
+ "version": "4.8.31",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, FunctionComponent } from 'react';
1
+ import React, { useState, useEffect, useRef, FunctionComponent } from 'react';
2
2
  import _get from 'lodash/get';
3
3
  import { Hidden } from 'react-grid-system';
4
4
  import PriceContent from './partials/PriceContent';
@@ -104,19 +104,31 @@ const VehicleDetailedSidebar: FunctionComponent<IVehicleDetailedSidebarProps> =
104
104
  }
105
105
  ];
106
106
 
107
+ const initialDefaultAppliedForPath = useRef<string | null>(null);
108
+
107
109
  useEffect(() => {
108
110
  const getlocalStorageActiveTabCDP = localStorage.getItem('activeTabCDP');
109
- if (!getlocalStorageActiveTabCDP) return;
110
- const activeTab = tabsTitles.findIndex(({ title }: { title: string }) => {
111
- return title === getlocalStorageActiveTabCDP;
112
- });
113
- if (activeTab === -1) {
114
- setActiveTab(null, 0);
115
- } else {
116
- setActiveTab(null, activeTab);
111
+ if (getlocalStorageActiveTabCDP) {
112
+ const activeTab = tabsTitles.findIndex(({ title }: { title: string }) => {
113
+ return title === getlocalStorageActiveTabCDP;
114
+ });
115
+ if (activeTab === -1) {
116
+ setActiveTab(null, 0);
117
+ } else {
118
+ setActiveTab(null, activeTab);
119
+ }
120
+ localStorage.removeItem('activeTabCDP');
121
+ initialDefaultAppliedForPath.current = pathname;
122
+ return;
123
+ }
124
+ if (
125
+ initialDefaultAppliedForPath.current !== pathname
126
+ && _get(price, 'leasing.isActive', false)
127
+ ) {
128
+ setActiveTab(null, 1);
129
+ initialDefaultAppliedForPath.current = pathname;
117
130
  }
118
- localStorage.removeItem('activeTabCDP');
119
- }, [pathname, activeTab]); // tslint:disable-line:align
131
+ }, [pathname, activeTab, price]); // tslint:disable-line:align
120
132
 
121
133
  const priceProps = {
122
134
  tabsTitles,
@@ -143,7 +143,9 @@ const getDecoratedLightProps = (
143
143
  ? t('vehicleProps:value.consumptionCombined', { consumption: consumptionCombined.toLocaleString(language), unit: translatedUnit })
144
144
  : t('vehicleProps:value.na');
145
145
 
146
- const consumptionPowerCombinedContent = t('vehicleProps:value.consumptionPowerCombined', { consumption: consumptionPowerCombined.toLocaleString(language), unit: translatedUnit });
146
+ const consumptionPowerCombinedContent = Number.isFinite(consumptionPowerCombined)
147
+ ? t('vehicleProps:value.consumptionPowerCombined', { consumption: consumptionPowerCombined.toLocaleString(language), unit: translatedUnit })
148
+ : null;
147
149
 
148
150
  const co2Value = Number.isFinite(co2)
149
151
  ? t('vehicleProps:value.co2Combined', { co2: co2.toLocaleString(language) })
@@ -233,8 +235,12 @@ const getDecoratedLightProps = (
233
235
 
234
236
  const consumptionPowerCombinedContent = t('vehicleProps:value.consumptionPowerCombined', { consumption: consumptionPowerCombined.toLocaleString(language), unit: translatedUnit });
235
237
  const consumptionCombinedContent = t('vehicleProps:value.consumptionCombined', { consumption: consumptionCombined.toLocaleString(language), unit: translatedUnit });
236
- const wltpWeightedPowerCombinedContent = t('vehicleProps:value.wltpWeightedPowerCombined', { consumption: wltpWeightedPowerCombined.toLocaleString(language), unit: translatedUnit });
237
- const wltpWeightedCombinedContent = t('vehicleProps:value.wltpWeightedCombined', { consumption: wltpWeightedCombined.toLocaleString(language), unit: translatedUnit });
238
+ const wltpWeightedPowerCombinedContent = Number.isFinite(wltpWeightedPowerCombined)
239
+ ? t('vehicleProps:value.wltpWeightedPowerCombined', { consumption: wltpWeightedPowerCombined.toLocaleString(language), unit: translatedUnit })
240
+ : null;
241
+ const wltpWeightedCombinedContent = Number.isFinite(wltpWeightedCombined)
242
+ ? t('vehicleProps:value.wltpWeightedCombined', { consumption: wltpWeightedCombined.toLocaleString(language), unit: translatedUnit })
243
+ : null;
238
244
  const wltpConsumptionPowerCombinedContent = wltpConsumptionPowerCombined
239
245
  ? t('vehicleProps:value.wltpPowerCombined', { consumption: wltpConsumptionPowerCombined.toLocaleString(language), unit: translatedUnit })
240
246
  : null;