@@ -27,30 +27,38 @@ const CoinDetails = async ({ params }: { params: Promise<{ id: string }> }) => {
2727 const coinOHLCData = await getCoinOHLC ( id , 1 , 'usd' , 'hourly' , 'full' ) ;
2828 const pool = await fetchPools ( id ) ;
2929
30- const coin = {
31- id : coinData . id ,
32- name : coinData . name ,
33- symbol : coinData . symbol ,
34- image : coinData . image . large ,
35- icon : coinData . image . small ,
36- price : coinData . market_data . current_price . usd ,
37- priceList : coinData . market_data . current_price ,
38- priceChange24h : coinData . market_data . price_change_24h_in_currency . usd ,
39- priceChangePercentage24h :
40- coinData . market_data . price_change_percentage_24h_in_currency . usd ,
41- priceChangePercentage30d :
42- coinData . market_data . price_change_percentage_30d_in_currency . usd ,
43- marketCap : coinData . market_data . market_cap . usd ,
44- marketCapRank : coinData . market_cap_rank ,
45- description : coinData . description . en ,
46- totalVolume : coinData . market_data . total_volume . usd ,
47- website : coinData . links . homepage [ 0 ] ,
48- explorer : coinData . links . blockchain_site [ 0 ] ,
49- communityLink : coinData . links . subreddit_url ,
50- tickers : coinData . tickers ,
51- } ;
52-
53- console . log ( '==== coinOHLCData:' , coinOHLCData ) ;
30+ const coinDetails = [
31+ {
32+ label : 'Market Cap' ,
33+ value : formatPrice ( coinData . market_data . market_cap . usd ) ,
34+ } ,
35+ {
36+ label : 'Market Cap Rank' ,
37+ value : `# ${ coinData . market_cap_rank } ` ,
38+ } ,
39+ {
40+ label : 'Total Volume' ,
41+ value : formatPrice ( coinData . market_data . total_volume . usd ) ,
42+ } ,
43+ {
44+ label : 'Website' ,
45+ value : '-' ,
46+ link : coinData . links . homepage [ 0 ] ,
47+ linkText : 'Website' ,
48+ } ,
49+ {
50+ label : 'Explorer' ,
51+ value : '-' ,
52+ link : coinData . links . blockchain_site [ 0 ] ,
53+ linkText : 'Explorer' ,
54+ } ,
55+ {
56+ label : 'Community Link' ,
57+ value : '-' ,
58+ link : coinData . links . subreddit_url ,
59+ linkText : 'Community' ,
60+ } ,
61+ ] ;
5462
5563 return (
5664 < main className = 'coin-details-main' >
@@ -59,9 +67,10 @@ const CoinDetails = async ({ params }: { params: Promise<{ id: string }> }) => {
5967 coinOHLCData = { coinOHLCData }
6068 coinId = { id }
6169 pool = { pool }
62- coin = { coin }
70+ coin = { coinData }
6371 >
64- { /* Exchange Listings */ }
72+ { /* Exchange Listings - pass it as a child of a client component
73+ // so it will be render server side */ }
6574 < div className = 'w-full mt-8 space-y-4' >
6675 < h4 className = 'section-title' > Exchange Listings</ h4 >
6776 < div className = 'custom-scrollbar mt-5 exchange-container' >
@@ -79,7 +88,7 @@ const CoinDetails = async ({ params }: { params: Promise<{ id: string }> }) => {
7988 </ TableRow >
8089 </ TableHeader >
8190 < TableBody >
82- { coin . tickers
91+ { coinData . tickers
8392 . slice ( 0 , 7 )
8493 . map ( ( ticker : Ticker , index : number ) => (
8594 < TableRow
@@ -125,51 +134,20 @@ const CoinDetails = async ({ params }: { params: Promise<{ id: string }> }) => {
125134 { /* Converter */ }
126135 < div className = 'w-full space-y-5' >
127136 < h4 className = 'converter-title' >
128- { coin . symbol . toUpperCase ( ) } Converter
137+ { coinData . symbol . toUpperCase ( ) } Converter
129138 </ h4 >
130139 < Converter
131- symbol = { coin . symbol }
132- icon = { coin . icon }
133- priceList = { coin . priceList }
140+ symbol = { coinData . symbol }
141+ icon = { coinData . image . small }
142+ priceList = { coinData . market_data . current_price }
134143 />
135144 </ div >
136145
137146 { /* Coin Details */ }
138147 < div className = 'w-full mt-8 space-y-4' >
139148 < h4 className = 'section-title pb-3' > Coin Details</ h4 >
140149 < div className = 'coin-details-grid' >
141- { [
142- {
143- label : 'Market Cap' ,
144- value : formatPrice ( coin . marketCap ) ,
145- } ,
146- {
147- label : 'Market Cap Rank' ,
148- value : `# ${ coin . marketCapRank } ` ,
149- } ,
150- {
151- label : 'Total Volume' ,
152- value : formatPrice ( coin . totalVolume ) ,
153- } ,
154- {
155- label : 'Website' ,
156- value : '-' ,
157- link : coin . website ,
158- linkText : 'Website' ,
159- } ,
160- {
161- label : 'Explorer' ,
162- value : '-' ,
163- link : coin . explorer ,
164- linkText : 'Explorer' ,
165- } ,
166- {
167- label : 'Community Link' ,
168- value : '-' ,
169- link : coin . communityLink ,
170- linkText : 'Community' ,
171- } ,
172- ] . map ( ( detail , index ) => (
150+ { coinDetails . map ( ( detail , index ) => (
173151 < CoinDetailCard
174152 key = { index }
175153 label = { detail . label }
@@ -181,6 +159,7 @@ const CoinDetails = async ({ params }: { params: Promise<{ id: string }> }) => {
181159 </ div >
182160 </ div >
183161
162+ { /* Top Gainers / Losers */ }
184163 < Tabs defaultValue = 'top-gainers' className = 'mt-8 w-full' >
185164 < TabsList className = 'size-full p-1 bg-transparent border-b border-dark-500 rounded-none ' >
186165 < TabsTrigger
0 commit comments