Skip to content

Commit

Permalink
Fix uncleared form on submit (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-aac authored May 18, 2022
1 parent fd14f1c commit 32a9eda
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/web/src/components/dashboard/sale-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { media } from 'src/styles/breakpoints';
import { useFractalKYCUrl } from 'src/hooks/use-kyc-url';
import { useSaleBuy } from 'src/hooks/use-sale';
import BigNumber from 'bignumber.js';
import React, { useCallback, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import styled from 'styled-components';

/**
Expand Down Expand Up @@ -98,7 +98,7 @@ function getFieldError(amount: string) {
export function SaleForm(props: Props) {
const [amount, setAmount] = useState<string>('');
const { disabled, tokenPrice } = props;
const { isPending, run: buy } = useSaleBuy();
const { isPending, isResolved, run: buy } = useSaleBuy();
const fieldError = getFieldError(amount);
const kycUrl = useFractalKYCUrl();
const handleOnChange = useCallback(event => {
Expand All @@ -112,6 +112,12 @@ export function SaleForm(props: Props) {
.toString();
}, [amount, tokenPrice]);

useEffect(() => {
if (isResolved) {
setAmount('');
}
}, [isResolved]);

return (
<Wrapper>
{disabled && (
Expand Down

1 comment on commit 32a9eda

@vercel
Copy link

@vercel vercel bot commented on 32a9eda May 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

discovery-dao – ./

discovery-dao-untile.vercel.app
discovery-dao-git-main-untile.vercel.app
discovery-dao.vercel.app

Please sign in to comment.