Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 🎨 migrated component to TSX (#48) #10116

Merged
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
2703f09
refactor: :art: migrated component to TSX (#48)
likhith-deriv Sep 16, 2023
ffebdf3
fix: :art: migrated config to tsx (#49)
likhith-deriv Sep 20, 2023
da041a9
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Sep 22, 2023
afbc2d7
refactor: migrated components to tsx
likhith-deriv Sep 22, 2023
bc8c973
refactor: migrated components to tsx
likhith-deriv Sep 22, 2023
7bc0245
chore: added testcases
likhith-deriv Sep 22, 2023
4527655
chore: added testcases
likhith-deriv Sep 22, 2023
0a2da32
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Sep 22, 2023
1b13537
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Sep 22, 2023
fcf23b9
fix: :test_tube: fixed failing testcase
likhith-deriv Sep 22, 2023
359b6fd
fix: :test_tube: fixed failing testcase
likhith-deriv Sep 22, 2023
ab8b9e4
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Sep 25, 2023
d1b6db7
Likhith/migrate poo form (#50)
likhith-deriv Sep 25, 2023
60b271a
Merge branch 'master' of github.com:binary-com/deriv-app into sprint-…
Sep 26, 2023
7b7f7e9
Merge branch 'master' of github.com:binary-com/deriv-app into sprint-…
Sep 28, 2023
680741d
Merge branch 'master' of github.com:binary-com/deriv-app into sprint-…
Oct 2, 2023
f6576bc
Merge branch 'sprint-10/account-package-refactor' of github.com:likhi…
Oct 3, 2023
c627e5a
chore: update from master
Oct 3, 2023
c977421
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Oct 16, 2023
c4e98bd
fix: error object props
likhith-deriv Oct 17, 2023
0c6cf2b
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Oct 18, 2023
0f0884e
chore: poo ts init (#53)
yauheni-deriv Oct 19, 2023
993fbd1
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Oct 20, 2023
6c55750
feat: refactored POO form values
likhith-deriv Oct 20, 2023
791716a
fix: Error text for Failure of IDV
likhith-deriv Oct 20, 2023
17607bd
fix: file upload
likhith-deriv Oct 21, 2023
3c07091
fix: POO validation
likhith-deriv Oct 21, 2023
3a9bb6b
fix: failing testcase
likhith-deriv Oct 23, 2023
b3796b9
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Oct 23, 2023
1271fcd
fix: added validations
likhith-deriv Oct 23, 2023
3d5c66b
fix: types of payment method
likhith-deriv Oct 23, 2023
572750b
fix: testcases for POO
likhith-deriv Oct 23, 2023
8ef684d
fix: code smells
likhith-deriv Oct 23, 2023
2ae5808
fix: resolved code smells
likhith-deriv Oct 23, 2023
f776f2e
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Oct 24, 2023
0921d58
refactor: types errors (#58)
yauheni-deriv Oct 25, 2023
0ed899b
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Oct 25, 2023
b81ed31
fix: resolved code smells
likhith-deriv Oct 25, 2023
3c38844
fix: code smells
likhith-deriv Oct 25, 2023
10b4b2b
fix: async behavior
likhith-deriv Oct 26, 2023
a92fab1
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Oct 26, 2023
21714b8
fix: import constant
likhith-deriv Oct 26, 2023
16434bc
fix: rename Const
likhith-deriv Oct 26, 2023
72b84e9
Merge branch 'master' of github.com:binary-com/deriv-app into sprint-…
Oct 27, 2023
d5cf46d
refactor: sonarcloud issues
Oct 27, 2023
2c9414e
fix: incorporated review comments
likhith-deriv Oct 29, 2023
bbb322a
fix: Convert the conditional to a boolean to avoid leaked value
likhith-deriv Oct 29, 2023
dd226f6
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Oct 31, 2023
563938a
fix: incorporated review comments
likhith-deriv Oct 31, 2023
e8a823e
refactor: incorporated review comments
likhith-deriv Nov 7, 2023
0d24faa
fix: removed duplicate status
likhith-deriv Nov 7, 2023
a9832ef
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Nov 7, 2023
98941c2
chore: spaces fix
Nov 8, 2023
d77bd0e
chore: poo-form review comments
Nov 8, 2023
06ee3a8
fix: code smells
likhith-deriv Nov 8, 2023
3fb70aa
fix: failing testcase
likhith-deriv Nov 8, 2023
075bdef
Merge branch 'master' of github.com:binary-com/deriv-app into sprint-…
Nov 27, 2023
891470b
fix: wrong upload settings field name
Nov 27, 2023
ffc8268
chore: unused import remove
Nov 27, 2023
2fa2177
fix: duplicate filling of payment-method
likhith-deriv Nov 28, 2023
124bb18
fix: removed unused import
likhith-deriv Nov 28, 2023
656e21c
fix:reset form
likhith-deriv Nov 29, 2023
86bc0ba
fix: resolved error display bugs
likhith-deriv Nov 29, 2023
185d114
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Dec 11, 2023
0de0b7d
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Dec 12, 2023
8c44a2c
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Dec 12, 2023
d8114a8
fix: issue related with POO disble
likhith-deriv Dec 12, 2023
f5eff8c
fix: code smells
likhith-deriv Dec 12, 2023
9faa993
fix: code smells
likhith-deriv Dec 12, 2023
c095832
refactor: incorporated review comments
likhith-deriv Dec 13, 2023
bd13f6e
fix: removed prop drilling
likhith-deriv Dec 13, 2023
ba6347f
fix: incorporated useFileUploader hook
likhith-deriv Dec 13, 2023
37e52df
refactor: removed hook implementation
likhith-deriv Dec 17, 2023
2c0d213
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Dec 18, 2023
c41dbab
fix: resolved loading and validation
likhith-deriv Dec 18, 2023
e9ca8c8
fix: incorrect status display issue
likhith-deriv Dec 18, 2023
87f6c9b
chore: removed console statements
likhith-deriv Dec 18, 2023
f453469
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Dec 18, 2023
899570d
fix: reinitialize form on value change
likhith-deriv Dec 18, 2023
49c04c9
Merge branch 'master' into sprint-10/account-package-refactor
likhith-deriv Dec 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/account/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ module.exports = function (env) {
'proof-of-address-container': 'Sections/Verification/ProofOfAddress/proof-of-address-container',
'proof-of-identity': 'Sections/Verification/ProofOfIdentity/proof-of-identity.jsx',
'proof-of-identity-container': 'Sections/Verification/ProofOfIdentity/proof-of-identity-container.jsx',
'proof-of-identity-config': 'Configs/proof-of-identity-config',
'proof-of-identity-container-for-mt5':
'Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5',
'poi-poa-docs-submitted': 'Components/poi-poa-docs-submitted/poi-poa-docs-submitted',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { screen, render } from '@testing-library/react';
import { SampleCreditCardModal } from '../sample-credit-card-modal';

describe('SampleCreditCardModal', () => {
let modal_root_el: HTMLDivElement;
beforeAll(() => {
modal_root_el = document.createElement('div');
modal_root_el.setAttribute('id', 'modal_root');
document.body.appendChild(modal_root_el);
});

afterAll(() => {
document.body.removeChild(modal_root_el);
});

it('should render modal props', () => {
const props: React.ComponentProps<typeof SampleCreditCardModal> = {
is_open: true,
onClose: jest.fn(),
};
render(<SampleCreditCardModal {...props} />);
expect(screen.getByRole('heading')).toHaveTextContent('How to mask your card?');
expect(screen.getByRole('img')).toHaveAttribute('alt', 'creditcardsample');
});

it('should not render modal when is_open is false', () => {
const props: React.ComponentProps<typeof SampleCreditCardModal> = {
is_open: false,
onClose: jest.fn(),
};
render(<SampleCreditCardModal {...props} />);
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
expect(screen.queryByRole('img')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { SampleCreditCardModal } from './sample-credit-card-modal.jsx';
import { SampleCreditCardModal } from './sample-credit-card-modal';

export default SampleCreditCardModal;
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import React from 'react';
import { Modal, Text } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';
import { Localize } from '@deriv/translations';
import { getUrlBase } from '@deriv/shared';

export const SampleCreditCardModal = ({ is_open, onClose }) => {
type TSampleCreditCardModalProps = {
is_open: boolean;
onClose: () => void;
};

/**
* Display a modal with a sample credit card image and instructions on how to mask the card.
* @name SampleCreditCardModal
* @param is_open - boolean to determine if the modal should be open or not
* @param onClose - function to close the modal
* @returns React component
*/
export const SampleCreditCardModal = ({ is_open, onClose }: TSampleCreditCardModalProps) => {
likhith-deriv marked this conversation as resolved.
Show resolved Hide resolved
return (
<Modal
className='sample-credit-card-modal'
Expand All @@ -14,9 +26,7 @@ export const SampleCreditCardModal = ({ is_open, onClose }) => {
>
<React.Fragment>
<Text className='sample-credit-card-modal-text' size='xs'>
{localize(
'Black out digits 7 to 12 of the card number that’s shown on the front of your debit/credit card.⁤'
)}
<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.⁤' />
</Text>
<img
src={getUrlBase('/public/images/common/sample-credit-card.png')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const getPaymentMethodsConfig = () => ({
icon_light: 'IcAdvcashLight',
icon_dark: 'IcAdvcashDark',
instructions: [
localize('Upload a screenshot of your name and email address from the personal information section.'),
<Localize
key={0}
i18n_default_text='Upload a screenshot of your name and email address from the personal information section.'
/>,
],
input_label: localize('Email address'),
identifier_type: 'email_address',
Expand All @@ -25,6 +28,7 @@ const getPaymentMethodsConfig = () => ({
target='_blank'
rel='noreferrer'
href='https://app.astropay.com/profile'
aria-label='Read more on AstroPay'
/>,
]}
/>,
Expand All @@ -35,24 +39,32 @@ const getPaymentMethodsConfig = () => ({
beyonic: {
icon_light: 'IcBeyonic',
icon_dark: 'IcBeyonic',
instructions: [localize('Upload your mobile bill statement showing your name and phone number.')],
instructions: [
<Localize
key={0}
i18n_default_text='Upload your mobile bill statement showing your name and phone number.'
/>,
],
input_label: localize('Mobile number'),
identifier_type: 'mobile_number',
},
'boleto (d24 voucher)': {
icon_light: 'IcBoletoD24VoucherLight',
icon_dark: 'IcBoletoD24VoucherDark',
instructions: [localize('Upload your bank statement showing your name and account details.')],
instructions: [
<Localize key={0} i18n_default_text='Upload your bank statement showing your name and account details.' />,
],
input_label: localize('Bank account number'),
identifier_type: 'bank_account_number',
},
visa: {
icon_light: 'IcVisaLight',
icon_dark: 'IcVisaDark',
instructions: [
localize(
'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.'
),
<Localize
key={0}
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.'
/>,
],
input_label: localize('Card number'),
identifier_type: 'card_number',
Expand All @@ -61,9 +73,10 @@ const getPaymentMethodsConfig = () => ({
icon_light: 'IcMasterCardLight',
icon_dark: 'IcMasterCardDark',
instructions: [
localize(
'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.'
),
<Localize
key={0}
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.'
/>,
],
input_label: localize('Card number'),
identifier_type: 'card_number',
Expand All @@ -72,10 +85,13 @@ const getPaymentMethodsConfig = () => ({
icon_light: 'IcPixLight',
icon_dark: 'IcPixDark',
instructions: [
localize('Upload a screenshot of either of the following to process the transaction:'),
localize('- your account profile section on the website'),
localize('- the Account Information page on the app'),
localize('- your account details of the bank linked to your account'),
<Localize
key={0}
i18n_default_text='Upload a screenshot of either of the following to process the transaction:'
/>,
<Localize key={1} i18n_default_text='- your account profile section on the website' />,
<Localize key={2} i18n_default_text='- the Account Information page on the app' />,
<Localize key={3} i18n_default_text='- your account details of the bank linked to your account' />,
],
input_label: localize('User ID'),
identifier_type: 'user_id',
Expand All @@ -84,9 +100,10 @@ const getPaymentMethodsConfig = () => ({
icon_light: 'IcSkrillLight',
icon_dark: 'IcSkrillDark',
instructions: [
localize(
'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.'
),
<Localize
key={0}
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.'
/>,
],
input_label: localize('Email address'),
identifier_type: 'email_address',
Expand Down Expand Up @@ -116,6 +133,7 @@ const getPaymentMethodsConfig = () => ({
target='_blank'
rel='noreferrer'
href='https://onlinenaira.com/members/index.htm'
aria-label='Read more on OnlineNaira'
/>,
]}
/>,
Expand All @@ -129,6 +147,7 @@ const getPaymentMethodsConfig = () => ({
target='_blank'
rel='noreferrer'
href='https://onlinenaira.com/members/bank.htm'
aria-label='Read more on OnlineNaira'
/>,
]}
/>,
Expand All @@ -140,9 +159,10 @@ const getPaymentMethodsConfig = () => ({
icon_light: 'IcWebMoneyLight',
icon_dark: 'IcWebMoneyDark',
instructions: [
localize(
'Upload a screenshot of your account and personal details page with your name, account number, phone number, and email address.'
),
<Localize
key={0}
i18n_default_text='Upload a screenshot of your account and personal details page with your name, account number, phone number, and email address.'
/>,
],
input_label: localize('Account number'),
identifier_type: 'account_number',
Expand All @@ -151,7 +171,10 @@ const getPaymentMethodsConfig = () => ({
icon_light: 'IcZingpay',
icon_dark: 'IcZingpay',
instructions: [
localize('Upload your bank statement showing your name, account number, and transaction history.'),
<Localize
key={0}
i18n_default_text='Upload your bank statement showing your name, account number, and transaction history.'
/>,
],
input_label: localize('Bank account number'),
identifier_type: 'bank_account_number',
Expand All @@ -160,7 +183,10 @@ const getPaymentMethodsConfig = () => ({
icon_light: 'IcSticpayLight',
icon_dark: 'IcSticpayDark',
instructions: [
localize('Upload a screenshot of your name and email address from the personal details section.'),
<Localize
key={0}
i18n_default_text='Upload a screenshot of your name and email address from the personal details section.'
/>,
],
input_label: localize('Email address'),
identifier_type: 'email_address',
Expand All @@ -169,15 +195,23 @@ const getPaymentMethodsConfig = () => ({
icon_light: 'IcJetonLight',
icon_dark: 'IcJetonDark',
instructions: [
localize('Upload a screenshot of your name and account number from the personal details section.'),
<Localize
key={0}
i18n_default_text='Upload a screenshot of your name and account number from the personal details section.'
/>,
],
input_label: localize('Account number'),
identifier_type: 'account_number',
},
other: {
icon_light: 'IcOtherPaymentMethod',
icon_dark: 'IcOtherPaymentMethod',
instructions: [localize('Upload a document showing your name and bank account number or account details.')],
instructions: [
<Localize
key={0}
i18n_default_text='Upload a document showing your name and bank account number or account details.'
/>,
],
input_label: null,
identifier_type: 'none',
},
Expand Down
20 changes: 0 additions & 20 deletions packages/account/src/Configs/proof-of-identity-config.ts

This file was deleted.

16 changes: 16 additions & 0 deletions packages/account/src/Constants/poo-identifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const IDENTIFIER_TYPES = Object.freeze({
ACCOUNT_ID: 'account_id',
ACCOUNT_NUMBER: 'account_number',
BANK_ACCOUNT_NUMBER: 'bank_account_number',
CARD_NUMBER: 'card_number',
EMAIL_ADDRESS: 'email_address',
MOBILE_NUMBER: 'mobile_number',
USER_ID: 'user_id',
});

export const CARD_NUMBER = {
MAX_LENGTH: 19,
MIN_LENGTH: 16,
};

export const MAX_FILE_SIZE = 8000; // 8MB
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Card from '../card';

jest.mock('../expanded-card', () => jest.fn(() => <div>Expanded Card</div>));

describe('Card', () => {
const mock_props: React.ComponentProps<typeof Card> = {
details: {
icon: 'IcVisaLight',
payment_method: 'visa',
items: [
{
creation_time: '1699433416524',
id: 4,
payment_method: 'visa',
documents_required: 1,
},
],
instructions: ['mock instruction 1', 'mock instruction 2'],
input_label: 'Card number',
identifier_type: 'card_number',
is_generic_pm: false,
documents_required: 1,
},
index: 0,
};

it('should render payment method card', () => {
render(<Card {...mock_props} />);
expect(screen.getByText('visa')).toBeInTheDocument();
});

it('should render expanded card when clicked', () => {
render(<Card {...mock_props} />);

userEvent.click(screen.getByRole('button'));
expect(screen.getByText('Expanded Card')).toBeInTheDocument();
});

it('should close the rendered expanded card when clicked', () => {
render(<Card {...mock_props} />);

userEvent.click(screen.getByRole('button'));

expect(screen.getByText('Expanded Card')).toBeInTheDocument();

userEvent.click(screen.getByRole('button'));

expect(screen.queryByText('Expanded Card')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import ExampleLink from '../example-link';

describe('ExampleLink', () => {
let modal_root_el: HTMLDivElement;
beforeAll(() => {
modal_root_el = document.createElement('div');
modal_root_el.setAttribute('id', 'modal_root');
document.body.appendChild(modal_root_el);
});

afterAll(() => {
document.body.removeChild(modal_root_el);
});

it('renders ExampleLink component', () => {
render(<ExampleLink />);
expect(screen.getByText('See example')).toBeInTheDocument();
});

it('should render SampleCreditCardModal when clicked', () => {
render(<ExampleLink />);

userEvent.click(screen.getByText('See example'));
expect(screen.getByText('How to mask your card?')).toBeInTheDocument();
});
});
Loading