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, - }) => ( -
- {!has_valid_residence ? ( - -
- - ) : ( -