Skip to content

Commit

Permalink
Added error checking when custom amount is greater than Max available
Browse files Browse the repository at this point in the history
  • Loading branch information
kirksgithub committed Oct 16, 2023
1 parent 7e0d4d6 commit 42f9c4f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/DepositTokensButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ export const DepositTokensButton = ({
<div className="flex flex-col gap-y-4">
<h2>Deposit tokens</h2>
<label>
Amount to deposit - <a href="#" onClick={() => { setAmount(humanReadableMax ? humanReadableMax.toString() : '') }}>Max</a>
Amount to deposit
{(!amount || amount.length < 0 || parseInt(amount) < humanReadableMax) &&
<>
&nbsp;-&nbsp;<a href="#" onClick={() => { setAmount(humanReadableMax ? humanReadableMax.toString() : '') }}>Max</a>
</>}
</label>
<Input
placeholder={humanReadableMax?.toString() + ' (max)'}
Expand All @@ -85,6 +89,7 @@ export const DepositTokensButton = ({
await deposit(nativeAmount)
setOpenModal(false)
}}
disabled={parseInt(amount) > humanReadableMax}
>
Confirm
</Button>
Expand Down

0 comments on commit 42f9c4f

Please sign in to comment.