|
8 | 8 | SheetTitle,
|
9 | 9 | SheetTrigger,
|
10 | 10 | } from "@/components/ui/sheet";
|
| 11 | +import { ToolTipLabel } from "@/components/ui/tooltip"; |
11 | 12 | import { MinterOnly } from "@3rdweb-sdk/react/components/roles/minter-only";
|
12 | 13 | import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
|
13 | 14 | import { FormControl, Input, Select } from "@chakra-ui/react";
|
@@ -48,6 +49,27 @@ export const NFTRevealButton: React.FC<NFTRevealButtonProps> = ({
|
48 | 49 |
|
49 | 50 | const [open, setOpen] = useState(false);
|
50 | 51 |
|
| 52 | + if (!batchesQuery.data?.length) { |
| 53 | + return null; |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * When a batch is revealed / decrypted / non-revealable, its batchUri will be "0x" |
| 58 | + */ |
| 59 | + const allBatchesRevealed = batchesQuery.data.every( |
| 60 | + (o) => o.batchUri === "0x", |
| 61 | + ); |
| 62 | + |
| 63 | + if (allBatchesRevealed) { |
| 64 | + return ( |
| 65 | + <ToolTipLabel label="All batches are revealed"> |
| 66 | + <Button variant="primary" className="gap-2" disabled> |
| 67 | + <EyeIcon className="size-4" /> Reveal NFTs |
| 68 | + </Button> |
| 69 | + </ToolTipLabel> |
| 70 | + ); |
| 71 | + } |
| 72 | + |
51 | 73 | return batchesQuery.data?.length ? (
|
52 | 74 | <MinterOnly contract={contract}>
|
53 | 75 | <Sheet open={open} onOpenChange={setOpen}>
|
@@ -109,9 +131,11 @@ export const NFTRevealButton: React.FC<NFTRevealButtonProps> = ({
|
109 | 131 | <option
|
110 | 132 | key={batch.batchId.toString()}
|
111 | 133 | value={batch.batchId.toString()}
|
| 134 | + disabled={batch.batchUri === "0x"} |
112 | 135 | >
|
113 | 136 | {batch.placeholderMetadata?.name ||
|
114 |
| - batch.batchId.toString()} |
| 137 | + batch.batchId.toString()}{" "} |
| 138 | + {batch.batchUri === "0x" && "(REVEALED)"} |
115 | 139 | </option>
|
116 | 140 | ))}
|
117 | 141 | </Select>
|
|
0 commit comments