fix buy/sell links in actions menu

This commit is contained in:
tjs 2022-08-21 00:08:07 -04:00
parent c0341773e7
commit 8011f4ff8e
2 changed files with 11 additions and 4 deletions

View File

@ -392,6 +392,7 @@ const ActionsMenu = ({
const set = mangoStore.getState().set
const router = useRouter()
const { asPath } = router
const jupiterTokens = mangoStore((s) => s.jupiterTokens)
const handleShowActionModals = useCallback(
(token: string, action: 'borrow' | 'deposit' | 'withdraw') => {
@ -406,22 +407,30 @@ const ActionsMenu = ({
)
const handleBuy = useCallback(() => {
const outputTokenInfo = jupiterTokens.find(
(t: any) => t.address === bank.mint.toString()
)
set((s) => {
s.swap.outputBank = bank
s.swap.outputTokenInfo = outputTokenInfo
})
if (asPath === '/') {
router.push('/trade', undefined, { shallow: true })
}
}, [bank, router, asPath, set])
}, [bank, router, asPath, set, jupiterTokens])
const handleSell = useCallback(() => {
const inputTokenInfo = jupiterTokens.find(
(t: any) => t.address === bank.mint.toString()
)
set((s) => {
s.swap.inputBank = bank
s.swap.inputTokenInfo = inputTokenInfo
})
if (asPath === '/') {
router.push('/trade', undefined, { shallow: true })
}
}, [router, asPath, set, bank])
}, [router, asPath, set, bank, jupiterTokens])
return (
<>

View File

@ -3,12 +3,10 @@ import { useState } from 'react'
import Button, { LinkButton } from '../shared/Button'
import DepositModal from '../modals/DepositModal'
import WithdrawModal from '../modals/WithdrawModal'
import mangoStore from '../../store/mangoStore'
import {
DotsHorizontalIcon,
PencilIcon,
TrashIcon,
XIcon,
} from '@heroicons/react/solid'
import { useTranslation } from 'next-i18next'
import IconDropMenu from '../shared/IconDropMenu'