@bytebrand/fe-ui-core 4.2.68 → 4.2.70

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.
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import PaymentTypeCard from '../../../../source/components/Checkout/RadioCards/PaymentTypeCard/PaymentTypeCard';
4
+
5
+ describe('PaymentTypeCard', () => {
6
+ it('should render correctly', () => {
7
+ const { getByText } = render(<PaymentTypeCard value="test-value" label="Test Label" />);
8
+ expect(getByText('Test Label')).toBeInTheDocument();
9
+ });
10
+
11
+ it('should handle onChange event correctly', () => {
12
+ const handleChange = jest.fn();
13
+ const { getByRole } = render(<PaymentTypeCard value="test-value" label="Test Label" onChange={handleChange} />);
14
+ fireEvent.click(getByRole('radio'));
15
+ expect(handleChange).toHaveBeenCalledTimes(1);
16
+ });
17
+
18
+ it('should handle onChange event correctly if we have checkbox="true"', () => {
19
+ const handleChange = jest.fn();
20
+ const { getByRole } = render(
21
+ <PaymentTypeCard
22
+ checkbox
23
+ value="test-value"
24
+ label="Test Label"
25
+ onChange={handleChange}
26
+ />
27
+ );
28
+ fireEvent.click(getByRole('checkbox'));
29
+ fireEvent.click(getByRole('checkbox'));
30
+ expect(handleChange).toHaveBeenCalledTimes(2);
31
+ })
32
+
33
+ it('should be correct classes on depend on prop "disabled, checked, error"', () => {
34
+ const handleChange = jest.fn();
35
+ const { getByTestId } = render(
36
+ <PaymentTypeCard
37
+ value="test-value"
38
+ label="Test Label"
39
+ onChange={handleChange}
40
+ disabled
41
+ checked
42
+ error
43
+ />
44
+ );
45
+ const container = getByTestId('container');
46
+ expect(container).toHaveClass('disabled');
47
+ expect(container).toHaveClass('checked');
48
+ expect(container).toHaveClass('error');
49
+ })
50
+ });
@@ -3,7 +3,7 @@ import { render } from '@testing-library/react'
3
3
  import AdditionalOrderInfo from '../../../../../source/components/UserDashboardPage/sections/OrderStatusSection/AdditionalOrderInfo';
4
4
  import { getFormattedPrice } from '../../../../../source/framework/utils/CommonUtils';
5
5
 
