Skip to content

Commit

Permalink
george / PRODQA-1316 / Transfer from Tradershub validation (#9908)
Browse files Browse the repository at this point in the history
* fix: 🚑 fix active container for TH transfer, fix insufficient balance check

* test: 🐛 fix tests

* fix: 🚑 fix 'Insufficient balance' condition
  • Loading branch information
heorhi-deriv authored Aug 31, 2023
1 parent 7ae26aa commit a48f6cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('AccountTransferModal', () => {
is_transfer_confirm: false,
should_switch_account: false,
},
general_store: { setActiveTab: jest.fn() },
},
},
});
Expand All @@ -50,6 +51,7 @@ describe('AccountTransferModal', () => {
is_transfer_confirm: false,
should_switch_account: false,
},
general_store: { setActiveTab: jest.fn() },
},
},
});
Expand All @@ -76,6 +78,7 @@ describe('AccountTransferModal', () => {
is_transfer_confirm: false,
should_switch_account: true,
},
general_store: { setActiveTab: jest.fn() },
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const AccountTransferModal = observer(({ is_modal_open, toggleModal }: TAccountT
modules: {
cashier: {
account_transfer: { is_transfer_confirm, should_switch_account, setShouldSwitchAccount },
general_store: { setActiveTab },
},
},
traders_hub: { closeModal, setSelectedAccount },
Expand All @@ -24,13 +25,18 @@ const AccountTransferModal = observer(({ is_modal_open, toggleModal }: TAccountT
const history = useHistory();

React.useEffect(() => {
if (is_modal_open) setActiveTab('account_transfer');

return () => {
setShouldSwitchAccount(false);
setSelectedAccount({});
closeModal();
if (is_modal_open) {
setShouldSwitchAccount(false);
setSelectedAccount({});
setActiveTab('deposit');
closeModal();
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [is_modal_open]);

const modal_title = !is_transfer_confirm && <Localize i18n_default_text={'Transfer funds to your accounts'} />;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const AccountTransferForm = observer(
});
if (!is_ok) return message;

if (selected_from.balance && Number(selected_from.balance) < Number(amount))
if (typeof selected_from.balance !== 'undefined' && Number(selected_from.balance) < Number(amount))
return localize('Insufficient balance');

return undefined;
Expand Down

1 comment on commit a48f6cd

@vercel
Copy link

@vercel vercel bot commented on a48f6cd Aug 31, 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.binary.sx
deriv-app.vercel.app
binary.sx
deriv-app-git-master.binary.sx

Please sign in to comment.