add loading spinner when claiming mngo rewards

This commit is contained in:
Tyler Shipe 2021-12-03 18:33:28 -05:00
parent 3ce0e1580e
commit 5604423709
2 changed files with 17 additions and 14 deletions

View File

@ -26,6 +26,7 @@ import { useViewport } from '../hooks/useViewport'
import { breakpoints } from './TradePageGrid'
import { useTranslation } from 'next-i18next'
import useMangoAccount from '../hooks/useMangoAccount'
import Loading from './Loading'
const I80F48_100 = I80F48.fromString('100')
@ -40,6 +41,7 @@ export default function AccountInfo() {
const actions = useMangoStore((s) => s.actions)
const { width } = useViewport()
const isMobile = width ? width < breakpoints.sm : false
const [redeeming, setRedeeming] = useState(false)
const [showDepositModal, setShowDepositModal] = useState(false)
const [showWithdrawModal, setShowWithdrawModal] = useState(false)
@ -69,6 +71,7 @@ export default function AccountInfo() {
mangoGroup.rootBankAccounts[MNGO_INDEX].nodeBankAccounts[0]
try {
setRedeeming(true)
const txid = await mangoClient.redeemAllMngo(
mangoGroup,
mangoAccount,
@ -91,6 +94,7 @@ export default function AccountInfo() {
})
} finally {
actions.reloadMangoAccount()
setRedeeming(false)
}
}
@ -261,13 +265,17 @@ export default function AccountInfo() {
) : (
0
)}
<LinkButton
onClick={handleRedeemMngo}
className="ml-2 text-th-primary text-xs disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:underline"
disabled={mngoAccrued.eq(ZERO_BN)}
>
{t('claim')}
</LinkButton>
{redeeming ? (
<Loading className="ml-2" />
) : (
<LinkButton
onClick={handleRedeemMngo}
className="ml-2 text-th-primary text-xs disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:underline"
disabled={mngoAccrued.eq(ZERO_BN)}
>
{t('claim')}
</LinkButton>
)}
</div>
</div>
</div>

View File

@ -997,7 +997,7 @@
"@blockworks-foundation/mango-client@git+https://github.com/blockworks-foundation/mango-client-v3.git":
version "3.2.13"
resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#d4a90b154d527f97961b122c8a32931381a34222"
resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#5bfe5f092e5d6ff1b41290eb320206d625522554"
dependencies:
"@project-serum/anchor" "^0.16.2"
"@project-serum/serum" "0.13.55"
@ -2483,16 +2483,11 @@ bindings@^1.3.0:
dependencies:
file-uri-to-path "1.0.0"
bn.js@5.1.3, bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9, bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.1, bn.js@^5.1.2:
bn.js@5.1.3, bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9, bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.1, bn.js@^5.1.2, bn.js@^5.2.0:
version "5.1.3"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b"
integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==
bn.js@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002"
integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==
boolbase@^1.0.0, boolbase@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"