From 8d43b0a8d78fbca4b575d09018eac20a43b31a9d Mon Sep 17 00:00:00 2001 From: Polybius93 Date: Thu, 12 Dec 2024 15:56:01 +0100 Subject: [PATCH] fix: add useEffect to set isSubmitting false when step reaches pending --- .../deposit-transaction-screen.tsx | 9 ++++++++- .../components/unmint/components/withdraw-screen.tsx | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/components/mint-unmint/components/deposit-transaction-screen/deposit-transaction-screen.tsx b/src/app/components/mint-unmint/components/deposit-transaction-screen/deposit-transaction-screen.tsx index a136cf8f..7f19585b 100644 --- a/src/app/components/mint-unmint/components/deposit-transaction-screen/deposit-transaction-screen.tsx +++ b/src/app/components/mint-unmint/components/deposit-transaction-screen/deposit-transaction-screen.tsx @@ -1,4 +1,4 @@ -import { useContext, useState } from 'react'; +import { useContext, useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { VStack, useToast } from '@chakra-ui/react'; @@ -46,6 +46,13 @@ export function DepositTransactionScreen({ const [isSubmitting, setIsSubmitting] = useState(false); + useEffect(() => { + if (mintStep.step === MintSteps.PENDING) { + setIsSubmitting(false); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [mintStep.step]); + async function handleDeposit(depositAmount: number) { if (!currentVault) return; diff --git a/src/app/components/mint-unmint/components/unmint/components/withdraw-screen.tsx b/src/app/components/mint-unmint/components/unmint/components/withdraw-screen.tsx index 3327bace..01df5521 100644 --- a/src/app/components/mint-unmint/components/unmint/components/withdraw-screen.tsx +++ b/src/app/components/mint-unmint/components/unmint/components/withdraw-screen.tsx @@ -1,4 +1,4 @@ -import { useContext, useState } from 'react'; +import { useContext, useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { VStack, useToast } from '@chakra-ui/react'; @@ -36,6 +36,13 @@ export function WithdrawScreen({ const [isSubmitting, setIsSubmitting] = useState(false); + useEffect(() => { + if (unmintStep.step === RedeemSteps.PENDING) { + setIsSubmitting(false); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [unmintStep.step]); + async function handleWithdraw(withdrawAmount: number): Promise { if (currentVault) { try {