Skip to content

Commit df04c53

Browse files
committed
[Dashboard] Fix NFT supply info
1 parent cc47b7b commit df04c53

File tree

1 file changed

+17
-4
lines changed
  • apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components

1 file changed

+17
-4
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
"use client";
22

33
import { Skeleton, Stat, StatLabel, StatNumber } from "@chakra-ui/react";
4+
import { useMemo } from "react";
45
import type { ThirdwebContract } from "thirdweb";
5-
import { nextTokenIdToMint, totalSupply } from "thirdweb/extensions/erc721";
6+
import {
7+
nextTokenIdToMint,
8+
startTokenId,
9+
totalSupply,
10+
} from "thirdweb/extensions/erc721";
611
import { useReadContract } from "thirdweb/react";
712
import { Card } from "tw-components";
813

@@ -18,9 +23,17 @@ export const SupplyCards: React.FC<SupplyCardsProps> = ({ contract }) => {
1823
contract,
1924
});
2025

21-
const unclaimedSupply = (
22-
(totalSupplyQuery?.data || 0n) - (claimedSupplyQuery?.data || 0n)
23-
).toString();
26+
const startTokenIdQuery = useReadContract(startTokenId, { contract });
27+
28+
const unclaimedSupply = useMemo(
29+
() =>
30+
(
31+
(totalSupplyQuery?.data || 0n) -
32+
(claimedSupplyQuery?.data || 0n) -
33+
(startTokenIdQuery.data || 0n)
34+
).toString(),
35+
[totalSupplyQuery.data, claimedSupplyQuery.data, startTokenIdQuery.data],
36+
);
2437

2538
return (
2639
<div className="flex flex-col gap-3 md:flex-row md:gap-6">

0 commit comments

Comments
 (0)