@bytebrand/fe-ui-core 4.8.28 → 4.8.30

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.28",
3
+ "version": "4.8.30",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -104,6 +104,7 @@
104
104
  "@types/react": "^16.8.3"
105
105
  },
106
106
  "scripts": {
107
+ "prepare": "husky",
107
108
  "storybook": "start-storybook -p 6006",
108
109
  "clean": "rm -rf ./dist/*.*",
109
110
  "build:lib": "yarn clean && webpack --config ./webpack.config.js --progress",
@@ -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,
@@ -48,7 +48,7 @@ const VehicleTitle: React.FC<IVehicleTitleProps> = ({
48
48
  event.preventDefault();
49
49
  event.stopPropagation();
50
50
  event.nativeEvent.stopImmediatePropagation();
51
- onFavoriteClick(event, id);
51
+ if (onFavoriteClick) onFavoriteClick(event, id);
52
52
  };
53
53
 
54
54
  const renderFavoriteIcon = (): React.ReactNode => {