Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binary-com/deriv-app into henry/9…
Browse files Browse the repository at this point in the history
…3321/charts-empty-for-1min-and-above-for-digits
  • Loading branch information
henry-deriv committed Apr 28, 2023
2 parents 831c6f0 + b61343e commit eb628ae
Show file tree
Hide file tree
Showing 90 changed files with 2,191 additions and 917 deletions.
1,312 changes: 1,116 additions & 196 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/account/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'^Constants/(.*)$': '<rootDir>/src/Constants/$1',
'^Configs/(.*)$': '<rootDir>/src/Configs/$1',
'^Duplicated/(.*)$': '<rootDir>/src/Duplicated/$1',
'^Helpers/(.*)$': '<rootDir>/src/Helpers/$1',
'^Services/(.*)$': '<rootDir>/src/Services/$1',
'^Stores/(.*)$': '<rootDir>/src/Stores/$1',
'^Sections/(.*)$': '<rootDir>/src/Sections/$1',
Expand Down
8 changes: 4 additions & 4 deletions packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@
"js-cookie": "^2.2.1",
"mobx": "^6.6.1",
"mobx-react": "^7.5.1",
"onfido-sdk-ui": "8.1.1",
"onfido-sdk-ui": "^11.0.0",
"prop-types": "^15.7.2",
"qrcode.react": "^1.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.11.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-i18next": "^11.11.0"
"react-router-dom": "^5.2.0"
},
"devDependencies": {
"@babel/eslint-parser": "^7.17.0",
"@babel/preset-react": "^7.16.7",
"@jest/globals": "^26.5.3",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.5.0",
"babel-eslint": "^10.1.0",
"@types/react": "^18.0.7",
"@types/react-dom": "^18.0.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"clean-webpack-plugin": "^3.0.0",
"css-loader": "^5.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Autocomplete, Button, DesktopWrapper, Input, MobileWrapper, Text, Selec
import { Formik, Field } from 'formik';
import { localize, Localize } from '@deriv/translations';
import { formatInput, WS } from '@deriv/shared';
import { generatePlaceholderText } from 'Helpers/utils';
import { documentAdditionalError, getDocumentData, getRegex, preventEmptyClipboardPaste } from './utils';
import FormFooter from 'Components/form-footer';
import BackButtonIcon from 'Assets/ic-poi-back-btn.svg';
Expand All @@ -14,7 +15,8 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
const [document_list, setDocumentList] = React.useState([]);
const [document_image, setDocumentImage] = React.useState(null);
const [is_input_disable, setInputDisable] = React.useState(true);
const [is_doc_selected, setDocSelected] = React.useState(false);
const [selected_doc, setSelectedDoc] = React.useState(null);

const document_data = selected_country.identity.services.idv.documents_supported;

const {
Expand Down Expand Up @@ -205,11 +207,11 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
onChange={handleChange}
onItemSelection={item => {
if (item.text === 'No results found' || !item.text) {
setDocSelected(false);
setSelectedDoc(null);
resetDocumentItemSelected(setFieldValue);
} else {
setFieldValue('document_type', item, true);
setDocSelected(true);
setSelectedDoc(item.id);
if (has_visual_sample) {
setDocumentImage(item.sample_image || '');
}
Expand All @@ -232,7 +234,7 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
handleChange(e);
const selected_document = getDocument(e.target.value);
if (selected_document) {
setDocSelected(true);
setSelectedDoc(selected_document.id);
setFieldValue('document_type', selected_document, true);
if (has_visual_sample) {
setDocumentImage(selected_document.sample_image);
Expand Down Expand Up @@ -264,7 +266,7 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
errors.error_message
}
autoComplete='off'
placeholder='Enter your document number'
placeholder={generatePlaceholderText(selected_doc)}
value={values.document_number}
onPaste={preventEmptyClipboardPaste}
onBlur={handleBlur}
Expand Down Expand Up @@ -322,7 +324,7 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
</div>
)}
</div>
{is_doc_selected && (
{selected_doc && (
<Text
className={classNames('proof-of-identity__text btm-spacer', {
'top-spacer': is_from_external,
Expand Down
39 changes: 20 additions & 19 deletions packages/account/src/Components/poi/idv-document-submit/utils.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { getUrlBase } from '@deriv/shared';
import { localize } from '@deriv/translations';

export const documentAdditionalError = (document_additional, document_additional_format) => {
let error_message = null;
if (!document_additional) {
error_message = 'Please enter your document number. ';
error_message = localize('Please enter your document number. ');
} else {
const format_regex = getRegex(document_additional_format);
if (!format_regex.test(document_additional)) {
error_message = 'Please enter the correct format. ';
error_message = localize('Please enter the correct format. ');
}
}

Expand Down Expand Up @@ -71,24 +72,24 @@ const idv_document_data = {
},
za: {
national_id: {
new_display_name: 'National ID',
new_display_name: localize('National ID'),
example_format: '1234567890123',
sample_image: getImageLocation('za_national_identity_card.png'),
},
national_id_no_photo: {
new_display_name: 'National ID (No Photo)',
new_display_name: localize('National ID (No Photo)'),
example_format: '1234567890123',
sample_image: '',
},
},
ng: {
bvn: {
new_display_name: 'Bank Verification Number',
new_display_name: localize('Bank Verification Number'),
example_format: '12345678901',
sample_image: '',
},
cac: {
new_display_name: 'Corporate Affairs Commission',
new_display_name: localize('Corporate Affairs Commission'),
example_format: '12345678',
sample_image: '',
},
Expand All @@ -98,75 +99,75 @@ const idv_document_data = {
sample_image: getImageLocation('ng_drivers_license.png'),
},
nin: {
new_display_name: 'National Identity Number',
new_display_name: localize('National Identity Number'),
example_format: '12345678901',
sample_image: '',
},
nin_slip: {
new_display_name: 'National Identity Number Slip',
new_display_name: localize('National Identity Number Slip'),
example_format: '12345678901',
sample_image: getImageLocation('ng_nin_slip.png'),
},
tin: {
new_display_name: 'Taxpayer identification number',
new_display_name: localize('Taxpayer identification number'),
example_format: '12345678-1234',
sample_image: '',
},
voter_id: {
new_display_name: 'Voter ID',
new_display_name: localize('Voter ID'),
example_format: '1234567890123456789',
sample_image: getImageLocation('ng_voter_id.png'),
},
},
gh: {
drivers_license: {
new_display_name: '',
example_format: 'B1234567',
example_format: '12345678A1',
sample_image: '',
},
national_id: {
new_display_name: 'National ID',
new_display_name: localize('National ID'),
example_format: 'GHA-123456789-1',
sample_image: '',
},
passport: {
new_display_name: 'Passport',
new_display_name: localize('Passport'),
example_format: 'G1234567',
sample_image: '',
},
ssnit: {
new_display_name: 'Social Security and National Insurance Trust',
new_display_name: localize('Social Security and National Insurance Trust'),
example_format: 'C123456789012',
sample_image: '',
},
voter_id: {
new_display_name: 'Voter ID',
new_display_name: localize('Voter ID'),
example_format: '01234567890',
sample_image: '',
},
},
br: {
cpf: {
new_display_name: 'CPF',
new_display_name: localize('CPF'),
example_format: '123.456.789-12',
sample_image: '',
},
},
ug: {
national_id: {
new_display_name: 'National ID',
new_display_name: localize('National ID'),
example_format: 'CM12345678PE1D',
sample_image: getImageLocation('ug_national_identity_card.png'),
},
national_id_no_photo: {
new_display_name: 'National ID (No Photo)',
new_display_name: localize('National ID (No Photo)'),
example_format: 'CM12345678PE1D',
sample_image: '',
},
},
zw: {
national_id: {
new_display_name: 'National ID',
new_display_name: localize('National ID'),
example_format: '081234567F53',
sample_image: getImageLocation('zw_national_identity_card.png'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import {
preventEmptyClipboardPaste,
} from '../../idv-document-submit/utils';
import DocumentSubmitLogo from 'Assets/ic-document-submit-icon.svg';
import { generatePlaceholderText } from 'Helpers/utils';

export const IdvDocSubmitOnSignup = ({ citizen_data, has_previous, onPrevious, onNext, value, has_idv_error }) => {
const [document_list, setDocumentList] = React.useState([]);
const [document_image, setDocumentImage] = React.useState(null);
const [is_input_disable, setInputDisable] = React.useState(true);
const [is_doc_selected, setDocSelected] = React.useState(false);
const [selected_doc, setSelectedDoc] = React.useState(null);

const document_data = citizen_data.identity.services.idv.documents_supported;
const {
Expand Down Expand Up @@ -194,7 +195,7 @@ export const IdvDocSubmitOnSignup = ({ citizen_data, has_previous, onPrevious, o
<Text className='proof-of-identity__text btm-spacer' size='xs'>
{localize('Please select the document type and enter the ID number.')}
</Text>
{has_idv_error && !is_doc_selected && (
{has_idv_error && !selected_doc && (
<>
<Text
className='proof-of-identity'
Expand Down Expand Up @@ -256,7 +257,7 @@ export const IdvDocSubmitOnSignup = ({ citizen_data, has_previous, onPrevious, o
'No results found' ||
!item.text
) {
setDocSelected(false);
setSelectedDoc(null);
resetDocumentItemSelected(
setFieldValue
);
Expand All @@ -266,7 +267,7 @@ export const IdvDocSubmitOnSignup = ({ citizen_data, has_previous, onPrevious, o
item,
true
);
setDocSelected(true);
setSelectedDoc(item.id);
if (has_visual_sample) {
setDocumentImage(
item.sample_image || ''
Expand Down Expand Up @@ -295,7 +296,9 @@ export const IdvDocSubmitOnSignup = ({ citizen_data, has_previous, onPrevious, o
e.target.value
);
if (selected_document) {
setDocSelected(true);
setSelectedDoc(
selected_document.id
);
setFieldValue(
'document_type',
selected_document,
Expand Down Expand Up @@ -337,7 +340,9 @@ export const IdvDocSubmitOnSignup = ({ citizen_data, has_previous, onPrevious, o
errors.error_message
}
autoComplete='off'
placeholder='Enter your document number'
placeholder={generatePlaceholderText(
selected_doc
)}
value={values.document_number}
onPaste={preventEmptyClipboardPaste}
onBlur={handleBlur}
Expand Down Expand Up @@ -405,7 +410,7 @@ export const IdvDocSubmitOnSignup = ({ citizen_data, has_previous, onPrevious, o
</div>
</div>
)}
{is_doc_selected && (
{selected_doc && (
<Text
className='proof-of-identity__text-spacer'
align='center'
Expand Down
18 changes: 15 additions & 3 deletions packages/account/src/Configs/address-details-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { localize } from '@deriv/translations';
import { generateValidationFunction, getDefaultFields, getErrorMessages, regex_checks } from '@deriv/shared';
import {
generateValidationFunction,
getDefaultFields,
getErrorMessages,
regex_checks,
address_permitted_special_characters_message,
} from '@deriv/shared';

const address_details_config = ({ account_settings, is_svg }) => {
const is_gb = account_settings.country_code === 'gb';
Expand All @@ -16,7 +22,10 @@ const address_details_config = ({ account_settings, is_svg }) => {
['length', localize('Only {{max}} characters, please.', { max: 70 }), { max: 70 }],
[
'regular',
localize("Use only the following special characters: . , ' : ; ( ) @ # / -"),
localize('Use only the following special characters: {{permitted_characters}}', {
permitted_characters: address_permitted_special_characters_message,
interpolation: { escapeValue: false },
}),
{
regex: regex_checks.address_details.address_line_1,
},
Expand All @@ -31,7 +40,10 @@ const address_details_config = ({ account_settings, is_svg }) => {
['length', localize('Only {{max}} characters, please.', { max: 70 }), { max: 70 }],
[
'regular',
localize("Use only the following special characters: . , ' : ; ( ) @ # / -"),
localize('Use only the following special characters: {{permitted_characters}}', {
permitted_characters: address_permitted_special_characters_message,
interpolation: { escapeValue: false },
}),
{
regex: regex_checks.address_details.address_line_2,
},
Expand Down
19 changes: 19 additions & 0 deletions packages/account/src/Helpers/__tests__/utils.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { generatePlaceholderText } from '../utils';

describe('generatePlaceholderText', () => {
it('should return the correct placeholder text for drivers license', () => {
expect(generatePlaceholderText('drivers_license')).toEqual('Enter Driver License Reference number');
});

it('should return the correct placeholder text for ssnit', () => {
expect(generatePlaceholderText('ssnit')).toEqual('Enter your SSNIT number');
});

it('should return the correct placeholder text for id card', () => {
expect(generatePlaceholderText('id_card')).toEqual('Enter your document number');
});

it('should return the correct placeholder text for passport', () => {
expect(generatePlaceholderText('passport')).toEqual('Enter your document number');
});
});
Loading

0 comments on commit eb628ae

Please sign in to comment.