@bytebrand/fe-ui-core 4.8.112 → 4.8.114

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.8.112",
3
+ "version": "4.8.114",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -104,7 +104,7 @@
104
104
  "@types/react": "^16.8.3"
105
105
  },
106
106
  "scripts": {
107
- "prepare": "node -e 0",
107
+ "prepare": "husky",
108
108
  "storybook": "start-storybook -p 6006",
109
109
  "clean": "rm -rf ./dist/*.*",
110
110
  "build:lib": "yarn clean && webpack --config ./webpack.config.js --progress",
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useRef, FunctionComponent } from 'react';
1
+ import React, { useState, useEffect, 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,31 +104,22 @@ const VehicleDetailedSidebar: FunctionComponent<IVehicleDetailedSidebarProps> =
104
104
  }
105
105
  ];
106
106
 
107
- const initialDefaultAppliedForPath = useRef<string | null>(null);
108
-
107
+ // ADV-116: the default CDP tab is driven solely by `activeTabCDP` (set to Financing by the
108
+ // originating card, or to the exact tab when a payment type is clicked directly). No
109
+ // leasing-based default override.
109
110
  useEffect(() => {
110
111
  const getlocalStorageActiveTabCDP = localStorage.getItem('activeTabCDP');
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;
112
+ if (!getlocalStorageActiveTabCDP) return;
113
+ const activeTab = tabsTitles.findIndex(({ title }: { title: string }) => {
114
+ return title === getlocalStorageActiveTabCDP;
115
+ });
116
+ if (activeTab === -1) {
117
+ setActiveTab(null, 0);
118
+ } else {
119
+ setActiveTab(null, activeTab);
130
120
  }
131
- }, [pathname, activeTab, price]); // tslint:disable-line:align
121
+ localStorage.removeItem('activeTabCDP');
122
+ }, [pathname, activeTab]); // tslint:disable-line:align
132
123
 
133
124
  const priceProps = {
134
125
  tabsTitles,
@@ -1,7 +1,6 @@
1
1
  /* tslint:disable */
2
2
  import * as React from 'react';
3
3
  import classnames from 'classnames';
4
- import _get from 'lodash/get';
5
4
  import styles from './VehicleInfo.styl';
6
5
  import PriceRating from '../../../PriceRating/PriceRating';
7
6
  import { Visible, Hidden } from 'react-grid-system';
@@ -45,7 +44,6 @@ const VehicleInfo: React.FC<IVehicleInfoProps> = (props) => {
45
44
  location,
46
45
  offer,
47
46
  engineData,
48
- leasing,
49
47
  suppressConsumption
50
48
  } = props as (typeof props & { suppressConsumption?: boolean });
51
49
  const firstRegistrationDate = regDate && regDate !== 0 ? regDate : 'N/A';
@@ -168,12 +166,8 @@ const VehicleInfo: React.FC<IVehicleInfoProps> = (props) => {
168
166
  ),
169
167
  ...routeObj,
170
168
  className: wrapClasses,
171
- onClick: () => localStorage.setItem(
172
- 'activeTabCDP',
173
- _get(leasing, 'isActive', false)
174
- ? t('vehicleProps:title.leasing')
175
- : t('vehicleProps:title.financing')
176
- ),
169
+ // ADV-116: opening a CDP from a card defaults to the Financing tab.
170
+ onClick: () => localStorage.setItem('activeTabCDP', t('vehicleProps:title.financing')),
177
171
  href: url,
178
172
  target,
179
173
  rel
@@ -318,12 +318,8 @@ const VehicleSmallCard: FunctionComponent<IVehicleSmallCardProps> = (props) => {
318
318
  target,
319
319
  rel,
320
320
  className: `${styles.redirectClassLink} ${styles.gridAreaTitle}`,
321
- onClick: () => localStorage.setItem(
322
- 'activeTabCDP',
323
- _get(price, 'leasing.isActive', false)
324
- ? t('vehicleProps:title.leasing')
325
- : t('vehicleProps:title.financing')
326
- ),
321
+ // ADV-116: opening a CDP from a card defaults to the Financing tab.
322
+ onClick: () => localStorage.setItem('activeTabCDP', t('vehicleProps:title.financing')),
327
323
  href: url
328
324
  })}
329
325
 
@@ -376,12 +372,8 @@ const VehicleSmallCard: FunctionComponent<IVehicleSmallCardProps> = (props) => {
376
372
  target,
377
373
  rel,
378
374
  className: `${styles.redirectClassLink} ${styles.gridAreaImage}`,
379
- onClick: () => localStorage.setItem(
380
- 'activeTabCDP',
381
- _get(price, 'leasing.isActive', false)
382
- ? t('vehicleProps:title.leasing')
383
- : t('vehicleProps:title.financing')
384
- ),
375
+ // ADV-116: opening a CDP from a card defaults to the Financing tab.
376
+ onClick: () => localStorage.setItem('activeTabCDP', t('vehicleProps:title.financing')),
385
377
  href: url
386
378
  })}
387
379
  <VehicleInfo {...vehicleInfoProps} />
@@ -74,20 +74,24 @@ const withStats = (WrappedComponent: any) => ({
74
74
  const MIN_PRICE_DIFFERENCE = 500;
75
75
 
76
76
  const [showByLocalStorage, setShowByLocalStorage] = React.useState(false);
77
- const [lsFinancingFirst, setLsFinancingFirst] = React.useState<number | undefined>(undefined);
77
+ const [anyLsBlocked, setAnyLsBlocked] = React.useState(false);
78
78
 
79
79
  React.useEffect(() => {
80
80
  const raw = localStorage.getItem('financing_store');
81
81
  const parsed = raw ? JSON.parse(raw) : null;
82
82
  const fin = parsed?.userCommonConfig?.financing?.firstInstallment;
83
83
  const lea = parsed?.userCommonConfig?.leasing?.firstInstallment;
84
- setLsFinancingFirst(fin);
85
- setShowByLocalStorage(fin === 0 || lea === 0);
84
+ const finBlocked = fin !== undefined && fin !== null && fin !== 0;
85
+ const leaBlocked = lea !== undefined && lea !== null && lea !== 0;
86
+ const anyBlocked = finBlocked || leaBlocked;
87
+ const hasZero = fin === 0 || lea === 0;
88
+ setAnyLsBlocked(anyBlocked);
89
+ setShowByLocalStorage(hasZero && !anyBlocked);
86
90
  }, []);
87
91
 
88
92
  const showByBackend = disableDownPaymentLocalStorage
89
93
  ? !!showDownPayment
90
- : showDownPayment && (lsFinancingFirst === undefined || lsFinancingFirst === null);
94
+ : showDownPayment && !anyLsBlocked;
91
95
  const effectiveShowByLocalStorage = disableDownPaymentLocalStorage ? false : showByLocalStorage;
92
96
 
93
97
  const onHandleSlideChange = (activeSlide: number) => {