From ad5e534a4d17871a43b75330af055626931d17cb Mon Sep 17 00:00:00 2001 From: Sergei Baranovski Date: Tue, 21 Feb 2023 12:24:39 +0300 Subject: [PATCH] fix: demo account total assets is always USD --- .../AccountSwitcher/account-switcher.jsx | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx b/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx index d2d78d270bf6..937e65ddddab 100644 --- a/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx +++ b/packages/core/src/App/Containers/AccountSwitcher/account-switcher.jsx @@ -42,8 +42,6 @@ const AccountSwitcher = props => { const [is_dxtrade_demo_visible, setDxtradeDemoVisible] = React.useState(true); const [is_dxtrade_real_visible, setDxtradeRealVisible] = React.useState(true); const [exchanged_rate_cfd_real, setExchangedRateCfdReal] = React.useState(1); - const [exchanged_rate_demo, setExchangedRateDemo] = React.useState(1); - const [exchanged_rate_cfd_demo, setExchangedRateCfdDemo] = React.useState(1); const [is_non_eu_regulator_visible, setNonEuRegulatorVisible] = React.useState(true); const [is_eu_regulator_visible, setEuRegulatorVisible] = React.useState(true); const [filtered_real_accounts, setFilteredRealAccounts] = React.useState([]); @@ -62,9 +60,6 @@ const AccountSwitcher = props => { const vrtc_loginid = props.account_list.find(account => account.is_virtual)?.loginid; const vrtc_currency = props.accounts[vrtc_loginid] ? props.accounts[vrtc_loginid].currency : 'USD'; - const cfd_demo_currency = - props.mt5_login_list.find(account => isDemo(account))?.currency || - props.dxtrade_accounts_list.find(account => isDemo(account))?.currency; React.useEffect(() => { if (getMaxAccountsDisplayed()) { @@ -83,12 +78,6 @@ const AccountSwitcher = props => { if (cfd_real_currency !== account_total_balance_currency) { getCurrentExchangeRate(cfd_real_currency, setExchangedRateCfdReal); } - if (vrtc_currency !== account_total_balance_currency) { - getCurrentExchangeRate(vrtc_currency, setExchangedRateDemo); - } - if (cfd_demo_currency !== account_total_balance_currency) { - getCurrentExchangeRate(cfd_demo_currency, setExchangedRateCfdDemo); - } if (props.is_low_risk || props.is_high_risk) { const real_accounts = getSortedAccountList(props.account_list, props.accounts).filter( account => !account.is_virtual && account.loginid.startsWith('CR') @@ -454,15 +443,12 @@ const AccountSwitcher = props => { const getTotalDemoAssets = () => { const vrtc_balance = props.accounts[vrtc_loginid] ? props.accounts[vrtc_loginid].balance : 0; - const mt5_demo_total = getTotalBalanceCfd(props.mt5_login_list, true, exchanged_rate_cfd_demo); - const dxtrade_demo_total = getTotalBalanceCfd(props.dxtrade_accounts_list, true, exchanged_rate_cfd_demo); - - const exchanged_balance = - vrtc_currency !== account_total_balance_currency ? vrtc_balance * exchanged_rate_demo : vrtc_balance; + const mt5_demo_total = getTotalBalanceCfd(props.mt5_login_list, true, 1); + const dxtrade_demo_total = getTotalBalanceCfd(props.dxtrade_accounts_list, true, 1); - const total = exchanged_balance + mt5_demo_total.balance + dxtrade_demo_total.balance; + const total = vrtc_balance + mt5_demo_total.balance + dxtrade_demo_total.balance; - return props.is_pre_appstore ? exchanged_balance : total; + return props.is_pre_appstore ? vrtc_balance : total; }; const getTotalRealAssets = () => { @@ -1253,9 +1239,9 @@ const AccountSwitcher = props => {