Skip to content

Commit

Permalink
chore: [#3] added check against claim period for claim button
Browse files Browse the repository at this point in the history
  • Loading branch information
mdnorman committed May 13, 2022
1 parent f90d661 commit f211bb3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions components/ClaimButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import DefaultButton, { DefaultButtonProps } from './common/DefaultButton';
export interface ClaimButtonProps extends DefaultButtonProps {
allowance: number;
walletAlreadyClaimed: number;
withinClaimPeriod: boolean;
}

const ClaimButton = ({ allowance, walletAlreadyClaimed, disabled, ...rest }: ClaimButtonProps) => {
const ClaimButton = ({ allowance, walletAlreadyClaimed, withinClaimPeriod, disabled, ...rest }: ClaimButtonProps) => {
const getClaimButtonText = () => {
if (!withinClaimPeriod) {
return 'CLAIM PLOTS';
}

if (allowance > 0 && allowance > walletAlreadyClaimed) {
return `CLAIM ${allowance - walletAlreadyClaimed} PLOTS`;
}
Expand All @@ -20,7 +25,10 @@ const ClaimButton = ({ allowance, walletAlreadyClaimed, disabled, ...rest }: Cla
};

return (
<DefaultButton {...rest} disabled={disabled || (walletAlreadyClaimed === 0 && allowance === 0)}>
<DefaultButton
{...rest}
disabled={disabled || !withinClaimPeriod || (walletAlreadyClaimed === 0 && allowance === 0)}
>
{getClaimButtonText()}
</DefaultButton>
);
Expand Down
1 change: 1 addition & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const Home: NextPage = () => {
<ClaimButton
walletAlreadyClaimed={walletAlreadyClaimed}
allowance={allowance}
withinClaimPeriod={claimPeriodStart < Date.now() && claimPeriodEnd > Date.now()}
disabled={!address}
onClick={
walletAlreadyClaimed === 0 || walletAlreadyClaimed < allowance ? handleOpenClaimModal : showMintedNfts
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2737,7 +2737,7 @@
"resolved" "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz"
"version" "1.4.2"
dependencies:
"ethereumjs-abi" "git+https://github.com/ethereumjs/ethereumjs-abi.git"
"ethereumjs-abi" "0.6.8"
"ethereumjs-util" "^5.1.1"

"ethereum-bloom-filters@^1.0.6":
Expand Down

0 comments on commit f211bb3

Please sign in to comment.