Skip to content

Commit

Permalink
[Dashboard] Enhance NFT Reveal feature (#5862)
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
kien-ngo committed Jan 1, 2025
1 parent 7bb7107 commit 8136ec9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet";
import { ToolTipLabel } from "@/components/ui/tooltip";
import { MinterOnly } from "@3rdweb-sdk/react/components/roles/minter-only";
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
import { FormControl, Input, Select } from "@chakra-ui/react";
Expand Down Expand Up @@ -48,6 +49,27 @@ export const NFTRevealButton: React.FC<NFTRevealButtonProps> = ({

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

if (!batchesQuery.data?.length) {
return null;
}

/**
* When a batch is revealed / decrypted / non-revealable, its batchUri will be "0x"
*/
const allBatchesRevealed = batchesQuery.data.every(
(o) => o.batchUri === "0x",
);

if (allBatchesRevealed) {
return (
<ToolTipLabel label="All batches are revealed">
<Button variant="primary" className="gap-2" disabled>
<EyeIcon className="size-4" /> Reveal NFTs
</Button>
</ToolTipLabel>
);
}

return batchesQuery.data?.length ? (
<MinterOnly contract={contract}>
<Sheet open={open} onOpenChange={setOpen}>
Expand Down Expand Up @@ -109,9 +131,11 @@ export const NFTRevealButton: React.FC<NFTRevealButtonProps> = ({
<option
key={batch.batchId.toString()}
value={batch.batchId.toString()}
disabled={batch.batchUri === "0x"}
>
{batch.placeholderMetadata?.name ||
batch.batchId.toString()}
batch.batchId.toString()}{" "}
{batch.batchUri === "0x" && "(REVEALED)"}
</option>
))}
</Select>
Expand Down

0 comments on commit 8136ec9

Please sign in to comment.