diff --git a/components/NftCard.tsx b/components/NftCard.tsx index 6a6227c..45c3325 100644 --- a/components/NftCard.tsx +++ b/components/NftCard.tsx @@ -1,41 +1,66 @@ import { useConnection } from '@solana/wallet-adapter-react' -import { Link, Button, Text, IconButton } from '@primer/react' +import { Link, Text, Button, Spinner } from '@primer/react' import { FC } from 'react' import { LinkExternalIcon } from '@primer/octicons-react' import Image from 'next/image' +import { VariantType } from '@primer/react/lib/Button/types' -const NftCard: FC<{ title: string; imageLink: string; hash?: string }> = ({ title, imageLink, hash }) => { +const NftCard: FC<{ + title: string + imageLink?: string + buttons?: { + text: string + as: 'link' | 'button' + hash?: string + isLoading?: boolean + variant: VariantType + onClick?: () => void + }[] +}> = ({ title, imageLink, buttons }) => { const { connection } = useConnection() - const image = imageLink !== '' ? imageLink : '/default-image.png' return (
{title}
- {title} + {imageLink?.length && {title}}
- {hash && ( - - - - )} + ))} + {buttons + ?.filter((btn) => btn.as === 'link') + .map((btn, i) => ( + + + + ))}
) } diff --git a/pages/[id].tsx b/pages/[id].tsx index aeeb942..2d45a1b 100644 --- a/pages/[id].tsx +++ b/pages/[id].tsx @@ -21,6 +21,7 @@ import { useEffect, useState } from 'react' import { useSetRecoilState } from 'recoil' import { nftsState } from 'lib/recoil-store/atoms' import { getAllNftsByCM, getNftByMint } from 'lib/nft/actions' +import { useMintCandyMachine } from 'hooks' const CandyMachine: NextPage = () => { const router = useRouter() @@ -36,6 +37,9 @@ const CandyMachine: NextPage = () => { const [isLoading, setIsLoading] = useState(false) const [isReloading, setIsReloading] = useState(false) const setNftsState = useSetRecoilState(nftsState) + const { isUserMinting, itemsRemaining, mintAccount, refreshCandyMachineState } = useMintCandyMachine( + candyMachineAccount as string + ) const [hasCollection, setHasCollection] = useState(false) async function viewNfts(e: React.ChangeEvent) { @@ -126,6 +130,7 @@ const CandyMachine: NextPage = () => { } useEffect(() => { + refreshCandyMachineState() getNfts() fetchCandyMachine({ candyMachineAccount, connection }).then(setCandyMachineConfig) // eslint-disable-next-line react-hooks/exhaustive-deps @@ -226,7 +231,14 @@ const CandyMachine: NextPage = () => { )} @@ -235,30 +247,79 @@ const CandyMachine: NextPage = () => {

Minted NFTs - 5

+ {itemsRemaining > 0 && ( + mintAccount(), + }, + ]} + /> + )}
@@ -268,27 +329,62 @@ const CandyMachine: NextPage = () => { diff --git a/public/default-image.png b/public/default-image.png deleted file mode 100644 index 5f313f0..0000000 Binary files a/public/default-image.png and /dev/null differ