Skip to content

Commit

Permalink
george / PRODQA-1316 / Transfer from Tradershub validation (binary-co…
Browse files Browse the repository at this point in the history
…m#9908)

* 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 and vinu-deriv committed Sep 1, 2023
1 parent 7da5cb6 commit 2231593
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

0 comments on commit 2231593

Please sign in to comment.