diff --git a/components/modals/RepayModal.tsx b/components/modals/RepayModal.tsx index 13487e76..3f56cd61 100644 --- a/components/modals/RepayModal.tsx +++ b/components/modals/RepayModal.tsx @@ -105,43 +105,47 @@ function RepayModal({ isOpen, onClose, token }: ModalCombinedProps) { setShowTokenList(false) } - const handleDeposit = useCallback(async () => { - const client = mangoStore.getState().client - const group = mangoStore.getState().group - const actions = mangoStore.getState().actions - const mangoAccount = mangoStore.getState().mangoAccount.current + const handleDeposit = useCallback( + async (amount: string) => { + const client = mangoStore.getState().client + const group = mangoStore.getState().group + const actions = mangoStore.getState().actions + const mangoAccount = mangoStore.getState().mangoAccount.current - if (!mangoAccount || !group || !bank || !wallet) return + if (!mangoAccount || !group || !bank || !wallet) return + console.log('inputAmount: ', amount) - try { - setSubmitting(true) - const tx = await client.tokenDeposit( - group, - mangoAccount, - bank.mint, - parseFloat(inputAmount) - ) - notify({ - title: 'Transaction confirmed', - type: 'success', - txid: tx, - }) + try { + setSubmitting(true) + const tx = await client.tokenDeposit( + group, + mangoAccount, + bank.mint, + parseFloat(amount) + ) + notify({ + title: 'Transaction confirmed', + type: 'success', + txid: tx, + }) - await actions.reloadMangoAccount() - actions.fetchWalletTokens(wallet.adapter as unknown as Wallet) - setSubmitting(false) - } catch (e: any) { - notify({ - title: 'Transaction failed', - description: e.message, - txid: e?.txid, - type: 'error', - }) - console.error('Error repaying:', e) - } + await actions.reloadMangoAccount() + actions.fetchWalletTokens(wallet.adapter as unknown as Wallet) + setSubmitting(false) + } catch (e: any) { + notify({ + title: 'Transaction failed', + description: e.message, + txid: e?.txid, + type: 'error', + }) + console.error('Error repaying:', e) + } - onClose() - }, [bank, wallet]) + onClose() + }, + [bank, wallet] + ) const banks = useMemo(() => { const banks = @@ -295,7 +299,7 @@ function RepayModal({ isOpen, onClose, token }: ModalCombinedProps) {