Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/binary-com/deriv-app into…
Browse files Browse the repository at this point in the history
… 72476_Account-switching-issue-when-using-P2P-with-crypto-account
  • Loading branch information
heorhi-deriv committed Aug 22, 2022
2 parents d2433e8 + e8f16d1 commit e87ccba
Show file tree
Hide file tree
Showing 249 changed files with 46,740 additions and 40,138 deletions.
2 changes: 1 addition & 1 deletion jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
collectCoverageFrom: ['**/*.{js,jsx,ts,tsx}', '!**/node_modules/**'],
coverageReporters: ['lcov'],
coverageDirectory: './coverage/',
testRegex: '(/__tests__/.*|(\\.)(test|spec))\\.js?$',
testRegex: '(/__tests__/.*|(\\.)(test|spec))\\.(js|tsx)?$',
// This is needed to transform es modules imported from node_modules of the target component.
transformIgnorePatterns: ['/node_modules/(?!react-virtualized).+\\.js$'],
setupFiles: ['<rootDir>/../../jest.setup.js'],
Expand Down
78,094 changes: 40,706 additions & 37,388 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@types/node": "^17.0.27",
"@types/react": "^18.0.7",
"@types/react-dom": "^18.0.0",
"@types/react-router-dom": "^5.1.6",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"babel-polyfill": "^6.26.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"js-cookie": "^2.2.1",
"mobx": "^5.15.7",
"mobx-react": "6.3.1",
"onfido-sdk-ui": "^8.1.1",
"onfido-sdk-ui": "8.1.1",
"prop-types": "^15.7.2",
"qrcode.react": "^1.0.0",
"react": "^16.14.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/account/src/Components/api-token/api-token.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
}
&__clipboard-wrapper {
display: flex;
justify-content: flex-end;
justify-content: flex-start;
align-items: center;
gap: 1rem;
padding-right: 1.3rem;
Expand Down Expand Up @@ -132,7 +132,7 @@
&-item {
margin-bottom: 0.8rem;
display: grid;
grid-template-columns: 1.6fr 0.4fr;
grid-template-columns: 1.5fr 0.5fr;

&--name {
word-break: break-all;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('<RadioButtonGroup/>', () => {

it('if is_fiat is false it should not show description on clicking the child component', () => {
render(
<RadioButtonGroup {...props} is_fiat={false}>
<RadioButtonGroup {...props} is_fiat={false}>
<button>Currency</button>
</RadioButtonGroup>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ describe('<RadioButton />', () => {
};

const ust_msg =
/send only tether omni to this deposit address\.sending tether erc20 to this address will result in the loss of your deposit\./i;
/Tether as an Omni token \(USDT\) is a version of Tether that is hosted on the Omni layer on the Bitcoin blockchain./i;

const usdt_msg =
/tether as an erc20 token \(eusdt\) is a version of tether that is hosted on ethereum, an open software platform where anyone can build and deploy decentralised applications\./i;
const usdt_msg = /Tether as an ERC20 token \(eUSDT\) is a version of Tether that is hosted on Ethereum./i;

it('should render radiobutton', () => {
render(<RadioButton {...props} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ const USTPopover = ({ id }) => {
popover_message = (
<Localize
i18n_default_text={
'Send only Tether Omni to this deposit address.<0 /><0 />Sending Tether ERC20 to this address will result in the loss of your deposit.'
'Tether as an Omni token (USDT) is a version of Tether that is hosted on the Omni layer on the Bitcoin blockchain.'
}
components={[<br key={0} />]}
/>
);
} else if (/^tUSDT$/i.test(id)) {
popover_message = (
<Localize
i18n_default_text={'Tether as a TRC20 token (tUSDT) is a version of Tether that is hosted on Tron.'}
/>
);
} else {
popover_message = (
<Localize
i18n_default_text={
'Tether as an ERC20 token (eUSDT) is a version of Tether that is hosted on Ethereum, an open software platform where anyone can build and deploy decentralised applications.'
'Tether as an ERC20 token (eUSDT) is a version of Tether that is hosted on Ethereum.'
}
/>
);
Expand Down Expand Up @@ -82,7 +88,7 @@ const RadioButton = ({
) : (
<React.Fragment>
<Icon className='currency-list__icon' icon={`IcCurrency-${id.toLowerCase()}`} />
{/^(UST|eUSDT)$/i.test(id) && <USTPopover id={id} />}
{/^(UST|eUSDT|tUSDT)$/i.test(id) && <USTPopover id={id} />}
<div className='label currency-list__item-text'>
<div className='currency-list__item-label'>{label}</div>
<div className='currency-list__item-code'>({getCurrencyDisplayCode(id)})</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import PropTypes from 'prop-types';
import DocumentUploader from '@binary-com/binary-document-uploader';
import { localize } from '@deriv/translations';
import { compressImageFiles, readFiles, DOCUMENT_TYPE, PAGE_TYPE } from '@deriv/shared';

const fileReadErrorMessage = filename => {
return localize('Unable to read file {{name}}', { name: filename });
};

const uploadFile = (file, getSocket, settings) =>
new Promise((resolve, reject) => {
if (!file) {
reject();
}

// File uploader instance connected to binary_socket
const uploader = new DocumentUploader({ connection: getSocket() });

let is_file_error = false;

compressImageFiles([file]).then(files_to_process => {
readFiles(files_to_process, fileReadErrorMessage, settings).then(processed_files => {
processed_files.forEach(item => {
if (item.message) {
is_file_error = true;
reject(item);
}
});
const total_to_upload = processed_files.length;
if (is_file_error || !total_to_upload) {
return; // don't start submitting files until all front-end validation checks pass
}

// send files
uploader.upload(processed_files[0]).then(resolve).catch(reject);
});
});
});

uploadFile.propTypes = {
file: PropTypes.element.isRequired,
getSocket: PropTypes.func.isRequired,
settings: PropTypes.shape({
documentType: PropTypes.oneOf(Object.values(DOCUMENT_TYPE)).isRequired,
pageType: PropTypes.oneOf(Object.values(PAGE_TYPE)),
expirationDate: PropTypes.string,
documentId: PropTypes.string,
lifetimeValid: PropTypes.bool,
}),
};

export default uploadFile;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import UnsupportedFailed from './unsupported-failed.jsx';

export default UnsupportedFailed;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Icon } from '@deriv/components';
import { localize } from '@deriv/translations';
import IconMessageContent from 'Components/icon-message-content';

const UnsupportedFailed = ({ error }) => (
<IconMessageContent
message={localize('Proof of identity documents upload failed')}
text={error}
icon={<Icon icon='IcPoiFailed' size={128} />}
className='account-management-dashboard'
/>
);

UnsupportedFailed.propTypes = {
error: PropTypes.string,
};

export default UnsupportedFailed;
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,17 @@ describe('<CountrySelector/>', () => {
],
selected_country: '',
setSelectedCountry: jest.fn(),
show_helper_msg: '',
};
});

it('should render CountrySelector component not external with helper message', () => {
mock_props.show_helper_msg = true;

const { container } = render(<CountrySelector {...mock_props} />);

expect(screen.getByText('Proof of identity')).toBeInTheDocument();
expect(screen.getByText('In which country was your document issued?')).toBeInTheDocument();
expect(screen.getByText('Country')).toBeInTheDocument();
expect(screen.getByText('Try submitting an ID document instead.')).toBeInTheDocument();

const div_with_external_class = container.querySelector('.external-dropdown');
expect(div_with_external_class).not.toBeInTheDocument();
});

it('should render CountrySelector component external without hepler message', () => {
it('should render CountrySelector component external', () => {
mock_props.is_from_external = true;

const { container } = render(<CountrySelector {...mock_props} />);

expect(screen.getByText('Proof of identity')).toBeInTheDocument();
expect(screen.getByText('In which country was your document issued?')).toBeInTheDocument();
expect(screen.getByText('Country')).toBeInTheDocument();
expect(screen.queryByText('Try submitting an ID document instead.')).not.toBeInTheDocument();

const div_with_external_class = container.querySelector('.external-dropdown');
expect(div_with_external_class).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const CountrySelector = ({
residence_list,
selected_country,
setSelectedCountry,
show_helper_msg,
}) => {
const [country_list, setCountryList] = React.useState([]);

Expand Down Expand Up @@ -136,11 +135,6 @@ const CountrySelector = ({
<FormFooter
className={classNames('proof-of-identity__footer', { 'external-footer': is_from_external })}
>
{show_helper_msg && (
<Text color='red' weight='bold' className='proof-of-identity__footer-alert' size='xs'>
{localize('Try submitting an ID document instead.')}
</Text>
)}
<Button
className='proof-of-identity__submit-button'
type='submit'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import DocumentsUpload from './documents-upload.jsx';
import SelfieUpload from './selfie-upload.jsx';
import { SELFIE_DOCUMENT } from '../constants';
import './card-details.scss';

const CardDetails = ({ data, goToCards, onComplete, is_from_external, setIsCfdPoiCompleted }) => {
const [documents, setDocuments] = React.useState();
const [selfie, setSelfie] = React.useState();
const [is_selfie_upload, setIsSelfieUpload] = React.useState(false);

const onSubmitDocuments = values => {
setDocuments(values);
setIsSelfieUpload(true);
};

const onConfirmDocuments = values => {
onComplete({ ...documents, ...values });
setIsCfdPoiCompleted(true);
};

return (
<React.Fragment>
{!is_selfie_upload ? (
<DocumentsUpload
initial_values={documents}
is_from_external={is_from_external}
data={data}
goToCards={goToCards}
onSubmit={onSubmitDocuments}
/>
) : (
<SelfieUpload
initial_values={selfie}
goBack={() => setIsSelfieUpload(false)}
onConfirm={onConfirmDocuments}
onFileDrop={value => setSelfie({ [SELFIE_DOCUMENT.name]: value })}
/>
)}
</React.Fragment>
);
};

export default CardDetails;
Loading

0 comments on commit e87ccba

Please sign in to comment.