Skip to content

Commit 8136ec9

Browse files
committed
[Dashboard] Enhance NFT Reveal feature (#5862)
TOOL-2730 TOOL-2733 TOOL-2738 [x] Dont show Reveal-button if nothing to reveal [x] Dont allow to select batches that were revealed already [x] Show UI for the un-revealed. metadata <!-- start pr-codex --> --- ## PR-Codex overview This PR updates the `nfts/components/reveal-button.tsx` file to enhance the NFT reveal functionality by adding a tooltip and handling cases for revealed batches. It also modifies a comment in `next-env.d.ts` to point to the correct documentation link. ### Detailed summary - Updated documentation link in `next-env.d.ts`. - Imported `ToolTipLabel` in `nfts/components/reveal-button.tsx`. - Added a check to return `null` if no batches are available. - Implemented logic to display a tooltip and disabled button when all batches are revealed. - Disabled options in the select dropdown for revealed batches. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 7bb7107 commit 8136ec9

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

apps/dashboard/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/// <reference types="next/navigation-types/compat/navigation" />
44

55
// NOTE: This file should not be edited
6-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
6+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/reveal-button.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
SheetTitle,
99
SheetTrigger,
1010
} from "@/components/ui/sheet";
11+
import { ToolTipLabel } from "@/components/ui/tooltip";
1112
import { MinterOnly } from "@3rdweb-sdk/react/components/roles/minter-only";
1213
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
1314
import { FormControl, Input, Select } from "@chakra-ui/react";
@@ -48,6 +49,27 @@ export const NFTRevealButton: React.FC<NFTRevealButtonProps> = ({
4849

4950
const [open, setOpen] = useState(false);
5051

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+
5173
return batchesQuery.data?.length ? (
5274
<MinterOnly contract={contract}>
5375
<Sheet open={open} onOpenChange={setOpen}>
@@ -109,9 +131,11 @@ export const NFTRevealButton: React.FC<NFTRevealButtonProps> = ({
109131
<option
110132
key={batch.batchId.toString()}
111133
value={batch.batchId.toString()}
134+
disabled={batch.batchUri === "0x"}
112135
>
113136
{batch.placeholderMetadata?.name ||
114-
batch.batchId.toString()}
137+
batch.batchId.toString()}{" "}
138+
{batch.batchUri === "0x" && "(REVEALED)"}
115139
</option>
116140
))}
117141
</Select>

0 commit comments

Comments
 (0)