diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 077cc90..4119316 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ jobs: - name: Check out code uses: actions/checkout@v3 - name: Install dependencies - run: npm ci + run: yarn install --frozen-lockfile - name: Build - run: npm run build + run: yarn build - name: Lint - run: npm run lint + run: yarn lint diff --git a/components/ClaimButton.tsx b/components/ClaimButton.tsx new file mode 100644 index 0000000..eb701e2 --- /dev/null +++ b/components/ClaimButton.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import DefaultButton, { DefaultButtonProps } from './common/DefaultButton'; + +export interface ClaimButtonProps extends DefaultButtonProps { + allowance: number; + walletAlreadyClaimed: number; +} + +const ClaimButton = ({ allowance, walletAlreadyClaimed, disabled, ...rest }: ClaimButtonProps) => { + const getClaimButtonText = () => { + if (walletAlreadyClaimed === 0 && allowance === 0) { + return 'CLAIM PLOTS'; + } else if (walletAlreadyClaimed > 0) { + return `${walletAlreadyClaimed} PLOTS CLAIMED`; + } else if (allowance > 0) { + return `CLAIM ${allowance} PLOTS`; + } + return ''; + }; + + return ( + + {getClaimButtonText()} + + ); +}; +export default ClaimButton; diff --git a/components/common/DefaultButton.tsx b/components/common/DefaultButton.tsx new file mode 100644 index 0000000..4efe67d --- /dev/null +++ b/components/common/DefaultButton.tsx @@ -0,0 +1,8 @@ +import React from 'react'; + +export interface DefaultButtonProps extends React.ButtonHTMLAttributes {} + +const DefaultButton = ({ disabled, ...rest }: DefaultButtonProps) => ( + + onClick={walletAlreadyClaimed === 0 ? handleOpenClaimModal : showMintedNfts} + /> - - + + ); }; - export default Home;