6
- const t = (phrase: string | string[], options: object) => {
6
+ const t = (phrase: string | string[], options?: object): string | string[] => {
7
7
  if (options) {
8
8
  const value = Object.values(options).map((option) => option)
9
9
  return `${phrase} ${value}`;
@@ -40,12 +40,11 @@ const additionalOrderData = (buyingType: 'buy' | 'leasing' | 'financing', object
40
40
  { label: 'vehicle registration', value: getFormattedPrice(registrationCost, '$,.2f', ' €') },
41
41
  { label: 'license plates', value: getFormattedPrice(licensePlateCost, '$,.2f', ' €') },
42
42
  { label: 'Delivery', value: getFormattedPrice(transportationCost, '$,.2f', ' €') },
43
- buyingType !== 'buy' &&
43
+ ...(buyingType !== 'buy') ? [
44
44
  { label: `${buyingType} rate`, value: `${getFormattedPrice(monthlyInstallment, '$,.2f', '', '€')} per month` },
45
- buyingType !== 'buy' &&
46
45
  { label: 'Running time (months)', value: `${paybackPeriod} months` },
47
- buyingType !== 'buy' &&
48
46
  { label: 'Deposit', value: getFormattedPrice(deposit, '$,.2f', ' €') }
47
+ ] : []
49
48
  ],
50
49
  overallRate: {
51
50
  label: 'Your overall rate',
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { render, fireEvent } from '@testing-library/react';
3
3
  import OrderStatusCar from '../../../../../source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusCar';
4
4
 
5
- const t = (phrase: string | string[], options: object) => {
5
+ const t = (phrase: string | string[], options?: object): string | string[] => {
6
6
  if (options) {
7
7
  const value = Object.values(options).map((option) => option)
8
8
  return `${phrase} ${value}`;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { render } from '@testing-library/react'
3
3
  import OrderStatusSection from '../../../../../source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusSection';
4
- import { car } from './mockedPendingRequestedCar';
4
+ import { car } from '../../../../mockedData/mockedPendingRequestedCar';
5
5
 
6
- const t = (phrase: string | string[], options: object) => {
6
+ const t = (phrase: string | string[], options?: object): string | string[] => {
7
7
  if (options) {
8
8
  const value = Object.values(options).map((option) => option)
9
9
  return `${phrase} ${value}`;
@@ -68,7 +68,6 @@ const mockProps = {
68
68
  requestedCars,
69
69
  getSupportedImageFormat: jest.fn(),
70
70
  redirectToCar: jest.fn(),
71
- initHotjar: jest.fn(),
72
71
  // tslint:disable-next-line:object-shorthand-properties-first
73
72
  LinkRouter
74
73
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.68",
3
+ "version": "4.2.70",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -12,8 +12,6 @@ type PaymentTypeCardProps = {
12
12
  checked?: boolean;
13
13
 
14
14
  onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean, value: any) => void;
15
- onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;
16
- onFocus?: (event: React.FocusEvent<HTMLDivElement>) => void;
17
15
  onCheckoutModalClick?: (modalContent: object) => void;
18
16
 
19
17
  // Custom radio button props
@@ -51,8 +49,6 @@ const PaymentTypeCard = ({
51
49
  checkbox,
52
50
  squareRadioClassname,
53
51
  onChange,
54
- // onBlur,
55
- // onFocus,
56
52
  onCheckoutModalClick,
57
53
  paymentClassName
58
54
  }: PaymentTypeCardProps) => {
@@ -93,16 +89,7 @@ const PaymentTypeCard = ({
93
89
 
94
90
  onChange(event, checked, value);
95
91
  };
96
- const onKeyPress = (event: any) => {
97
- const checked = input.checked;
98
- const value = input.value;
99
92
 
100
- if (disabled) {
101
- return false;
102
- }
103
-
104
- onChange(event, checked, value);
105
- };
106
93
  const containerClasses = classnames(
107
94
  styles.container,
108
95
  paymentClassName,
@@ -132,63 +119,62 @@ const PaymentTypeCard = ({
132
119
  };
133
120
 
134
121
  return (
135
- <div className={containerClasses} tabIndex={1}>
122
+ <div data-testid='container' className={containerClasses} tabIndex={1}>
136
123
  <CardActionArea>
137
- <label className={labelClasses}>
138
- {/* Visual representation of the radio button */}
139
- <div className={styles.radioContentBlock}>
140
- {iconName && <span className={styles.payTypeIcon}><IconSVG name={iconName} /></span>}
141
- <div className={styles.payTypeRadioWrapper}>
142
- <div className={styles.radioLabelWrapper}>
143
- <span className={styles.labelContent}>
144
- <span ref={inputRef}>{label}</span>
145
- </span>
146
- {price != null &&
147
- <span>
148
- <VehicleFormattedPrice
149
- className={styles.price}
150
- monthly={monthly}
151
- toRound={false}
152
- numbersAfterDot={Math.round(price) === price ? 0 : 2}
153
- price={price}
154
- unit='€'
155
- size='medium'
156
- isNew={true}
157
- numberContainerClassName={styles.numberContainer}
158
- unitWrapperClassName={styles.unitWrapper}
159
- unitClassName={monthly ? styles.unit : styles.buyUnit}
160
- monthlyClassName={styles.monthly}
161
- afterCommaClassName={styles.afterComma}
162
- disablePrice={disabled}
163
- />
164
- </span>}
165
- <span className={radioClasses}>{checked && <IconSVG name='common_CheckBlue' className={styles.checkBlueIcon} />}
166
- </span>
167
- {/* Hidden radio input for SEO and HTML semantics */}
168
- <input
169
- className={styles.input}
170
- type={checkbox ? 'checkbox' : 'radio'}
171
- name={name}
172
- checked={checked}
173
- value={value}
174
- disabled={disabled}
175
- tabIndex={-1}
176
- onChange={checkbox ? onChangeCheckbox : onChangeRadio}
177
- ref={setInputRef}
178
- />
124
+ <label className={labelClasses}>
125
+ {/* Visual representation of the radio button */}
126
+ <div className={styles.radioContentBlock}>
127
+ {iconName && <span className={styles.payTypeIcon}><IconSVG name={iconName} /></span>}
128
+ <div className={styles.payTypeRadioWrapper}>
129
+ <div className={styles.radioLabelWrapper}>
130
+ <span className={styles.labelContent}>
131
+ <span ref={inputRef}>{label}</span>
132
+ </span>
133
+ {price != null &&
134
+ <span>
135
+ <VehicleFormattedPrice
136
+ className={styles.price}
137
+ monthly={monthly}
138
+ toRound={false}
139
+ numbersAfterDot={Math.round(price) === price ? 0 : 2}
140
+ price={price}
141
+ unit='€'
142
+ size='medium'
143
+ isNew={true}
144
+ numberContainerClassName={styles.numberContainer}
145
+ unitWrapperClassName={styles.unitWrapper}
146
+ unitClassName={monthly ? styles.unit : styles.buyUnit}
147
+ monthlyClassName={styles.monthly}
148
+ afterCommaClassName={styles.afterComma}
149
+ disablePrice={disabled}
150
+ />
151
+ </span>}
152
+ <span className={radioClasses}>{checked && <IconSVG name='common_CheckBlue' className={styles.checkBlueIcon} />}
153
+ </span>
154
+ {/* Hidden radio input for SEO and HTML semantics */}
155
+ <input
156
+ className={styles.input}
157
+ type={checkbox ? 'checkbox' : 'radio'}
158
+ name={name}
159
+ checked={checked}
160
+ value={value}
161
+ disabled={disabled}
162
+ tabIndex={-1}
163
+ onChange={checkbox ? onChangeCheckbox : onChangeRadio}
164
+ ref={setInputRef}
165
+ />
166
+ </div>
167
+ <span className={styles.infoContent}>{infoContent}</span>
179
168
  </div>
180
- <span className={styles.infoContent}>{infoContent}</span>
181
169
  </div>
182
- </div>
183
- </label>
184
- {tooltip &&
185
- <span style={{ position: 'absolute', left: titleWidth + 16, top: 25 }}>
186
- <IconSVG customDimensions className={styles.infoTransparent} onClick={() => onCheckoutModalClick(modalProps)} name='infoIcon' />
187
- </span>
188
- }
170
+ </label>
171
+ {tooltip &&
172
+ <span style={{ position: 'absolute', left: titleWidth + 16, top: 25 }}>
173
+ <IconSVG customDimensions className={styles.infoTransparent} onClick={() => onCheckoutModalClick(modalProps)} name='infoIcon' />
174
+ </span>
175
+ }
189
176
  </CardActionArea>
190
177
  </div>
191
-
192
178
  );
193
179
  };
194
180
 
@@ -1,24 +1,16 @@
1
1
  import React from 'react';
2
2
  import styles from './AdditionalOrderInfo.styl';
3
3
 
4
- import i18n from 'i18next';
5
-
6
4
  import VehicleFormattedPrice from '../../../Vehicle/VehicleFormattedPrice/VehicleFormattedPrice';
7
5
  import Button from '../../../_common/Button/Button';
8
6
  import classNames from 'classnames';
9
7
 
8
+ import { TFunction } from '../../../../framework/types/types';
9
+
10
10
  interface IAdditionalOrderData {
11
11
  addressData: { label: string, value: string }[];
12
12
  carPriceData: { label: string, value: string | number }[];
13
- overallRate: {
14
- label: string,
15
- value: number
16
- };
17
- }
18
-
19
- interface TFunction {
20
- <T = string>(key: string, options?: object): T;
21
- <T = string>(keys: string[], options?: object): T;
13
+ overallRate: { label: string, value: number };
22
14
  }
23
15
 
24
16
  interface IAdditionalOrderInfo {
@@ -130,7 +130,7 @@
130
130
  background-size: cover
131
131
 
132
132
  .slick-next::after
133
- left: 10px
133
+ left: 0px
134
134
 
135
135
  .slick-prev::after
136
136
  transform: rotate(180deg) translateY(-50%)
@@ -142,6 +142,4 @@
142
142
 
143
143
  .slick-next
144
144
  right: -5px!important
145
- top:50%!important
146
-
147
-
145
+ top:50%!important
@@ -4,8 +4,6 @@ import styles from './RequestedCarsSection.styl';
4
4
  import Slider from 'react-slick';
5
5
  import DashboardSection from '../../../containers/DasboardSection/DashboardSection';
6
6
  import SupportSection from './SupportSection';
7
- import i18next from 'i18next';
8
- import { translate } from 'react-i18next';
9
7
  import Image from '../../../_common/Image/Image';
10
8
  import { Hidden, Visible } from 'react-grid-system';
11
9
  import { getFormattedPrice } from '../../../../framework/utils/CommonUtils';
@@ -30,10 +28,7 @@ interface IRequestedCarsSection {
30
28
  initHotjar:() => void;
31
29
  }
32
30
 
33
- const RequestedCarsSection = ({ t, getSupportedImageFormat, requestedCars, redirectToCar, LinkRouter, initHotjar }: IRequestedCarsSection) => {
34
- useEffect(() => {
35
- initHotjar();
36
- }, []);
31
+ const RequestedCarsSection = ({ t, getSupportedImageFormat, requestedCars, redirectToCar, LinkRouter }: IRequestedCarsSection) => {
37
32
  const onDetailsClick = (event: React.MouseEvent, carId: string) => {
38
33
  redirectToCar(carId);
39
34
  event.preventDefault();
@@ -21,7 +21,7 @@ const SupportSection: React.FunctionComponent<IProps> = ({ t , Link }) => {
21
21
  <div className={styles.text}>
22
22
  {t('DealerDashboardPage:requestedCars.customerServiceText')}</div>
23
23
  <div className={styles.contactButton}>
24
- <Link link='/account/kontakt'>
24
+ <Link to='/account/kontakt'>
25
25
  <Button size='small' color='success' variant='contained'>{t('DealerDashboardPage:requestedCars.contact')}</Button>
26
26
  </Link>
27
27
  </div>
@@ -338,3 +338,8 @@ export interface IVehicleCompareProps {
338
338
  toCompare: boolean;
339
339
  onRemoveClick: () => void;
340
340
  }
341
+
342
+ export interface TFunction {
343
+ <T = string>(key: string, options?: object): T;
344
+ <T = string>(keys: string[], options?: object): T;
345
+ }