File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import { InfoSection } from "../global/sections";
1515import PageSkeleton from "./page-skeleton" ;
1616import { cache , Suspense } from "react" ;
1717import { getHypercertState } from "@/hypercerts/getHypercertState" ;
18+ import { getOrders } from "@/marketplace/getOpenOrders" ;
1819
1920function HypercertDetailsNotFound ( ) {
2021 return < InfoSection > Hypercert not found</ InfoSection > ;
@@ -38,6 +39,9 @@ export default async function HypercertDetails({
3839 hypercertId : string ;
3940} ) {
4041 const hypercert = await getHypercertDetails ( hypercertId ) ;
42+ const orders = await getOrders ( { filter : { hypercertId : hypercertId } } ) ;
43+
44+ const isListed = orders ?. data ?. length > 0 && orders ?. count > 0 ;
4145
4246 if ( ! hypercert ) {
4347 return < HypercertDetailsNotFound /> ;
@@ -57,7 +61,7 @@ export default async function HypercertDetails({
5761 { hypercert ?. metadata ?. name || "[Untitled]" }
5862 </ h1 >
5963 < div className = "flex space-x-2" >
60- < BuyButton />
64+ < BuyButton isListed = { isListed } />
6165 < MutationButtons hypercert = { hypercert } />
6266 </ div >
6367 </ div >
Original file line number Diff line number Diff line change 22
33import { Button } from "@/components/ui/button" ;
44
5- export function BuyButton ( ) {
5+ export function BuyButton ( { isListed } : { isListed : boolean } ) {
66 const handleClick = ( ) => {
77 const listingsSection = document . getElementById ( "marketplace-listings" ) ;
88 if ( listingsSection ) {
@@ -12,5 +12,11 @@ export function BuyButton() {
1212 }
1313 } ;
1414
15- return < Button onClick = { handleClick } > Buy</ Button > ;
15+ return (
16+ < Button onClick = { handleClick } disabled = { ! isListed } >
17+ Buy
18+ </ Button >
19+ ) ;
1620}
21+
22+ export default BuyButton ;
You can’t perform that action at this time.
0 commit comments