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

View File

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

View File

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