Skip to content

Commit

Permalink
Suisin/prodqa 891/refresh during sign up (#9639)
Browse files Browse the repository at this point in the history
* chore: solved refresh issue when use is in signup page

* chore: update to use existing code

* chore: update code to use SessionStore

* chore: remove comment out of codes

* chore: remove unused import
  • Loading branch information
suisin-deriv authored Sep 21, 2023
1 parent 0b9135e commit 5d56e37
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import classNames from 'classnames';
import { Formik, Form } from 'formik';
import PropTypes from 'prop-types';
import React from 'react';
import { getLocation, PlatformContext, SessionStore } from '@deriv/shared';
import { Button, Checkbox, Dialog, Loading, Text } from '@deriv/components';
import { getLocation, PlatformContext } from '@deriv/shared';
import { localize } from '@deriv/translations';
import { WS } from 'Services';
import { connect } from 'Stores/connect';
Expand Down Expand Up @@ -71,6 +71,7 @@ const AccountSignup = ({ enableApp, isModalVisible, clients_country, onSignup, r
setApiError(error);
} else {
isModalVisible(false);
SessionStore.remove('signup_query_param');
enableApp();
}
};
Expand Down
13 changes: 11 additions & 2 deletions packages/core/src/App/Containers/Modals/app-modals.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useLocation } from 'react-router-dom';
import { ContentFlag, moduleLoader } from '@deriv/shared';
import { ContentFlag, routes, moduleLoader, SessionStore } from '@deriv/shared';
import { connect } from 'Stores/connect';
import MT5Notification from './mt5-notification';
import MT5AccountNeededModal from 'App/Components/Elements/Modals/mt5-account-needed-modal.jsx';
Expand Down Expand Up @@ -61,6 +61,7 @@ const AppModals = ({
is_logged_in,
should_show_cooldown_modal,
should_show_assessment_complete_modal,
toggleAccountSignupModal,
is_trading_assessment_for_new_user_enabled,
fetchFinancialAssessment,
setCFDScore,
Expand All @@ -74,7 +75,8 @@ const AppModals = ({
should_show_risk_accept_modal,
is_need_real_account_for_cashier_modal_visible,
}) => {
const url_params = new URLSearchParams(useLocation().search);
const temp_session_signup_params = SessionStore.get('signup_query_param');
const url_params = new URLSearchParams(useLocation().search || temp_session_signup_params);
const url_action_param = url_params.get('action');

const is_eu_user = [ContentFlag.LOW_RISK_CR_EU, ContentFlag.EU_REAL, ContentFlag.EU_DEMO].includes(content_flag);
Expand All @@ -86,6 +88,12 @@ const AppModals = ({
});
}
}, [is_logged_in]);
if (temp_session_signup_params && window.location.href.includes(routes.onboarding)) {
toggleAccountSignupModal(true);
} else {
SessionStore.remove('signup_query_param');
toggleAccountSignupModal(false);
}

let ComponentToLoad = null;
switch (url_action_param) {
Expand Down Expand Up @@ -178,6 +186,7 @@ export default connect(({ client, ui, traders_hub }) => ({
setShouldShowVerifiedAccount: ui.setShouldShowVerifiedAccount,
should_show_cooldown_modal: ui.should_show_cooldown_modal,
should_show_assessment_complete_modal: ui.should_show_assessment_complete_modal,
toggleAccountSignupModal: ui.toggleAccountSignupModal,
is_trading_assessment_for_new_user_enabled: ui.is_trading_assessment_for_new_user_enabled,
active_account_landing_company: client.landing_company_shortcode,
is_deriv_account_needed_modal_visible: ui.is_deriv_account_needed_modal_visible,
Expand Down
24 changes: 7 additions & 17 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, SessionStore } from '@deriv/shared';
import { getLanguage } from '@deriv/translations';
import { connect } from 'Stores/connect';
import { WS } from 'Services';
Expand All @@ -23,7 +22,6 @@ const Redirect = ({
const url_query_string = window.location.search;
const url_params = new URLSearchParams(url_query_string);
let redirected_to_route = false;
const { is_appstore } = React.useContext(PlatformContext);
const action_param = url_params.get('action');
const code_param = url_params.get('code') || verification_code[action_param];

Expand All @@ -32,20 +30,12 @@ const Redirect = ({

switch (action_param) {
case 'signup': {
if (is_appstore) {
// TODO: redirect
// history.push({
// pathname: routes.dashboard,
// search: url_query_string,
// });
// redirected_to_route = true;
} else {
history.push({
pathname: routes.onboarding,
search: url_query_string,
});
}
sessionStorage.removeItem('redirect_url');
SessionStore.set('signup_query_param', url_query_string);
history.push({
pathname: routes.onboarding,
search: url_query_string,
});
SessionStore.remove('redirect_url');
redirected_to_route = true;
toggleAccountSignupModal(true);
break;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
removeCookies,
routes,
setCurrencies,
SessionStore,
toMoment,
urlForLanguage,
} from '@deriv/shared';
Expand Down Expand Up @@ -1573,7 +1574,7 @@ export default class ClientStore extends BaseStore {
* We initially fetch things from local storage, and then do everything inside the store.
*/
async init(login_new_user) {
const search = window.location.search;
const search = SessionStore.get('signup_query_param') || window.location.search;
const search_params = new URLSearchParams(search);
const redirect_url = search_params?.get('redirect_url');
const code_param = search_params?.get('code');
Expand Down

1 comment on commit 5d56e37

@vercel
Copy link

@vercel vercel bot commented on 5d56e37 Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-app – ./

binary.sx
deriv-app.vercel.app
deriv-app.binary.sx
deriv-app-git-master.binary.sx

Please sign in to comment.