diff --git a/packages/cashier/src/stores/account-transfer-store.js b/packages/cashier/src/stores/account-transfer-store.js index 30c618e3c36a..484ffbbafb8b 100644 --- a/packages/cashier/src/stores/account-transfer-store.js +++ b/packages/cashier/src/stores/account-transfer-store.js @@ -12,6 +12,7 @@ import { getPropertyValue, validNumber, CFD_PLATFORMS, + routes, } from '@deriv/shared'; import { localize, Localize } from '@deriv/translations'; import Constants from '../constants/constants'; @@ -388,6 +389,9 @@ export default class AccountTransferStore { const arr_accounts = []; this.setSelectedTo({}); // set selected to empty each time so we can redetermine its value on reload + const is_from_pre_appstore = + this.root_store.client.is_pre_appstore && !location.pathname.startsWith(routes.cashier); + accounts.forEach(account => { const cfd_platforms = { mt5: { name: 'Deriv MT5', icon: 'IcMt5' }, @@ -482,8 +486,16 @@ export default class AccountTransferStore { // check if selected to is not allowed account obj_values.error = getSelectedError(obj_values.value); } - // set the first available account as the default transfer to account - this.setSelectedTo(obj_values); + + const { account_id, login } = this.root_store.traders_hub?.selected_account; + + //if from appstore -> set selected account as the default transfer to account + //if not from appstore -> set the first available account as the default transfer to account + if (!is_from_pre_appstore) { + this.setSelectedTo(obj_values); + } else if ([account_id, login].includes(account.loginid)) { + this.setSelectedTo(obj_values); + } } arr_accounts.push(obj_values); }); @@ -546,10 +558,9 @@ export default class AccountTransferStore { // not allowed to transfer from MT to MT // not allowed to transfer from Dxtrade to Dxtrade // not allowed to transfer between MT and Dxtrade - const first_non_cfd = this.accounts_list.find( - account => !account.is_mt && !account.is_dxtrade && !account.is_derivez - ); - this.onChangeTransferTo({ target: { value: first_non_cfd.value } }); + // if new value of selected_from is different from selected_to + // switch the value of selected_to to current client loginid + this.onChangeTransferTo({ target: { value: this.root_store.client.loginid } }); } if (hasTransferNotAllowedLoginid(selected_from.value)) {