Skip to content

Commit

Permalink
Thisyahlen/exittradershub (#7490)
Browse files Browse the repository at this point in the history
* fix: exit traders hub

* fix: exit traders hub

* fix: exit v2

* fix: exit remove async v3

* fix: remove await

* fix: account switcher now showing currencies

---------

Co-authored-by: vinu-deriv <100689171+vinu-deriv@users.noreply.github.com>
  • Loading branch information
thisyahlen-deriv and vinu-deriv committed Feb 3, 2023
1 parent eb178dd commit b03b9cf
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const AccountSwitcher = props => {
if (cfd_demo_currency !== account_total_balance_currency) {
getCurrentExchangeRate(cfd_demo_currency, setExchangedRateCfdDemo);
}
if (props.is_low_risk) {
if (props.is_low_risk || props.is_high_risk || props.is_eu) {
const real_accounts = getSortedAccountList(props.account_list, props.accounts).filter(
account => !account.is_virtual && account.loginid.startsWith('CR')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const DefaultHeader = ({
toggleAccountsDialog,
toggleNotifications,
is_landing_company_loaded,
is_switching,
}) => {
const addUpdateNotification = () => addNotificationMessage(client_notifications.new_version_available);
const removeUpdateNotification = React.useCallback(
Expand Down Expand Up @@ -154,7 +155,7 @@ const DefaultHeader = ({
'header__menu-right--hidden': isMobile() && is_logging_in,
})}
>
{is_logging_in && (
{(is_logging_in || is_switching) && (
<div
id='dt_core_header_acc-info-preloader'
className={classNames('acc-info__preloader', {
Expand Down Expand Up @@ -237,6 +238,7 @@ DefaultHeader.propTypes = {
menu_items: PropTypes.array,
setIsPreAppStore: PropTypes.func,
is_landing_company_loaded: PropTypes.bool,
is_switching: PropTypes.bool,
};

export default connect(({ client, common, ui, menu, modules, notifications }) => ({
Expand Down Expand Up @@ -274,4 +276,5 @@ export default connect(({ client, common, ui, menu, modules, notifications }) =>
is_trading_assessment_for_existing_user_enabled: ui.is_trading_assessment_for_existing_user_enabled,
is_landing_company_loaded: client.is_landing_company_loaded,
setIsPreAppStore: client.setIsPreAppStore,
is_switching: client.is_switching,
}))(withRouter(DefaultHeader));
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const DTraderHeader = ({
removeNotificationMessage,
toggleAccountsDialog,
toggleNotifications,
is_switching,
}) => {
const addUpdateNotification = () => addNotificationMessage(client_notifications.new_version_available);
const removeUpdateNotification = React.useCallback(
Expand Down Expand Up @@ -124,7 +125,7 @@ const DTraderHeader = ({
<Divider />
</div>
</DesktopWrapper>
{is_logging_in && (
{(is_logging_in || is_switching) && (
<div
id='dt_core_header_acc-info-preloader'
className={classNames('acc-info__preloader__dtrader', {
Expand Down Expand Up @@ -201,6 +202,7 @@ DTraderHeader.propTypes = {
history: PropTypes.object,
menu_items: PropTypes.array,
is_pre_appstore: PropTypes.bool,
is_switching: PropTypes.bool,
};

export default connect(({ client, common, ui, menu, modules, notifications }) => ({
Expand Down Expand Up @@ -237,4 +239,5 @@ export default connect(({ client, common, ui, menu, modules, notifications }) =>
toggleAccountsDialog: ui.toggleAccountsDialog,
toggleNotifications: notifications.toggleNotificationsModal,
is_pre_appstore: client.is_pre_appstore,
is_switching: client.is_switching,
}))(withRouter(DTraderHeader));
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const ExitTradersHubModal = ({
switchAccount,
account_list,
active_accounts,
setIsLoggingIn,
}) => {
const history = useHistory();

Expand Down Expand Up @@ -42,17 +43,20 @@ const ExitTradersHubModal = ({
};

const onClickExitButton = async () => {
setIsPreAppStore(false);
setIsLoggingIn(true);
const cr_account = active_accounts.some(acc => acc.landing_company_shortcode === 'svg');
toggleExitTradersHubModal();

if (content_flag === ContentFlag.LOW_RISK_CR_EU) {
if (!cr_account) {
await switchAccount(account_list.find(acc => acc.loginid.startsWith('VRTC'))?.loginid);
}
//if eu is currently selected , switch to non-eu on exiting tradershub
await switchAccount(account_list.find(acc => acc.loginid.startsWith('CR'))?.loginid);
}
setIsPreAppStore(false);
history.push(routes.root);
setIsLoggingIn(false);
};

return (
Expand Down Expand Up @@ -98,4 +102,5 @@ export default connect(({ ui, client, traders_hub }) => ({
switchAccount: client.switchAccount,
account_list: client.account_list,
active_accounts: client.active_accounts,
setIsLoggingIn: client.setIsLoggingIn,
}))(ExitTradersHubModal);
19 changes: 10 additions & 9 deletions packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2561,15 +2561,16 @@ export default class ClientStore extends BaseStore {

setIsPreAppStore(is_pre_appstore) {
const trading_hub = is_pre_appstore ? 1 : 0;
WS.setSettings({
set_settings: 1,
trading_hub,
}).then(response => {
if (!response.error) {
this.account_settings = { ...this.account_settings, trading_hub };
localStorage.setItem('is_pre_appstore', is_pre_appstore);
}
});
try {
WS.setSettings({
set_settings: 1,
trading_hub,
});
} catch (error) {
return;
}
this.account_settings = { ...this.account_settings, trading_hub };
localStorage.setItem('is_pre_appstore', is_pre_appstore);
}
}
/* eslint-enable */

1 comment on commit b03b9cf

@vercel
Copy link

@vercel vercel bot commented on b03b9cf Feb 3, 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 – ./

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

Please sign in to comment.