From 7beba2614599886818db7c144d6386dd35d68f2e Mon Sep 17 00:00:00 2001
From: balakrishna-binary
<56330681+balakrishna-binary@users.noreply.github.com>
Date: Tue, 2 Feb 2021 15:10:23 +0530
Subject: [PATCH] Revert "zaki / account_opening_dashboard"
---
.../address-details/address-details.jsx | 4 +-
.../components/autocomplete/autocomplete.jsx | 14 +-
.../account-signup-modal.jsx | 258 +++++++-----------
.../src/App/Containers/Redirect/redirect.jsx | 11 +-
.../SetResidenceModal/set-residence-form.jsx | 103 +++----
.../SetResidenceModal/set-residence-modal.jsx | 103 +++----
packages/core/src/Services/socket-general.js | 6 +-
packages/core/src/Stores/client-store.js | 5 -
.../src/sass/app/modules/account-signup.scss | 18 --
.../temp-get-dmt5-wallet.tsx | 3 +-
packages/dashboard/src/types/stores.types.ts | 2 -
.../shared/src/utils/string/string_util.js | 6 -
12 files changed, 201 insertions(+), 332 deletions(-)
diff --git a/packages/account/src/Components/address-details/address-details.jsx b/packages/account/src/Components/address-details/address-details.jsx
index d974d6e4c4b6..8d32fcfacebc 100644
--- a/packages/account/src/Components/address-details/address-details.jsx
+++ b/packages/account/src/Components/address-details/address-details.jsx
@@ -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);
diff --git a/packages/components/src/components/autocomplete/autocomplete.jsx b/packages/components/src/components/autocomplete/autocomplete.jsx
index 1a538b460b21..4d06642a648f 100644
--- a/packages/components/src/components/autocomplete/autocomplete.jsx
+++ b/packages/components/src/components/autocomplete/autocomplete.jsx
@@ -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';
@@ -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)
);
@@ -40,7 +34,6 @@ const Autocomplete = React.memo(props => {
onScrollStop,
list_portal_id,
is_alignment_top,
- should_filter_by_char,
...other_props
} = props;
@@ -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('');
@@ -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,
};
diff --git a/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx b/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx
index 069989372475..a6029412e84d 100644
--- a/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx
+++ b/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx
@@ -2,18 +2,9 @@ import classNames from 'classnames';
import { Field, Formik, Form } from 'formik';
import PropTypes from 'prop-types';
import React from 'react';
-import { Button, Dialog, Loading, PasswordInput, PasswordMeter, Text } from '@deriv/components';
-import {
- validPassword,
- getLocation,
- validLength,
- website_name,
- getErrorMessages,
- PlatformContext,
- redirectToSignUp,
-} from '@deriv/shared';
+import { Button, Dialog, PasswordInput, PasswordMeter, Text } from '@deriv/components';
+import { validPassword, validLength, website_name, getErrorMessages, PlatformContext } from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
-import { WS } from 'Services';
import { connect } from 'Stores/connect';
import ResidenceForm from '../SetResidenceModal/set-residence-form.jsx';
import 'Sass/app/modules/account-signup.scss';
@@ -54,19 +45,9 @@ const validateSignup = (values, residence_list) => {
return errors;
};
-const AccountSignup = ({
- enableApp,
- isModalVisible,
- clients_country,
- is_account_signup_modal_visible,
- onSignup,
- residence_list,
-}) => {
- const { is_deriv_crypto, is_dashboard } = React.useContext(PlatformContext);
+const AccountSignup = ({ enableApp, isModalVisible, is_account_signup_modal_visible, onSignup, residence_list }) => {
+ const context_type = React.useContext(PlatformContext);
- const [api_error, setApiError] = React.useState(false);
- const [is_loading, setIsLoading] = React.useState(true);
- const [country, setCountry] = React.useState('');
const [pw_input, setPWInput] = React.useState('');
const [has_valid_residence, setHasValidResidence] = React.useState(false);
@@ -78,22 +59,15 @@ const AccountSignup = ({
setHasValidResidence(true);
};
- // didMount lifecycle hook
- React.useEffect(() => {
- WS.wait('website_status', 'residence_list').then(() => {
- if (clients_country && residence_list) {
- setCountry(getLocation(residence_list, clients_country, 'text'));
- }
- setIsLoading(false);
- });
- }, []); // eslint-disable-line react-hooks/exhaustive-deps
-
const onSignupComplete = error => {
+ // Handle lower level modal controls due to overriding modal rendering
+ isModalVisible(false);
+ enableApp();
+
+ // Error would be returned on invalid token (and the like) cases.
+ // TODO: Proper error handling (currently we have no place to put the message)
if (error) {
- setApiError(error);
- } else {
- isModalVisible(false);
- enableApp();
+ throw Error(error);
}
};
@@ -106,7 +80,7 @@ const AccountSignup = ({
const modded_values = {
...values,
residence: residence_list[index_of_selection].value,
- is_deriv_crypto,
+ is_deriv_crypto: context_type.is_deriv_crypto,
is_account_signup_modal_visible,
};
onSignup(modded_values, onSignupComplete);
@@ -114,126 +88,92 @@ const AccountSignup = ({
return (
- {is_loading ? (
-
- ) : (
-
- {({
- isSubmitting,
- handleBlur,
- errors,
- handleChange,
- values,
- setFieldValue,
- setFieldTouched,
- touched,
- }) => (
-
+ )}
+
);
};
@@ -249,7 +189,6 @@ AccountSignup.propTypes = {
const AccountSignupModal = ({
enableApp,
disableApp,
- clients_country,
is_loading,
is_visible,
is_logged_in,
@@ -275,7 +214,6 @@ const AccountSignupModal = ({
is_content_centered
>
({
onSignup: client.onSignup,
is_logged_in: client.is_logged_in,
residence_list: client.residence_list,
- clients_country: client.clients_country,
logout: client.logout,
}))(AccountSignupModal);
diff --git a/packages/core/src/App/Containers/Redirect/redirect.jsx b/packages/core/src/App/Containers/Redirect/redirect.jsx
index 83744920785f..59bd9bcd1adc 100644
--- a/packages/core/src/App/Containers/Redirect/redirect.jsx
+++ b/packages/core/src/App/Containers/Redirect/redirect.jsx
@@ -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';
@@ -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;
}
diff --git a/packages/core/src/App/Containers/SetResidenceModal/set-residence-form.jsx b/packages/core/src/App/Containers/SetResidenceModal/set-residence-form.jsx
index cb64db187d03..b2c4652d37b4 100644
--- a/packages/core/src/App/Containers/SetResidenceModal/set-residence-form.jsx
+++ b/packages/core/src/App/Containers/SetResidenceModal/set-residence-form.jsx
@@ -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 (
-
- {!!header_text && (
-
- {header_text}
-
- )}
-
- {localize('Where do you live?')}
+}) => (
+
+ {!!header_text && (
+
+ {header_text}
-
- {({ field }) => (
-
-
-
- setFieldValue('residence', value ? text : '', true)
- }
- should_filter_by_char
- />
-
-
- {
- setFieldTouched('residence', true);
- setFieldValue('residence', e.target.value, true);
- }}
- />
-
-
- )}
-
- {children}
-
- );
-};
+ )}
+ {localize('Where do you live?')}
+
+ {({ field }) => (
+
+
+ setFieldValue('residence', value ? text : '', true)}
+ />
+
+
+ {
+ setFieldTouched('residence', true);
+ setFieldValue('residence', e.target.value, true);
+ }}
+ />
+
+
+ )}
+
+ {children}
+
+);
SetResidenceForm.propTypes = {
children: PropTypes.node,
- default_value: PropTypes.string,
class_prefix: PropTypes.string,
header_text: PropTypes.string,
residence_list: PropTypes.arrayOf(PropTypes.object),
diff --git a/packages/core/src/App/Containers/SetResidenceModal/set-residence-modal.jsx b/packages/core/src/App/Containers/SetResidenceModal/set-residence-modal.jsx
index a70051e8bd19..164dd0ac27b9 100644
--- a/packages/core/src/App/Containers/SetResidenceModal/set-residence-modal.jsx
+++ b/packages/core/src/App/Containers/SetResidenceModal/set-residence-modal.jsx
@@ -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 (
-
- validateResidence(values, residence_list)}
- onSubmit={onSetResidencePassthrough}
- >
- {({ isSubmitting, errors, values, setFieldValue, touched }) => (
-
- )}
-
-
- );
-};
+ 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 (
+
+ validateResidence(values, residence_list)}
+ onSubmit={onSetResidencePassthrough}
+ >
+ {({ isSubmitting, errors, values, setFieldValue, touched }) => (
+
+ )}
+
+
+ );
+ }
+}
SetResidence.propTypes = {
- enableApp: PropTypes.func,
onSetResidence: PropTypes.func,
residence_list: PropTypes.array,
- toggleModalVisibility: PropTypes.func,
};
const SetResidenceModal = ({
@@ -114,7 +115,7 @@ const SetResidenceModal = ({
diff --git a/packages/core/src/Services/socket-general.js b/packages/core/src/Services/socket-general.js
index 97a92b2951e8..fde6ceb8cdab 100644
--- a/packages/core/src/Services/socket-general.js
+++ b/packages/core/src/Services/socket-general.js
@@ -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
diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js
index b60f0ff8721b..45651af094f7 100644
--- a/packages/core/src/Stores/client-store.js
+++ b/packages/core/src/Stores/client-store.js
@@ -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;
diff --git a/packages/core/src/sass/app/modules/account-signup.scss b/packages/core/src/sass/app/modules/account-signup.scss
index e75166905799..a50bde322fa3 100644
--- a/packages/core/src/sass/app/modules/account-signup.scss
+++ b/packages/core/src/sass/app/modules/account-signup.scss
@@ -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;
@@ -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;
diff --git a/packages/dashboard/src/components/pages/temp-get-dmt5-wallet/temp-get-dmt5-wallet.tsx b/packages/dashboard/src/components/pages/temp-get-dmt5-wallet/temp-get-dmt5-wallet.tsx
index 9f64c2c70d1c..bc9f61b53d2d 100644
--- a/packages/dashboard/src/components/pages/temp-get-dmt5-wallet/temp-get-dmt5-wallet.tsx
+++ b/packages/dashboard/src/components/pages/temp-get-dmt5-wallet/temp-get-dmt5-wallet.tsx
@@ -9,10 +9,9 @@ import GetWalletModal from 'Components/modals/get-wallet-modal';
// TODO: Temp component. This should be removed after integrating with MT5 signup
const TempGetDMT5Wallet: React.FC = observer(() => {
- const { client_store, mt5_store, ui_store } = useStores();
+ const { mt5_store, ui_store } = useStores();
const { is_real_acc_signup_on } = ui_store;
- if (!client_store.is_logged_in) return null;
return (
diff --git a/packages/dashboard/src/types/stores.types.ts b/packages/dashboard/src/types/stores.types.ts
index 858ec7dc1492..0b122c0563ee 100644
--- a/packages/dashboard/src/types/stores.types.ts
+++ b/packages/dashboard/src/types/stores.types.ts
@@ -15,7 +15,6 @@ export type TClientStore = {
email_address: string;
currencies_list: TCurrenciesList;
currency: string;
- is_logged_in: boolean;
financial_assessment: GetFinancialAssessment;
residence_list: ResidenceList;
states_list: StatesList;
@@ -81,7 +80,6 @@ export type TUIStore = {
is_get_wallet_modal_open: boolean;
is_real_acc_signup_on: boolean;
resetRealAccountSignupParams?: () => void;
- openRealAccountSignup: () => void;
enableGetPasswordModal: () => void;
disableGetPasswordModal: () => void;
};
diff --git a/packages/shared/src/utils/string/string_util.js b/packages/shared/src/utils/string/string_util.js
index 82f1aa73e9d0..e58967569a6c 100644
--- a/packages/shared/src/utils/string/string_util.js
+++ b/packages/shared/src/utils/string/string_util.js
@@ -25,12 +25,6 @@ export const compareBigUnsignedInt = (a, b) => {
return order;
};
-export const matchStringByChar = (s, p) => {
- if (p?.length < 1) return true;
- const z = p.split('').reduce((a, b) => `${a}[^${b}]*${b}`);
- return RegExp(z, 'i').test(s);
-};
-
export const numberToString = n => (typeof n === 'number' ? String(n) : n);
export const getKebabCase = str => {