Skip to content

Commit

Permalink
Merge pull request binary-com#5 from balakrishna-binary/revert-4-acco…
Browse files Browse the repository at this point in the history
…unt_opening_dashboard

Revert "zaki / account_opening_dashboard"
  • Loading branch information
balakrishna-deriv committed Feb 2, 2021
2 parents 7699de4 + 7beba26 commit 599b81d
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ const AddressDetails = ({
const { cancel, promise } = makeCancellablePromise(props.fetchStatesList());
promise.then(() => {
setHasFetchedStatesList(true);
if (props.value.address_state) {
setAddressStateToDisplay(getLocation(states_list, props.value.address_state, 'text'));
}
setAddressStateToDisplay(getLocation(states_list, props.value.address_state, 'text'));
});
return () => {
setHasFetchedStatesList(false);
Expand Down
14 changes: 3 additions & 11 deletions packages/components/src/components/autocomplete/autocomplete.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { matchStringByChar, getPosition } from '@deriv/shared';
import { getPosition } from '@deriv/shared';
import Icon from '../icon';
import Input from '../input';
import DropdownList from '../dropdown-list';
Expand All @@ -15,15 +15,9 @@ const KEY_CODE = {
KEYUP: 38,
};

const getFilteredItems = (val, list, should_filter_by_char) => {
const getFilteredItems = (val, list) => {
const is_string_array = list.length && typeof list[0] === 'string';

if (should_filter_by_char) {
return list.filter(item =>
is_string_array ? matchStringByChar(item, val) : matchStringByChar(item.text, val)
);
}

return list.filter(item =>
is_string_array ? item.toLowerCase().includes(val) : item.text.toLowerCase().includes(val)
);
Expand All @@ -40,7 +34,6 @@ const Autocomplete = React.memo(props => {
onScrollStop,
list_portal_id,
is_alignment_top,
should_filter_by_char,
...other_props
} = props;

Expand Down Expand Up @@ -225,7 +218,7 @@ const Autocomplete = React.memo(props => {

const filterList = e => {
const val = e.target.value.toLowerCase();
const new_filtered_items = getFilteredItems(val, props.list_items, should_filter_by_char);
const new_filtered_items = getFilteredItems(val, props.list_items);

if (!new_filtered_items.length) {
setInputValue('');
Expand Down Expand Up @@ -317,5 +310,4 @@ Autocomplete.propTypes = {
onItemSelection: PropTypes.func,
list_portal_id: PropTypes.string,
is_alignment_top: PropTypes.bool,
should_filter_by_char: PropTypes.bool,
};

Large diffs are not rendered by default.

11 changes: 1 addition & 10 deletions packages/core/src/App/Containers/Redirect/redirect.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import { withRouter } from 'react-router-dom';
import { loginUrl, routes, PlatformContext } from '@deriv/shared';
import { loginUrl, routes } from '@deriv/shared';
import { getLanguage } from '@deriv/translations';
import { connect } from 'Stores/connect';
import { WS } from 'Services';
Expand All @@ -18,19 +17,11 @@ const Redirect = ({
const url_query_string = window.location.search;
const url_params = new URLSearchParams(url_query_string);
let redirected_to_route = false;
const { is_dashboard } = React.useContext(PlatformContext);

setVerificationCode(url_params.get('code'), url_params.get('action'));

switch (url_params.get('action')) {
case 'signup': {
if (is_dashboard) {
history.push({
pathname: routes.dashboard,
search: url_query_string,
});
redirected_to_route = true;
}
toggleAccountSignupModal(true);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,60 @@ import { localize } from '@deriv/translations';
const SetResidenceForm = ({
class_prefix = 'set-residence',
children,
default_value,
header_text,
errors,
touched,
setFieldTouched,
setFieldValue,
residence_list,
}) => {
React.useEffect(() => {
if (default_value) {
setFieldTouched('residence', true);
setFieldValue('residence', default_value, true);
}
}, []); // eslint-disable-line react-hooks/exhaustive-deps
return (
<div className={`${class_prefix}__residence-selection`}>
{!!header_text && (
<Text as='p' weight='bold' className={`${class_prefix}__heading`}>
{header_text}
</Text>
)}
<Text as='p' className={`${class_prefix}__${header_text ? 'text' : 'heading'}`}>
{localize('Where do you live?')}
}) => (
<div className={`${class_prefix}__residence-selection`}>
{!!header_text && (
<Text as='p' weight='bold' className={`${class_prefix}__heading`}>
{header_text}
</Text>
<Field name='residence'>
{({ field }) => (
<React.Fragment>
<DesktopWrapper>
<Autocomplete
{...field}
autoComplete='off'
className={`${class_prefix}__residence-field`}
type='text'
label={localize('Choose country')}
error={touched.residence && errors.residence}
required
list_items={residence_list}
onItemSelection={({ value, text }) =>
setFieldValue('residence', value ? text : '', true)
}
should_filter_by_char
/>
</DesktopWrapper>
<MobileWrapper>
<SelectNative
placeholder={localize('Please select')}
label={localize('Choose country')}
value={field.value}
list_items={residence_list}
error={touched.residence && errors.residence}
required
use_text
onChange={e => {
setFieldTouched('residence', true);
setFieldValue('residence', e.target.value, true);
}}
/>
</MobileWrapper>
</React.Fragment>
)}
</Field>
{children}
</div>
);
};
)}
<p className={`${class_prefix}__${header_text ? 'text' : 'heading'}`}>{localize('Where do you live?')}</p>
<Field name='residence'>
{({ field }) => (
<React.Fragment>
<DesktopWrapper>
<Autocomplete
{...field}
autoComplete='off'
className={`${class_prefix}__residence-field`}
type='text'
label={localize('Choose country')}
error={touched.residence && errors.residence}
required
list_items={residence_list}
onItemSelection={({ value, text }) => setFieldValue('residence', value ? text : '', true)}
/>
</DesktopWrapper>
<MobileWrapper>
<SelectNative
placeholder={localize('Please select')}
label={localize('Choose country')}
value={field.value}
list_items={residence_list}
error={touched.residence && errors.residence}
required
use_text
onChange={e => {
setFieldTouched('residence', true);
setFieldValue('residence', e.target.value, true);
}}
/>
</MobileWrapper>
</React.Fragment>
)}
</Field>
{children}
</div>
);

SetResidenceForm.propTypes = {
children: PropTypes.node,
default_value: PropTypes.string,
class_prefix: PropTypes.string,
header_text: PropTypes.string,
residence_list: PropTypes.arrayOf(PropTypes.object),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,67 +30,68 @@ const validateResidence = (values, residence_list) => {
return errors;
};

const SetResidence = ({ enableApp, onSetResidence, residence_list, toggleModalVisibility }) => {
const onSetResidenceComplete = error => {
class SetResidence extends React.Component {
onSetResidenceComplete = error => {
// TODO: Proper error handling (currently we have no place to put the message)
if (error) {
throw Error(error);
}
// Handle lower level modal controls due to overriding modal rendering
toggleModalVisibility(false);
enableApp();
this.props.isModalVisible(false);
this.props.enableApp();
};

const onSetResidencePassthrough = values => {
const index_of_selection = residence_list.findIndex(item => isResidenceText(item, values));
const modded_values = { ...values, residence: residence_list[index_of_selection].value };
onSetResidence(modded_values, onSetResidenceComplete);
};
return (
<div className='set-residence'>
<Formik
initialValues={{ residence: '' }}
validate={values => validateResidence(values, residence_list)}
onSubmit={onSetResidencePassthrough}
>
{({ isSubmitting, errors, values, setFieldValue, touched }) => (
<Form>
<React.Fragment>
<ResidenceForm
errors={errors}
touched={touched}
setFieldValue={setFieldValue}
residence_list={residence_list}
>
<Text as='p' size='xxs' weight='bold' className='set-residence__subtext'>
{localize(
'We need this to make sure our service complies with laws and regulations in your country.'
)}
</Text>
<Button
className={classNames('set-residence__btn', {
'set-residence__btn--disabled':
!values.residence || errors.residence || isSubmitting,
})}
type='submit'
is_disabled={!values.residence || !!errors.residence || isSubmitting}
text={localize('Set residence')}
primary
/>
</ResidenceForm>
</React.Fragment>
</Form>
)}
</Formik>
</div>
);
};
render() {
const { onSetResidence, residence_list } = this.props;
const onSetResidencePassthrough = values => {
const index_of_selection = residence_list.findIndex(item => isResidenceText(item, values));
const modded_values = { ...values, residence: residence_list[index_of_selection].value };
onSetResidence(modded_values, this.onSetResidenceComplete);
};
return (
<div className='set-residence'>
<Formik
initialValues={{ residence: '' }}
validate={values => validateResidence(values, residence_list)}
onSubmit={onSetResidencePassthrough}
>
{({ isSubmitting, errors, values, setFieldValue, touched }) => (
<Form>
<React.Fragment>
<ResidenceForm
errors={errors}
touched={touched}
setFieldValue={setFieldValue}
residence_list={residence_list}
>
<Text as='p' size='xxs' weight='bold' className='set-residence__subtext'>
{localize(
'We need this to make sure our service complies with laws and regulations in your country.'
)}
</Text>
<Button
className={classNames('set-residence__btn', {
'set-residence__btn--disabled':
!values.residence || errors.residence || isSubmitting,
})}
type='submit'
is_disabled={!values.residence || !!errors.residence || isSubmitting}
text={localize('Set residence')}
primary
/>
</ResidenceForm>
</React.Fragment>
</Form>
)}
</Formik>
</div>
);
}
}

SetResidence.propTypes = {
enableApp: PropTypes.func,
onSetResidence: PropTypes.func,
residence_list: PropTypes.array,
toggleModalVisibility: PropTypes.func,
};

const SetResidenceModal = ({
Expand All @@ -114,7 +115,7 @@ const SetResidenceModal = ({
<SetResidence
onSetResidence={onSetResidence}
residence_list={residence_list}
toggleModalVisibility={toggleSetResidenceModal}
isModalVisible={toggleSetResidenceModal}
enableApp={enableApp}
/>
</Dialog>
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/Services/socket-general.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,10 @@ const BinarySocketGeneral = (() => {
common_store.setError(true, { message: response.error.message });
break;
case 'InvalidToken':
if (
['cashier', 'paymentagent_withdraw', 'mt5_password_reset', 'new_account_virtual'].includes(msg_type)
) {
if (['cashier', 'paymentagent_withdraw', 'mt5_password_reset'].includes(msg_type)) {
return;
}
if (!['reset_password'].includes(msg_type)) {
if (!['reset_password', 'new_account_virtual'].includes(msg_type)) {
if (window.TrackJS) window.TrackJS.track('Custom InvalidToken error');
}
// eslint-disable-next-line no-case-declarations
Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,6 @@ export default class ClientStore extends BaseStore {
return 'mt_financial_company' in landing_companies || 'mt_gaming_company' in landing_companies;
};

@computed
get clients_country() {
return this.website_status?.clients_country;
}

@computed
get is_eu_country() {
const country = this.website_status.clients_country;
Expand Down
18 changes: 0 additions & 18 deletions packages/core/src/sass/app/modules/account-signup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@
.account-signup {
margin: 1.6rem 1.6rem 0;

&__error-wrapper {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 0.8rem;
margin-left: auto;

@include mobile {
justify-items: center;
margin-left: unset;
}
}
&__residence-selection,
&__password-selection {
display: flex;
Expand Down Expand Up @@ -64,13 +53,6 @@
}
&__subtext {
margin: 1rem 0 2.4rem;

&--error {
@include mobile {
margin-top: -1.4rem;
margin-bottom: 0.8rem;
}
}
}
&__btn {
align-self: flex-end;
Expand Down
Loading

0 comments on commit 599b81d

Please sign in to comment.