Skip to content

Commit

Permalink
Merge branch 'feature/82781/diel_for_all' of github.com:matin-deriv/d…
Browse files Browse the repository at this point in the history
…eriv-app into topup
  • Loading branch information
jim-deriv committed Jan 10, 2023
2 parents 2bae223 + 6cb7890 commit 4d45c43
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { localize } from '@deriv/translations';
const DemoAccountCard = () => {
const { client, traders_hub } = useStores();
const { accounts, loginid, resetVirtualBalance } = client;
const {
platform_demo_balance: { currency, balance },
selected_account_type,
} = traders_hub;
const { platform_demo_balance, selected_account_type } = traders_hub;

const canResetBalance = () => {
return accounts[loginid]?.balance !== 10000;
Expand All @@ -36,7 +33,7 @@ const DemoAccountCard = () => {
)
}
>
<BalanceText currency={currency} balance={balance} size='xs' />
<BalanceText currency={platform_demo_balance.currency} balance={platform_demo_balance.balance} size='xs' />
</CurrencySwitcherContainer>
);
};
Expand Down
16 changes: 14 additions & 2 deletions packages/core/src/Stores/traders-hub-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default class TradersHubStore extends BaseStore {
reaction(
() => [
this.root_store.client.balance,
this.root_store.client.loginid,
this.root_store.client.obj_total_balance,
this.root_store.client.mt5_login_list,
this.root_store.client.dxtrade_accounts_list,
Expand Down Expand Up @@ -348,17 +349,28 @@ export default class TradersHubStore extends BaseStore {
}

getExistingAccounts(platform, market_type) {
const { residence } = this.root_store.client;
const current_list = this.root_store.modules?.cfd?.current_list || [];
const current_list_keys = Object.keys(current_list);
const selected_account_type = this.selected_account_type;
const existing_accounts = current_list_keys
.filter(key => {
if (platform === CFD_PLATFORMS.MT5) {
const maltainvest_account = current_list[key].landing_company_short === 'maltainvest';

if (platform === CFD_PLATFORMS.MT5 && !this.is_eu_user && !maltainvest_account) {
return key.startsWith(`${platform}.${selected_account_type}.${market_type}`);
}
if (platform === CFD_PLATFORMS.DXTRADE && market_type === 'all') {
return key.startsWith(`${platform}.${selected_account_type}.${platform}@${market_type}`);
}
if (
platform === CFD_PLATFORMS.MT5 &&
(this.is_eu_user || isEuCountry(residence)) &&
maltainvest_account
) {
return key.startsWith(`${platform}.${selected_account_type}.${market_type}`);
}

return key.startsWith(`${platform}.${selected_account_type}.${market_type}@${market_type}`);
})
.reduce((_acc, cur) => {
Expand Down Expand Up @@ -610,7 +622,7 @@ export default class TradersHubStore extends BaseStore {
exchange_rate = await getExchangeRate(currency, base_currency);
}

total.balance += balance * exchange_rate || 0;
(await total).balance += balance * exchange_rate || 0;
return total;
},
{ balance: 0 }
Expand Down

0 comments on commit 4d45c43

Please sign in to comment.