From a7fd488c7f3a40af53be745351da4f92bb0e0790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Est=C3=A1cio=20=7C=20stacio=2Eeth?= Date: Fri, 24 Jun 2022 18:05:43 -0300 Subject: [PATCH] fix: clean inputs after add liquidity (#347) --- .../app/src/systems/Pool/hooks/useAddLiquidity.ts | 11 +++++++---- packages/app/src/systems/Swap/pages/SwapPage.tsx | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/app/src/systems/Pool/hooks/useAddLiquidity.ts b/packages/app/src/systems/Pool/hooks/useAddLiquidity.ts index d84410c6..027db68f 100644 --- a/packages/app/src/systems/Pool/hooks/useAddLiquidity.ts +++ b/packages/app/src/systems/Pool/hooks/useAddLiquidity.ts @@ -94,9 +94,13 @@ export function useAddLiquidity({ ); function handleSuccess() { - fromInput.setAmount(BigInt(0)); - toInput.setAmount(BigInt(0)); - navigate('../'); + fromInput.setAmount(null); + toInput.setAmount(null); + // Clean state before navigate to next + // screen + setTimeout(() => { + navigate('../'); + }); } function handleError(e: any) { @@ -117,7 +121,6 @@ export function useAddLiquidity({ async function handleSettled() { onSettle?.(); - navigate('../'); setStage(0); } diff --git a/packages/app/src/systems/Swap/pages/SwapPage.tsx b/packages/app/src/systems/Swap/pages/SwapPage.tsx index 04b7ddf4..9268872f 100644 --- a/packages/app/src/systems/Swap/pages/SwapPage.tsx +++ b/packages/app/src/systems/Swap/pages/SwapPage.tsx @@ -103,15 +103,18 @@ export function SwapPage() { txCost, }); - const shouldDisableSwap = - isLoading || validationState !== ValidationStateEnum.Swap; + const shouldDisableSwap = !!( + isLoading || + validationState !== ValidationStateEnum.Swap || + !txCost.total || + txCost.error + ); const btnText = getValidationText(validationState, swapState); const { mutate: swap, isLoading: isSwapping } = useMutation( async () => { if (!swapState) return; - if (!txCost?.gas || txCost.error) return; setHasSwapped(false); const res = await swapTokens(contract, swapState, txCost); return res;