Skip to content

Commit

Permalink
fix: revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdiyeh-deriv committed Mar 2, 2023
1 parent 2b9e1ea commit 6bd8359
Show file tree
Hide file tree
Showing 122 changed files with 26,540 additions and 67,702 deletions.
89,324 changes: 23,068 additions & 66,256 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"build:storybook": "cd packages/components && build-storybook --output-dir .out",
"build:gh-pages": "f () { nx run-many --target=build projects=@deriv/components,@deriv/p2p && nx run-many --target=build --projects=@deriv/cashier,@deriv/account,@deriv/cfd,@deriv/reports && npm run build:local $1 ;}; f",
"clean": "echo \"Remove $(git rev-parse --show-toplevel)/node_modules\" && lerna clean && rm -rf \"$(git rev-parse --show-toplevel)/node_modules\"",
"deploy": "f () { npm run build:travis && npm run build:local && lerna exec --scope @deriv/core -- npm run deploy $@ ;}; f",
"deploy": "f () { export NODE_ENV=staging && npm run build:all && lerna exec --scope @deriv/core -- npm run deploy $@ && export NODE_ENV= ;}; f",
"deploy:clean": "f () { npm run build:travis && npm run build:local && lerna exec --scope @deriv/core -- npm run deploy:clean $@ ;}; f",
"deploy:folder": "f () { export NODE_ENV=staging && npm run build:gh-pages $1 && lerna exec --scope @deriv/core -- npm run deploy:folder $@ && export NODE_ENV= ;}; f",
"install:qa": "npm --prefix ./e2e_tests ci && echo \"IMPORTANT: copy .env.example to .env and update the values for development.\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@binary-com/binary-document-uploader": "^2.4.7",
"@deriv/api-types": "^1.0.54",
"@deriv/api-types": "^1.0.11",
"@deriv/components": "^1.0.0",
"@deriv/shared": "^1.0.0",
"@deriv/translations": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ describe('<AccountLimits/>', () => {
expect(screen.queryByText('/account limits/i')).not.toBeInTheDocument();
});

