Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
fix: clean inputs after add liquidity (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Jun 24, 2022
1 parent 8fcf321 commit a7fd488
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 7 additions & 4 deletions packages/app/src/systems/Pool/hooks/useAddLiquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -117,7 +121,6 @@ export function useAddLiquidity({

async function handleSettled() {
onSettle?.();
navigate('../');
setStage(0);
}

Expand Down
9 changes: 6 additions & 3 deletions packages/app/src/systems/Swap/pages/SwapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a7fd488

Please sign in to comment.