Skip to content

Commit edf3aad

Browse files
committed
[BLD-396] Dashboard: Fix changing tabs in /nfts/<id> page shows full page loading indicator (#8224)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances the `TokenIdPage` component by introducing `Suspense` for improved loading state handling and adjusting the layout of the loading spinner. ### Detailed summary - Added `Suspense` for handling loading states. - Updated the loading spinner layout with additional padding (`py-20`). - Wrapped the tab rendering logic within the `Suspense` component for better user experience during data fetching. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced a loading experience for NFT tab content using Suspense, providing a fallback UI while content loads. - Improves responsiveness when switching tabs by deferring heavy content until ready. - Style - Increased vertical padding for the pending NFT state to enhance visual spacing and readability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent ab4190e commit edf3aad

File tree

1 file changed

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

1 file changed

+21
-10
lines changed

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { ExternalLinkIcon } from "lucide-react";
44
import Link from "next/link";
5-
import { useState } from "react";
5+
import { Suspense, useState } from "react";
66
import type { NFT, ThirdwebClient, ThirdwebContract } from "thirdweb";
77
import { getNFT as getErc721NFT } from "thirdweb/extensions/erc721";
88
import { getNFT as getErc1155NFT } from "thirdweb/extensions/erc1155";
@@ -89,7 +89,7 @@ export const TokenIdPage: React.FC<TokenIdPageProps> = ({
8989

9090
if (isPending) {
9191
return (
92-
<div className="flex h-[400px] items-center justify-center">
92+
<div className="flex h-[400px] items-center justify-center py-20">
9393
<Spinner className="size-10" />
9494
</div>
9595
);
@@ -179,15 +179,26 @@ export const TokenIdPage: React.FC<TokenIdPageProps> = ({
179179
<NFTDetailsTab client={contract.client} nft={nft} />
180180
)}
181181

182-
{tabs.map((tb) => {
183-
return (
184-
tb.title === tab && (
185-
<div className="w-full" key={tb.title}>
186-
{tb.children}
182+
<Suspense
183+
fallback={
184+
<div className="h-full">
185+
<div className="flex items-center gap-1.5">
186+
<Spinner className="size-4" />
187+
<p className="text-sm text-muted-foreground"> Loading </p>
187188
</div>
188-
)
189-
);
190-
})}
189+
</div>
190+
}
191+
>
192+
{tabs.map((tb) => {
193+
return (
194+
tb.title === tab && (
195+
<div className="w-full" key={tb.title}>
196+
{tb.children}
197+
</div>
198+
)
199+
);
200+
})}
201+
</Suspense>
191202
</div>
192203
</div>
193204
</div>

0 commit comments

Comments
 (0)