it('should render Trading limits - Item table and its contents properly', () => {
it('should render Trading limits table and its trading limits contents properly', () => {
render(<AccountLimits {...props} />);
expect(screen.queryByTestId('account_limits_data')).toBeInTheDocument();

expect(
screen.getByRole('columnheader', {
name: /trading limits \- item/i,
name: /trading limits/i,
})
).toBeInTheDocument();
expect(
Expand Down Expand Up @@ -221,12 +221,12 @@ describe('<AccountLimits/>', () => {
expect(formatMoney).toHaveBeenCalledWith(props.currency, account_balance, true);
});

it('should render Trading limits - Item table and its contents properly', () => {
it('should render Trading limits table and its maximum daily turnover contents properly', () => {
render(<AccountLimits {...props} />);
expect(screen.queryByTestId('trading_daily_turnover_table')).toBeInTheDocument();
expect(
screen.getByRole('columnheader', {
name: /trading limits \- maximum daily turnover/i,
name: /maximum daily turnover/i,
})
).toBeInTheDocument();
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const AccountLimitsTableHeader = ({
align={align}
as='p'
color='prominent'
size='xxs'
size='xs'
line_height='m'
weight='bold'
data-testid='account_limit_table_header_text'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const AccountLimits = ({
<thead>
<tr>
<AccountLimitsTableHeader>
<Localize i18n_default_text='Trading limits - Item' />
<Localize i18n_default_text='Trading limits' />
</AccountLimitsTableHeader>
<AccountLimitsTableHeader align='right'>
<Localize i18n_default_text='Limit' />
Expand Down Expand Up @@ -207,7 +207,7 @@ const AccountLimits = ({
/>
)}
>
<Localize i18n_default_text='Trading limits - Maximum daily turnover' />
<Localize i18n_default_text='Maximum daily turnover' />
</AccountLimitsTableHeader>
<AccountLimitsTableHeader align='right'>
<Localize i18n_default_text='Limit' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const AddressDetails = ({
is_gb_residence,
onSubmitEnabledChange,
selected_step_ref,
has_real_account,
...props
}) => {
const { is_appstore } = React.useContext(PlatformContext);
Expand Down Expand Up @@ -158,7 +159,7 @@ const AddressDetails = ({
}
maxLength={255}
placeholder={localize('First line of address')}
disabled={props.value?.address_line_1}
disabled={props.value?.address_line_1 && has_real_account}
/>
<InputField
name='address_line_2'
Expand All @@ -170,7 +171,7 @@ const AddressDetails = ({
}
maxLength={255}
placeholder={localize('Second line of address')}
disabled={props.value?.address_line_2}
disabled={props.value?.address_line_2 && has_real_account}
/>
<InputField
name='address_city'
Expand All @@ -181,7 +182,7 @@ const AddressDetails = ({
: localize('Town/City')
}
placeholder={localize('Town/City')}
disabled={props.value?.address_city}
disabled={props.value?.address_city && has_real_account}
/>
{!has_fetched_states_list && (
<div className='details-form__loader'>
Expand Down Expand Up @@ -212,7 +213,9 @@ const AddressDetails = ({
setAddressStateToDisplay('');
}}
list_portal_id={is_appstore ? '' : 'modal_root'}
disabled={props.value?.address_state}
disabled={
props.value?.address_state && has_real_account
}
/>
</DesktopWrapper>
<MobileWrapper>
Expand All @@ -230,7 +233,9 @@ const AddressDetails = ({
);
setAddressStateToDisplay('');
}}
disabled={props.value?.address_state}
disabled={
props.value?.address_state && has_real_account
}
/>
</MobileWrapper>
</>
Expand All @@ -242,7 +247,7 @@ const AddressDetails = ({
name='address_state'
label={localize('State/Province')}
placeholder={localize('State/Province')}
disabled={props.value?.address_state}
disabled={props.value?.address_state && has_real_account}
/>
)}
<InputField
Expand All @@ -256,7 +261,7 @@ const AddressDetails = ({
setFieldTouched('address_postcode', true);
handleChange(e);
}}
disabled={props.value?.address_postcode}
disabled={props.value?.address_postcode && has_real_account}
/>
</div>
</ThemedScrollbars>
Expand Down
4 changes: 2 additions & 2 deletions packages/account/src/Components/hooks/useToggleValidation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import React from 'react';

export const useToggleValidation = (hash: string) => {
const [is_validation_enabled, setIsValidationEnabled] = React.useState(false);
const { is_deriv_app } = getPlatformFromUrl();
const { is_staging_deriv_app } = getPlatformFromUrl();

React.useEffect(() => {
// This effect allows to toggle IDV validation
// for repetitive and sequential numbers
if (is_deriv_app || (hash && hash === '#toggle_id_validation')) {
if (!is_staging_deriv_app || (hash && hash === '#toggle_id_validation')) {
setIsValidationEnabled(true);
} else {
setIsValidationEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const PersonalDetails = ({
onSubmitEnabledChange,
selected_step_ref,
closeRealAccountSignup,
has_real_account,
...props
}) => {
const { is_appstore } = React.useContext(PlatformContext);
Expand Down Expand Up @@ -266,7 +267,8 @@ const PersonalDetails = ({
}
hint={getFieldHint(localize('first name'))}
disabled={
disabled_items.includes('first_name') || props.value?.first_name
disabled_items.includes('first_name') ||
(props.value?.first_name && has_real_account)
}
placeholder={localize('John')}
data-testid='first_name'
Expand All @@ -279,7 +281,8 @@ const PersonalDetails = ({
label={getLastNameLabel()}
hint={getFieldHint(localize('last name'))}
disabled={
disabled_items.includes('last_name') || props.value?.last_name
disabled_items.includes('last_name') ||
(props.value?.last_name && has_real_account)
}
placeholder={localize('Doe')}
data-testid='last_name'
Expand All @@ -298,7 +301,7 @@ const PersonalDetails = ({
hint={getFieldHint(localize('date of birth'))}
disabled={
disabled_items.includes('date_of_birth') ||
props.value?.date_of_birth
(props.value?.date_of_birth && has_real_account)
}
placeholder={localize('01-07-1999')}
portal_id={is_appstore ? '' : 'modal_root'}
Expand All @@ -315,7 +318,7 @@ const PersonalDetails = ({
disabled={
(!!props.value.place_of_birth &&
disabled_items.includes('place_of_birth')) ||
props.value?.place_of_birth
(props.value?.place_of_birth && has_real_account)
}
data-lpignore='true'
autoComplete='off' // prevent chrome autocomplete
Expand Down Expand Up @@ -345,7 +348,7 @@ const PersonalDetails = ({
disabled={
(!!props.value.place_of_birth &&
disabled_items.includes('place_of_birth')) ||
props.value?.place_of_birth
(props.value?.place_of_birth && has_real_account)
}
label={
is_mf
Expand Down Expand Up @@ -395,7 +398,7 @@ const PersonalDetails = ({
(props.value.citizen && is_fully_authenticated) ||
(!!props.value.citizen &&
disabled_items.includes('citizen')) ||
props.value?.citizen
(props.value?.citizen && has_real_account)
}
list_items={residence_list}
onItemSelection={({ value, text }) =>
Expand All @@ -414,7 +417,7 @@ const PersonalDetails = ({
(props.value.citizen && is_fully_authenticated) ||
(!!props.value.citizen &&
disabled_items.includes('citizen')) ||
props.value?.citizen
(props.value?.citizen && has_real_account)
}
label={
is_mf
Expand Down Expand Up @@ -455,6 +458,7 @@ const PersonalDetails = ({
disabled={
disabled_items.includes('phone') ||
(props.value?.phone &&
has_real_account &&
validPhone(props.value?.phone) &&
props.value?.phone?.length >= 9 &&
props.value?.phone?.length <= 35)
Expand Down Expand Up @@ -564,7 +568,8 @@ const PersonalDetails = ({
data-testid='tax_identification_number'
disabled={
disabled_items.includes('tax_identification_number') ||
props.value?.tax_identification_number
(props.value?.tax_identification_number &&
has_real_account)
}
/>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ 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 { isSequentialNumber, isRecurringNumberRegex, getDocumentData, getRegex } from './utils';
import {
isSequentialNumber,
isRecurringNumberRegex,
getDocumentData,
getRegex,
preventEmptyClipboardPaste,
} from './utils';
import { useToggleValidation } from '../../hooks/useToggleValidation';
import FormFooter from 'Components/form-footer';
import BackButtonIcon from 'Assets/ic-poi-back-btn.svg';
Expand Down Expand Up @@ -96,7 +102,10 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
if (!document_number) {
errors.document_number =
localize('Please enter your document number. ') + getExampleFormat(document_type.example_format);
} else if (validation_is_enabled && (is_recurring_number || is_sequential_number)) {
} else if (
(validation_is_enabled && (is_recurring_number || is_sequential_number)) ||
document_number === document_type.example_format
) {
errors.document_number = localize('Please enter a valid ID number.');
} else {
const format_regex = getRegex(document_type.value);
Expand Down Expand Up @@ -238,7 +247,7 @@ const IdvDocumentSubmit = ({ handleBack, handleViewComplete, selected_country, i
autoComplete='off'
placeholder='Enter your document number'
value={values.document_number}
onPaste={e => e.preventDefault()}
onPaste={preventEmptyClipboardPaste}
onBlur={handleBlur}
onChange={handleChange}
onKeyUp={e => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export const getDocumentData = (country_code, document_type) => {

const getImageLocation = image_name => getUrlBase(`/public/images/common/${image_name}`);

export const preventEmptyClipboardPaste = e => {
const clipboardData = (e.clipboardData || window.clipboardData).getData('text');
if (clipboardData.length === 0) {
e.preventDefault();
}
};

// Unsupported Regex List
const regex = [
{
Expand Down
Loading

0 comments on commit 6bd8359

Please sign in to comment.