Skip to content

Commit

Permalink
fix: fix issue where user is able to attempt to claim nft when they h…
Browse files Browse the repository at this point in the history
…ave no balance
  • Loading branch information
LordCheta committed Nov 27, 2024
1 parent 852fe3b commit 471a990
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pages/communities/nft/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CopyButton } from '@/components/CopyButton'
import { NftHoldersSection } from '@/app/communities/NftHoldersSection'
import { communitiesMapByContract } from '@/app/communities/communityUtils'
import { isUserRejectedTxError } from '@/components/ErrorPage/commonErrors'
import { useBalancesContext } from '@/app/user/Balances/context/BalancesContext'

/**
* Name of the local storage variable with information about whether the token was added to the wallet
Expand Down Expand Up @@ -188,6 +189,10 @@ export default function Page() {
}
}

const { balances } = useBalancesContext()
const { balance } = balances['RIF']
const hasEnoughBalance = Number(balance) > 0

if (!nftAddress) return null
return (
<MainContainer notProtected>
Expand Down Expand Up @@ -301,7 +306,7 @@ export default function Page() {
variant="primary"
className="my-[16px]"
onClick={handleMinting}
disabled={!tokensAvailable || !address || isClaiming}
disabled={!tokensAvailable || !address || isClaiming || !hasEnoughBalance}
loading={isClaiming}
data-testid="claimButton"
>
Expand Down

0 comments on commit 471a990

Please sign in to comment.