Skip to content

Commit

Permalink
fix(PoolStep): parse amount to float
Browse files Browse the repository at this point in the history
  • Loading branch information
FBalint committed Jul 18, 2024
1 parent aed11c0 commit 78d346a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const PoolStep = ({ onSubmit }: { onSubmit: () => void }) => {
const { chainId, address: userAddress } = useAccount()
const {
field: { value: amount },
} = useController({ name: "amount" })
} = useController({ name: "amount", defaultValue: "1" })

const [skip, setSkip] = useState(false)

Expand Down Expand Up @@ -116,6 +116,8 @@ const PoolStep = ({ onSubmit }: { onSubmit: () => void }) => {
setSkip(!skip)
}

const willDepositTokens = !!amount ? parseFloat(amount) > 0 : false

return (
<Stack gap={5}>
<Text colorScheme="gray">
Expand Down Expand Up @@ -159,11 +161,11 @@ const PoolStep = ({ onSubmit }: { onSubmit: () => void }) => {
</Stack>

<Stack>
<Collapse in={!isOnCorrectChain && amount !== "0"}>
<Collapse in={!isOnCorrectChain && willDepositTokens}>
<SwitchNetworkButton targetChainId={Number(Chains[chain])} />
</Collapse>

<Collapse in={isOnCorrectChain && amount !== "0"}>
<Collapse in={isOnCorrectChain && willDepositTokens}>
<AllowanceButton
chain={chain}
token={tokenAddress}
Expand All @@ -174,7 +176,7 @@ const PoolStep = ({ onSubmit }: { onSubmit: () => void }) => {
<Collapse
in={
(!!allowance || pickedCurrencyIsNative) &&
(isOnCorrectChain || amount === "0")
(isOnCorrectChain || !willDepositTokens)
}
>
<Button
Expand Down

0 comments on commit 78d346a

Please sign in to comment.