Skip to content

Commit 7bc8fdc

Browse files
likhith-deriv“yauheni-kryzhyk-deriv”yauheni-deriv
authored
refactor: 🎨 migrated component to TSX (#48) (#10116)
* refactor: 🎨 migrated component to TSX (#48) * refactor: 🎨 migrated component to TSX * refactor: ⚰️ unused import * fix: 🎨 migrated config to tsx (#49) * refactor: migrated components to tsx * refactor: migrated components to tsx * chore: added testcases * chore: added testcases * Merge branch 'master' into sprint-10/account-package-refactor * fix: 🧪 fixed failing testcase * fix: 🧪 fixed failing testcase * Likhith/migrate poo form (#50) * refactor: removed dead code * chore: fixed error condition * chore: update from master * fix: error object props * chore: poo ts init (#53) * chore: poo ts init * chore: remove query * chore: some types fix * chore: revert observer for poo form --------- Co-authored-by: “yauheni-kryzhyk-deriv” <“[email protected]”> * feat: refactored POO form values * fix: Error text for Failure of IDV * fix: file upload * fix: POO validation * fix: failing testcase * fix: added validations * fix: types of payment method * fix: testcases for POO * fix: code smells * fix: resolved code smells * refactor: types errors (#58) Co-authored-by: “yauheni-kryzhyk-deriv” <“[email protected]”> * fix: resolved code smells * fix: code smells * fix: async behavior * fix: import constant * fix: rename Const * refactor: sonarcloud issues * fix: incorporated review comments * fix: Convert the conditional to a boolean to avoid leaked value * fix: incorporated review comments * refactor: incorporated review comments * fix: removed duplicate status * chore: poo-form review comments * fix: code smells * fix: failing testcase * fix: wrong upload settings field name * chore: unused import remove * fix: duplicate filling of payment-method * fix: removed unused import * fix:reset form * fix: resolved error display bugs * Merge branch 'master' into sprint-10/account-package-refactor * fix: issue related with POO disble * fix: code smells * fix: code smells * refactor: incorporated review comments * fix: removed prop drilling * fix: incorporated useFileUploader hook * refactor: removed hook implementation * fix: resolved loading and validation * fix: incorrect status display issue * chore: removed console statements * fix: reinitialize form on value change --------- Co-authored-by: “yauheni-kryzhyk-deriv” <“[email protected]”> Co-authored-by: yauheni-deriv <[email protected]>
1 parent 6a2c14c commit 7bc8fdc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1295
-1096
lines changed

packages/account/build/webpack.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ module.exports = function (env) {
4646
'proof-of-address-container': 'Sections/Verification/ProofOfAddress/proof-of-address-container',
4747
'proof-of-identity': 'Sections/Verification/ProofOfIdentity/proof-of-identity.jsx',
4848
'proof-of-identity-container': 'Sections/Verification/ProofOfIdentity/proof-of-identity-container.jsx',
49-
'proof-of-identity-config': 'Configs/proof-of-identity-config',
5049
'proof-of-identity-container-for-mt5':
5150
'Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5',
5251
'poi-poa-docs-submitted': 'Components/poi-poa-docs-submitted/poi-poa-docs-submitted',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import { screen, render } from '@testing-library/react';
3+
import { SampleCreditCardModal } from '../sample-credit-card-modal';
4+
5+
describe('SampleCreditCardModal', () => {
6+
let modal_root_el: HTMLDivElement;
7+
beforeAll(() => {
8+
modal_root_el = document.createElement('div');
9+
modal_root_el.setAttribute('id', 'modal_root');
10+
document.body.appendChild(modal_root_el);
11+
});
12+
13+
afterAll(() => {
14+
document.body.removeChild(modal_root_el);
15+
});
16+
17+
it('should render modal props', () => {
18+
const props: React.ComponentProps<typeof SampleCreditCardModal> = {
19+
is_open: true,
20+
onClose: jest.fn(),
21+
};
22+
render(<SampleCreditCardModal {...props} />);
23+
expect(screen.getByRole('heading')).toHaveTextContent('How to mask your card?');
24+
expect(screen.getByRole('img')).toHaveAttribute('alt', 'creditcardsample');
25+
});
26+
27+
it('should not render modal when is_open is false', () => {
28+
const props: React.ComponentProps<typeof SampleCreditCardModal> = {
29+
is_open: false,
30+
onClose: jest.fn(),
31+
};
32+
render(<SampleCreditCardModal {...props} />);
33+
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
34+
expect(screen.queryByRole('img')).not.toBeInTheDocument();
35+
});
36+
});
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { SampleCreditCardModal } from './sample-credit-card-modal.jsx';
1+
import { SampleCreditCardModal } from './sample-credit-card-modal';
22

33
export default SampleCreditCardModal;

packages/account/src/Components/sample-credit-card-modal/sample-credit-card-modal.jsx packages/account/src/Components/sample-credit-card-modal/sample-credit-card-modal.tsx

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import React from 'react';
22
import { Modal, Text } from '@deriv/components';
3-
import { localize, Localize } from '@deriv/translations';
3+
import { Localize } from '@deriv/translations';
44
import { getUrlBase } from '@deriv/shared';
55

6-
export const SampleCreditCardModal = ({ is_open, onClose }) => {
6+
type TSampleCreditCardModalProps = {
7+
is_open: boolean;
8+
onClose: () => void;
9+
};
10+
11+
/**
12+
* Display a modal with a sample credit card image and instructions on how to mask the card.
13+
* @name SampleCreditCardModal
14+
* @param is_open - boolean to determine if the modal should be open or not
15+
* @param onClose - function to close the modal
16+
* @returns React component
17+
*/
18+
export const SampleCreditCardModal = ({ is_open, onClose }: TSampleCreditCardModalProps) => {
719
return (
820
<Modal
921
className='sample-credit-card-modal'
@@ -14,9 +26,7 @@ export const SampleCreditCardModal = ({ is_open, onClose }) => {
1426
>
1527
<React.Fragment>
1628
<Text className='sample-credit-card-modal-text' size='xs'>
17-
{localize(
18-
'Black out digits 7 to 12 of the card number that’s shown on the front of your debit/credit card.⁤'
19-
)}
29+
<Localize i18n_default_text='Black out digits 7 to 12 of the card number that’s shown on the front of your debit/credit card.⁤' />
2030
</Text>
2131
<img
2232
src={getUrlBase('/public/images/common/sample-credit-card.png')}

packages/account/src/Sections/Verification/ProofOfOwnership/payment-method-config.js packages/account/src/Configs/payment-method-config.tsx

+57-23
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ const getPaymentMethodsConfig = () => ({
66
icon_light: 'IcAdvcashLight',
77
icon_dark: 'IcAdvcashDark',
88
instructions: [
9-
localize('Upload a screenshot of your name and email address from the personal information section.'),
9+
<Localize
10+
key={0}
11+
i18n_default_text='Upload a screenshot of your name and email address from the personal information section.'
12+
/>,
1013
],
1114
input_label: localize('Email address'),
1215
identifier_type: 'email_address',
@@ -25,6 +28,7 @@ const getPaymentMethodsConfig = () => ({
2528
target='_blank'
2629
rel='noreferrer'
2730
href='https://app.astropay.com/profile'
31+
aria-label='Read more on AstroPay'
2832
/>,
2933
]}
3034
/>,
@@ -35,24 +39,32 @@ const getPaymentMethodsConfig = () => ({
3539
beyonic: {
3640
icon_light: 'IcBeyonic',
3741
icon_dark: 'IcBeyonic',
38-
instructions: [localize('Upload your mobile bill statement showing your name and phone number.')],
42+
instructions: [
43+
<Localize
44+
key={0}
45+
i18n_default_text='Upload your mobile bill statement showing your name and phone number.'
46+
/>,
47+
],
3948
input_label: localize('Mobile number'),
4049
identifier_type: 'mobile_number',
4150
},
4251
'boleto (d24 voucher)': {
4352
icon_light: 'IcBoletoD24VoucherLight',
4453
icon_dark: 'IcBoletoD24VoucherDark',
45-
instructions: [localize('Upload your bank statement showing your name and account details.')],
54+
instructions: [
55+
<Localize key={0} i18n_default_text='Upload your bank statement showing your name and account details.' />,
56+
],
4657
input_label: localize('Bank account number'),
4758
identifier_type: 'bank_account_number',
4859
},
4960
visa: {
5061
icon_light: 'IcVisaLight',
5162
icon_dark: 'IcVisaDark',
5263
instructions: [
53-
localize(
54-
'Upload a photo showing your name and the first six and last four digits of your card number. If the card does not display your name, upload the bank statement showing your name and card number in the transaction history.'
55-
),
64+
<Localize
65+
key={0}
66+
i18n_default_text='Upload a photo showing your name and the first six and last four digits of your card number. If the card does not display your name, upload the bank statement showing your name and card number in the transaction history.'
67+
/>,
5668
],
5769
input_label: localize('Card number'),
5870
identifier_type: 'card_number',
@@ -61,9 +73,10 @@ const getPaymentMethodsConfig = () => ({
6173
icon_light: 'IcMasterCardLight',
6274
icon_dark: 'IcMasterCardDark',
6375
instructions: [
64-
localize(
65-
'Upload a photo showing your name and the first six and last four digits of your card number. If the card does not display your name, upload the bank statement showing your name and card number in the transaction history.'
66-
),
76+
<Localize
77+
key={0}
78+
i18n_default_text='Upload a photo showing your name and the first six and last four digits of your card number. If the card does not display your name, upload the bank statement showing your name and card number in the transaction history.'
79+
/>,
6780
],
6881
input_label: localize('Card number'),
6982
identifier_type: 'card_number',
@@ -72,10 +85,13 @@ const getPaymentMethodsConfig = () => ({
7285
icon_light: 'IcPixLight',
7386
icon_dark: 'IcPixDark',
7487
instructions: [
75-
localize('Upload a screenshot of either of the following to process the transaction:'),
76-
localize('- your account profile section on the website'),
77-
localize('- the Account Information page on the app'),
78-
localize('- your account details of the bank linked to your account'),
88+
<Localize
89+
key={0}
90+
i18n_default_text='Upload a screenshot of either of the following to process the transaction:'
91+
/>,
92+
<Localize key={1} i18n_default_text='- your account profile section on the website' />,
93+
<Localize key={2} i18n_default_text='- the Account Information page on the app' />,
94+
<Localize key={3} i18n_default_text='- your account details of the bank linked to your account' />,
7995
],
8096
input_label: localize('User ID'),
8197
identifier_type: 'user_id',
@@ -84,9 +100,10 @@ const getPaymentMethodsConfig = () => ({
84100
icon_light: 'IcSkrillLight',
85101
icon_dark: 'IcSkrillDark',
86102
instructions: [
87-
localize(
88-
'Upload a screenshot of your name, account number, and email address from the personal details section of the app or profile section of your account on the website.'
89-
),
103+
<Localize
104+
key={0}
105+
i18n_default_text='Upload a screenshot of your name, account number, and email address from the personal details section of the app or profile section of your account on the website.'
106+
/>,
90107
],
91108
input_label: localize('Email address'),
92109
identifier_type: 'email_address',
@@ -116,6 +133,7 @@ const getPaymentMethodsConfig = () => ({
116133
target='_blank'
117134
rel='noreferrer'
118135
href='https://onlinenaira.com/members/index.htm'
136+
aria-label='Read more on OnlineNaira'
119137
/>,
120138
]}
121139
/>,
@@ -129,6 +147,7 @@ const getPaymentMethodsConfig = () => ({
129147
target='_blank'
130148
rel='noreferrer'
131149
href='https://onlinenaira.com/members/bank.htm'
150+
aria-label='Read more on OnlineNaira'
132151
/>,
133152
]}
134153
/>,
@@ -140,9 +159,10 @@ const getPaymentMethodsConfig = () => ({
140159
icon_light: 'IcWebMoneyLight',
141160
icon_dark: 'IcWebMoneyDark',
142161
instructions: [
143-
localize(
144-
'Upload a screenshot of your account and personal details page with your name, account number, phone number, and email address.'
145-
),
162+
<Localize
163+
key={0}
164+
i18n_default_text='Upload a screenshot of your account and personal details page with your name, account number, phone number, and email address.'
165+
/>,
146166
],
147167
input_label: localize('Account number'),
148168
identifier_type: 'account_number',
@@ -151,7 +171,10 @@ const getPaymentMethodsConfig = () => ({
151171
icon_light: 'IcZingpay',
152172
icon_dark: 'IcZingpay',
153173
instructions: [
154-
localize('Upload your bank statement showing your name, account number, and transaction history.'),
174+
<Localize
175+
key={0}
176+
i18n_default_text='Upload your bank statement showing your name, account number, and transaction history.'
177+
/>,
155178
],
156179
input_label: localize('Bank account number'),
157180
identifier_type: 'bank_account_number',
@@ -160,7 +183,10 @@ const getPaymentMethodsConfig = () => ({
160183
icon_light: 'IcSticpayLight',
161184
icon_dark: 'IcSticpayDark',
162185
instructions: [
163-
localize('Upload a screenshot of your name and email address from the personal details section.'),
186+
<Localize
187+
key={0}
188+
i18n_default_text='Upload a screenshot of your name and email address from the personal details section.'
189+
/>,
164190
],
165191
input_label: localize('Email address'),
166192
identifier_type: 'email_address',
@@ -169,15 +195,23 @@ const getPaymentMethodsConfig = () => ({
169195
icon_light: 'IcJetonLight',
170196
icon_dark: 'IcJetonDark',
171197
instructions: [
172-
localize('Upload a screenshot of your name and account number from the personal details section.'),
198+
<Localize
199+
key={0}
200+
i18n_default_text='Upload a screenshot of your name and account number from the personal details section.'
201+
/>,
173202
],
174203
input_label: localize('Account number'),
175204
identifier_type: 'account_number',
176205
},
177206
other: {
178207
icon_light: 'IcOtherPaymentMethod',
179208
icon_dark: 'IcOtherPaymentMethod',
180-
instructions: [localize('Upload a document showing your name and bank account number or account details.')],
209+
instructions: [
210+
<Localize
211+
key={0}
212+
i18n_default_text='Upload a document showing your name and bank account number or account details.'
213+
/>,
214+
],
181215
input_label: null,
182216
identifier_type: 'none',
183217
},

packages/account/src/Configs/proof-of-identity-config.ts

-20
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const IDENTIFIER_TYPES = Object.freeze({
2+
ACCOUNT_ID: 'account_id',
3+
ACCOUNT_NUMBER: 'account_number',
4+
BANK_ACCOUNT_NUMBER: 'bank_account_number',
5+
CARD_NUMBER: 'card_number',
6+
EMAIL_ADDRESS: 'email_address',
7+
MOBILE_NUMBER: 'mobile_number',
8+
USER_ID: 'user_id',
9+
});
10+
11+
export const CARD_NUMBER = {
12+
MAX_LENGTH: 19,
13+
MIN_LENGTH: 16,
14+
};
15+
16+
export const MAX_FILE_SIZE = 8000; // 8MB

packages/account/src/Containers/Account/account.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const Account = observer(({ history, location, routes }: TAccountProps) => {
2626
is_virtual,
2727
is_logged_in,
2828
is_logging_in,
29-
is_pending_proof_of_ownership,
29+
is_proof_of_ownership_enabled,
3030
landing_company_shortcode,
3131
should_allow_authentication,
3232
should_allow_poinc_authentication,
@@ -56,7 +56,7 @@ const Account = observer(({ history, location, routes }: TAccountProps) => {
5656
}
5757

5858
if (route.path === shared_routes.proof_of_ownership) {
59-
route.is_disabled = is_virtual || !is_pending_proof_of_ownership;
59+
route.is_disabled = is_virtual || !is_proof_of_ownership_enabled;
6060
}
6161

6262
if (route.path === shared_routes.proof_of_income) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import userEvent from '@testing-library/user-event';
4+
import Card from '../card';
5+
6+
jest.mock('../expanded-card', () => jest.fn(() => <div>Expanded Card</div>));
7+
8+
describe('Card', () => {
9+
const mock_props: React.ComponentProps<typeof Card> = {
10+
details: {
11+
icon: 'IcVisaLight',
12+
payment_method: 'visa',
13+
items: [
14+
{
15+
creation_time: '1699433416524',
16+
id: 4,
17+
payment_method: 'visa',
18+
documents_required: 1,
19+
},
20+
],
21+
instructions: ['mock instruction 1', 'mock instruction 2'],
22+
input_label: 'Card number',
23+
identifier_type: 'card_number',
24+
is_generic_pm: false,
25+
documents_required: 1,
26+
},
27+
index: 0,
28+
};
29+
30+
it('should render payment method card', () => {
31+
render(<Card {...mock_props} />);
32+
expect(screen.getByText('visa')).toBeInTheDocument();
33+
});
34+
35+
it('should render expanded card when clicked', () => {
36+
render(<Card {...mock_props} />);
37+
38+
userEvent.click(screen.getByRole('button'));
39+
expect(screen.getByText('Expanded Card')).toBeInTheDocument();
40+
});
41+
42+
it('should close the rendered expanded card when clicked', () => {
43+
render(<Card {...mock_props} />);
44+
45+
userEvent.click(screen.getByRole('button'));
46+
47+
expect(screen.getByText('Expanded Card')).toBeInTheDocument();
48+
49+
userEvent.click(screen.getByRole('button'));
50+
51+
expect(screen.queryByText('Expanded Card')).not.toBeInTheDocument();
52+
});
53+
});

0 commit comments

Comments
 (0)