only close modal if deposit/withdraw is successful

This commit is contained in:
saml33 2022-12-18 00:01:33 +11:00
parent 13cdf408ef
commit 1a1e4bab9d
3 changed files with 11 additions and 10 deletions

View File

@ -137,6 +137,8 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
await actions.reloadMangoAccount()
actions.fetchWalletTokens(wallet!.adapter as unknown as Wallet)
setSubmitting(false)
onSuccess()
} catch (e: any) {
notify({
title: 'Transaction failed',
@ -145,9 +147,7 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
type: 'error',
})
console.error('Error depositing:', e)
} finally {
setSubmitting(false)
onSuccess()
}
}, [bank, wallet, inputAmount])

View File

@ -98,13 +98,14 @@ const TopBar = () => {
{/* <div className="px-3 md:px-4">
<ThemeSwitcher />
</div> */}
{connected ? (
<div className="flex items-center pr-4 md:pr-0">
<Button
disabled={!connected}
onClick={() => setShowDepositWithdrawModal(true)}
secondary
className="mx-4"
>{`${t('deposit')} / ${t('withdraw')}`}</Button>
{connected ? (
<div className="flex items-center pr-4 md:pr-0">
<button
className="hidden h-16 border-l border-th-bkg-3 px-4 md:block"
id="account-step-two"

View File

@ -101,7 +101,9 @@ function WithdrawForm({ onSuccess, token }: WithdrawFormProps) {
type: 'success',
txid: tx,
})
actions.reloadMangoAccount()
await actions.reloadMangoAccount()
setSubmitting(false)
onSuccess()
} catch (e: any) {
console.error(e)
notify({
@ -110,9 +112,7 @@ function WithdrawForm({ onSuccess, token }: WithdrawFormProps) {
txid: e?.txid,
type: 'error',
})
} finally {
setSubmitting(false)
onSuccess()
}
}, [bank, inputAmount])