Skip to content

Commit

Permalink
Allow inputting 0 to type decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
harryttd committed Oct 5, 2023
1 parent 61a0742 commit 11ab19f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/Faucet/FaucetRequestButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ export default function FaucetRequestButton({
setLocalLoading(false)
}

const validateAmount = (amount: number) =>
amount >= minTez && amount <= maxTez

const updateAmount = (e: React.ChangeEvent<HTMLInputElement>) => {
const value = Number(e.target.value.slice(0, 16))
if (value >= minTez && value <= maxTez) {
if (value === 0 || validateAmount(value)) {
setAmount(value)
}
}
Expand Down Expand Up @@ -281,7 +284,11 @@ export default function FaucetRequestButton({
</Col>

<Col xs={12} sm={6} className="d-flex justify-content-sm-end">
<Button variant="primary" disabled={disabled} onClick={getTez}>
<Button
variant="primary"
disabled={disabled || !validateAmount(amount)}
onClick={getTez}
>
<DropletFill />
&nbsp;
{isLocalLoading
Expand Down

0 comments on commit 11ab19f

Please sign in to comment.