@@ -2,21 +2,26 @@ import { Metadata, ResolvingMetadata } from "next";
22
33import { getHypercert } from "@/hypercerts/getHypercert" ;
44
5- import HypercertDetails from "@/components/hypercert/hypercert-details " ;
6- import EvaluateButton from "@/components/hypercert/evaluate-button " ;
5+ import CreatorFeedButton from "@/components/creator-feed/creator-feed-button " ;
6+ import CreatorFeeds from "@/components/creator-feed/creator-feeds " ;
77import { CurrencyButtons } from "@/components/currency-buttons" ;
8- import { ListForSaleButton } from "@/components/marketplace/list-for-sale-button " ;
8+ import HypercertEvaluations from "@/components/evaluations/hypercert-evaluations " ;
99import ErrorState from "@/components/global/error-state" ;
10+ import EvaluateButton from "@/components/hypercert/evaluate-button" ;
11+ import HypercertDetails from "@/components/hypercert/hypercert-details" ;
1012import HypercertListings from "@/components/marketplace/hypercert-listings" ;
11- import HypercertEvaluations from "@/components/evaluations/hypercert-evaluations" ;
12- import CreatorFeedButton from "@/components/creator-feed/creator-feed-button" ;
13- import CreatorFeeds from "@/components/creator-feed/creator-feeds" ;
13+ import { ListForSaleButton } from "@/components/marketplace/list-for-sale-button" ;
1414import {
1515 Accordion ,
1616 AccordionContent ,
1717 AccordionItem ,
1818 AccordionTrigger ,
1919} from "@/components/ui/accordion" ;
20+ import {
21+ creatorFeedFlag ,
22+ evaluationsFlag ,
23+ marketplaceListingsFlag ,
24+ } from "@/flags/chain-actions-flag" ;
2025
2126type Props = {
2227 params : { hypercertId : string } ;
@@ -46,19 +51,35 @@ export async function generateMetadata(
4651export default async function HypercertPage ( { params, searchParams } : Props ) {
4752 const { hypercertId } = params ;
4853
49- const [ hypercert ] = await Promise . all ( [ getHypercert ( hypercertId ) ] ) ;
54+ const hypercert = await getHypercert ( hypercertId ) ;
55+ const isCreatorFeedEnabledOnChain = await creatorFeedFlag ( ) ;
56+ const isEvaluationsEnabledOnChain = await evaluationsFlag ( ) ;
57+ const isMarketplaceListingsEnabledOnChain = await marketplaceListingsFlag ( ) ;
5058
5159 if ( ! hypercert ) {
5260 return (
5361 < ErrorState message = "Hypercert not found" hypercertId = { hypercertId } />
5462 ) ;
5563 }
5664
65+ const getDefaultAccordionItems = ( ) => {
66+ if ( isMarketplaceListingsEnabledOnChain ) return [ "marketplace-listings" ] ;
67+ if ( isEvaluationsEnabledOnChain ) return [ "evaluations" ] ;
68+ if ( isCreatorFeedEnabledOnChain ) return [ "creator-feed" ] ;
69+ return [ ] ;
70+ } ;
71+
72+ const defaultAccordionItems = getDefaultAccordionItems ( ) ;
73+
5774 return (
5875 < main className = "flex flex-col p-8 md:px-24 md:pt-14 pb-24 space-y-4 flex-1" >
5976 < HypercertDetails hypercertId = { hypercertId } />
60- < Accordion type = "multiple" defaultValue = { [ "item-3" ] } className = "w-full" >
61- < AccordionItem value = "item-1" >
77+ < Accordion
78+ type = "multiple"
79+ defaultValue = { defaultAccordionItems }
80+ className = "w-full"
81+ >
82+ < AccordionItem value = "creator-feed" >
6283 { /* creator feed */ }
6384 < AccordionTrigger className = "uppercase text-sm text-slate-500 font-medium tracking-wider" >
6485 CREATOR'S FEED
@@ -68,14 +89,15 @@ export default async function HypercertPage({ params, searchParams }: Props) {
6889 < CreatorFeedButton
6990 hypercertId = { hypercertId }
7091 creatorAddress = { hypercert . creator_address ! }
92+ disabledForChain = { ! isCreatorFeedEnabledOnChain }
7193 />
7294 </ div >
7395 < CreatorFeeds hypercertId = { hypercertId } />
7496 </ AccordionContent >
7597 </ AccordionItem >
7698
7799 { /* evaluations */ }
78- < AccordionItem value = "item-2 " >
100+ < AccordionItem value = "evaluations " >
79101 < AccordionTrigger className = "uppercase text-sm text-slate-500 font-medium tracking-wider" >
80102 Evaluations
81103 </ AccordionTrigger >
@@ -86,20 +108,24 @@ export default async function HypercertPage({ params, searchParams }: Props) {
86108 < HypercertEvaluations
87109 hypercertId = { hypercertId }
88110 searchParams = { searchParams }
111+ disabledForChain = { ! isEvaluationsEnabledOnChain }
89112 />
90113 </ AccordionContent >
91114 </ AccordionItem >
92115
93116 { /* marketplace */ }
94- < AccordionItem value = "item-3 " >
117+ < AccordionItem value = "marketplace-listings " >
95118 < AccordionTrigger className = "uppercase text-sm text-slate-500 font-medium tracking-wider" >
96119 Marketplace
97120 </ AccordionTrigger >
98121 < AccordionContent >
99122 < div className = "flex justify-end mb-4" >
100123 < div className = "flex gap-2" >
101124 < CurrencyButtons />
102- < ListForSaleButton hypercert = { hypercert } />
125+ < ListForSaleButton
126+ hypercert = { hypercert }
127+ disabledForChain = { ! isMarketplaceListingsEnabledOnChain }
128+ />
103129 </ div >
104130 </ div >
105131 < HypercertListings
0 commit comments