Skip to content

Commit

Permalink
chore: [#3] don't try to go to show minted NFTs when more to claim
Browse files Browse the repository at this point in the history
  • Loading branch information
mdnorman committed May 12, 2022
1 parent fc466e0 commit 92c96fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 8 additions & 7 deletions components/ClaimButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ export interface ClaimButtonProps extends DefaultButtonProps {

const ClaimButton = ({ allowance, walletAlreadyClaimed, disabled, ...rest }: ClaimButtonProps) => {
const getClaimButtonText = () => {
if (walletAlreadyClaimed === 0 && allowance === 0) {
return 'CLAIM PLOTS';
} else if (walletAlreadyClaimed > 0) {
if (allowance > 0 && allowance > walletAlreadyClaimed) {
return `CLAIM ${allowance - walletAlreadyClaimed} PLOTS`;
}

if (walletAlreadyClaimed > 0) {
return `${walletAlreadyClaimed} PLOTS CLAIMED`;
} else if (allowance > 0) {
return `CLAIM ${allowance} PLOTS`;
}
return '';

return 'CLAIM PLOTS';
};

return (
<DefaultButton {...rest} disabled={disabled || allowance === 0}>
<DefaultButton {...rest} disabled={disabled || (walletAlreadyClaimed === 0 && allowance === 0)}>
{getClaimButtonText()}
</DefaultButton>
);
Expand Down
4 changes: 3 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ const Home: NextPage = () => {
walletAlreadyClaimed={walletAlreadyClaimed}
allowance={allowance}
disabled={!address}
onClick={walletAlreadyClaimed === 0 ? handleOpenClaimModal : showMintedNfts}
onClick={
walletAlreadyClaimed === 0 || walletAlreadyClaimed < allowance ? handleOpenClaimModal : showMintedNfts
}
/>
<ParcelProperties parcelProperties={parcelProperties} />
</div>
Expand Down

0 comments on commit 92c96fc

Please sign in to comment.