@bytebrand/fe-ui-core 4.2.69 → 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.
- package/__tests__/components/Checkout/PaymentTypeCard/PaymentTypeCard.test.tsx +50 -0
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/AdditionalOrderInfo.test.tsx +3 -4
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCar.test.tsx +1 -1
- package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusSection.test.tsx +2 -2
- package/package.json +1 -1
- package/source/components/Checkout/RadioCards/PaymentTypeCard/PaymentTypeCard.tsx +51 -65
- package/source/components/UserDashboardPage/sections/OrderStatusSection/AdditionalOrderInfo.tsx +3 -11
- package/source/framework/types/types.ts +5 -0
- /package/__tests__/{components/UserDasboardPage/sections/OrderStatusSection → mockedData}/mockedPendingRequestedCar.js +0 -0
|
@@ -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
|
|
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',
|
package/__tests__/components/UserDasboardPage/sections/OrderStatusSection/OrderStatusCar.test.tsx
CHANGED
|
@@ -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
|
|
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 '
|
|
4
|
+
import { car } from '../../../../mockedData/mockedPendingRequestedCar';
|
|
5
5
|
|
|
6
|
-
const t = (phrase: string | string[], options
|
|
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}`;
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
</
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
|
package/source/components/UserDashboardPage/sections/OrderStatusSection/AdditionalOrderInfo.tsx
CHANGED
|
@@ -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 {
|