From ccff347d9696cf73548ae2c7ed6970de31b238e8 Mon Sep 17 00:00:00 2001 From: MananTank Date: Tue, 15 Oct 2024 21:02:38 +0000 Subject: [PATCH] Migrate Marketplace Listing Stats on Contract Overview page to shadcn+tailwind (#5040) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## PR-Codex overview This PR primarily focuses on refactoring components in the `MarketplaceDetails.tsx` and `listing-stats.tsx` files to replace instances of the `Flex` component with standard `div` elements, while also introducing a new `StatCard` component for displaying statistics. ### Detailed summary - Replaced `Flex` components with `div` elements in `DirectListingCards`, `EnglishAuctionCards`, and `MarketplaceDetails`. - Introduced a new `StatCard` component in `listing-stats.tsx` for displaying statistics. - Updated the rendering of total listings, direct listings, and English auctions to use `StatCard`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../components/MarketplaceDetails.tsx | 21 ++++--- .../listings/components/listing-stats.tsx | 61 +++++++++++-------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/overview/components/MarketplaceDetails.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/overview/components/MarketplaceDetails.tsx index 8a08925706a..19ae1f929bb 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/overview/components/MarketplaceDetails.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/overview/components/MarketplaceDetails.tsx @@ -1,6 +1,5 @@ import { WalletAddress } from "@/components/blocks/wallet-address"; import { - Flex, GridItem, SimpleGrid, Skeleton, @@ -84,7 +83,7 @@ const DirectListingCards: React.FC = ({ return ( <> - +

Direct Listing

@@ -100,7 +99,7 @@ const DirectListingCards: React.FC = ({ > View all -> - +
= ({ return ( <> - +
English Auctions = ({ > View all -> - +
= ({ chainSlug, }) => { return ( - - Listings +
+

Listings

+ {hasDirectListings && contract && ( = ({ chainSlug={chainSlug} /> )} + {hasEnglishAuctions && contract && ( = ({ chainSlug={chainSlug} /> )} - +
); }; @@ -298,7 +299,7 @@ const ListingCards: React.FC = ({ /> - +
{listing.asset.metadata.name} @@ -334,7 +335,7 @@ const ListingCards: React.FC = ({ {listing.currencyValue.displayValue}{" "} {listing.currencyValue.symbol} - +
))} diff --git a/apps/dashboard/src/contract-ui/tabs/listings/components/listing-stats.tsx b/apps/dashboard/src/contract-ui/tabs/listings/components/listing-stats.tsx index d9fe3a4f6a5..691e0bbdba1 100644 --- a/apps/dashboard/src/contract-ui/tabs/listings/components/listing-stats.tsx +++ b/apps/dashboard/src/contract-ui/tabs/listings/components/listing-stats.tsx @@ -1,9 +1,8 @@ -import { Skeleton, Stat, StatLabel, StatNumber } from "@chakra-ui/react"; +import { SkeletonContainer } from "@/components/ui/skeleton"; import { useMemo } from "react"; import type { ThirdwebContract } from "thirdweb"; import { totalAuctions, totalListings } from "thirdweb/extensions/marketplace"; import { useReadContract } from "thirdweb/react"; -import { Card } from "tw-components"; const TotalListingsStat: React.FC<{ contract: ThirdwebContract }> = ({ contract, @@ -20,16 +19,13 @@ const TotalListingsStat: React.FC<{ contract: ThirdwebContract }> = ({ ); return ( - - Total Listings - - {combinedListingCount.toString()} - - + ); }; @@ -41,12 +37,11 @@ const DirectListingsStat: React.FC<{ contract: ThirdwebContract }> = ({ }); return ( - - Direct Listings - - {(directListingsQuery.data || 0n).toString()} - - + ); }; @@ -58,12 +53,11 @@ const EnglishAuctionsStat: React.FC<{ contract: ThirdwebContract }> = ({ }); return ( - - English Auctions - - {(englishAuctionsQuery.data || 0n).toString()} - - + ); }; @@ -79,7 +73,7 @@ export const ListingStatsV3: React.FC = ({ hasEnglishAuctions, }) => { return ( -
+
{hasDirectListings && hasEnglishAuctions && contract && ( )} @@ -88,3 +82,20 @@ export const ListingStatsV3: React.FC = ({
); }; + +function StatCard(props: { + value: string; + isPending: boolean; + label: string; +}) { + return ( +
+
{props.label}
+
{v}
} + /> +
+ ); +}