Skip to content

Commit 4542a48

Browse files
committed
[Dashboard] Add tokenURI section to the NFT page (#5035)
<img width="1172" alt="image" src="https://github.com/user-attachments/assets/bef8ec5b-b453-43e1-bc90-f7156b3dd578"> <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances the `TokenIdPage` component by adding functionality for displaying and copying the token URI of an NFT. It introduces a `CopyTextButton` and a link that opens the token URI in a new tab, improving user interaction and accessibility. ### Detailed summary - Added import for `CopyTextButton`. - Added import for `ExternalLinkIcon`. - Introduced `Link` from `next/link`. - Added `token URI` section in the UI. - Implemented `CopyTextButton` to copy the `nft.tokenURI`. - Added a button with a link that opens the `nft.tokenURI` in a new tab. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 17127d7 commit 4542a48

File tree

1 file changed

+30
-1
lines changed
  • apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]

1 file changed

+30
-1
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/[tokenId]/token-id.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"use client";
22

33
import { WalletAddress } from "@/components/blocks/wallet-address";
4+
import { CopyTextButton } from "@/components/ui/CopyTextButton";
45
import { Spinner } from "@/components/ui/Spinner/Spinner";
6+
import { useThirdwebClient } from "@/constants/thirdweb.client";
57
import { useDashboardRouter } from "@/lib/DashboardRouter";
68
import {
79
Box,
@@ -15,15 +17,18 @@ import {
1517
useBreakpointValue,
1618
} from "@chakra-ui/react";
1719
import { useChainSlug } from "hooks/chains/chainSlug";
18-
import { ChevronLeftIcon } from "lucide-react";
20+
import { ChevronLeftIcon, ExternalLinkIcon } from "lucide-react";
21+
import Link from "next/link";
1922
import { useState } from "react";
2023
import type { ThirdwebContract } from "thirdweb";
2124
import { getNFT as getErc721NFT } from "thirdweb/extensions/erc721";
2225
import { getNFT as getErc1155NFT } from "thirdweb/extensions/erc1155";
2326
import { useReadContract } from "thirdweb/react";
27+
import { resolveScheme } from "thirdweb/storage";
2428
import { Badge, Button, Card, CodeBlock, Heading, Text } from "tw-components";
2529
import { AddressCopyButton } from "tw-components/AddressCopyButton";
2630
import { NFTMediaWithEmptyState } from "tw-components/nft-media";
31+
import { shortenString } from "utils/usedapp-external";
2732
import { NftProperty } from "../components/nft-property";
2833
import { useNFTDrawerTabs } from "./useNftDrawerTabs";
2934

@@ -65,6 +70,8 @@ export const TokenIdPage: React.FC<TokenIdPageProps> = ({
6570
tokenId,
6671
});
6772

73+
const client = useThirdwebClient();
74+
6875
const { data: nft, isPending } = useReadContract(
6976
isErc721 ? getErc721NFT : getErc1155NFT,
7077
{
@@ -240,6 +247,28 @@ export const TokenIdPage: React.FC<TokenIdPageProps> = ({
240247
</GridItem>
241248
</>
242249
)}
250+
<GridItem colSpan={4}>
251+
<Heading size="label.md">Token URI</Heading>
252+
</GridItem>
253+
<GridItem
254+
colSpan={8}
255+
className="flex flex-row items-center gap-1"
256+
>
257+
<CopyTextButton
258+
textToCopy={nft.tokenURI}
259+
textToShow={shortenString(nft.tokenURI)}
260+
tooltip="The URI of this NFT"
261+
copyIconPosition="right"
262+
/>
263+
<Button variant="ghost">
264+
<Link
265+
href={resolveScheme({ client, uri: nft.tokenURI })}
266+
target="_blank"
267+
>
268+
<ExternalLinkIcon className="size-4" />
269+
</Link>
270+
</Button>
271+
</GridItem>
243272
</SimpleGrid>
244273
</Card>
245274
{properties ? (

0 commit comments

Comments
 (0)