1
- import { useExchangeRates } from ' @/hooks/api' ;
2
- import { currencyFormat } from ' @/utils/number' ;
3
- import Link from ' next/link' ;
4
- import type { OverviewProps } from ' ./types' ;
5
- import { useState , useEffect } from ' react' ;
1
+ import { useExchangeRates , useOrdinalsMarketcap } from " @/hooks/api" ;
2
+ import { currencyFormat } from " @/utils/number" ;
3
+ import Link from " next/link" ;
4
+ import type { OverviewProps } from " ./types" ;
5
+ import { useState , useEffect } from " react" ;
6
6
7
7
export default function AccountOverview ( { tokens } : OverviewProps ) {
8
8
const exchangeRatesQuery = useExchangeRates ( ) ;
9
+ const ordinalsMarketcapQuery = useOrdinalsMarketcap ( ) ;
9
10
const [ totalValue , setTotalValue ] = useState ( 0 ) ;
10
11
11
12
useEffect ( ( ) => {
@@ -24,12 +25,17 @@ export default function AccountOverview({ tokens }: OverviewProps) {
24
25
}
25
26
} , [ exchangeRatesQuery . isSuccess , tokens ] ) ;
26
27
27
- if ( exchangeRatesQuery . isLoading ) {
28
+ if ( exchangeRatesQuery . isLoading || ordinalsMarketcapQuery . isLoading ) {
28
29
return < span > Loading...</ span > ;
29
30
}
30
31
31
- if ( exchangeRatesQuery . isError ) {
32
- return < span > Error: { exchangeRatesQuery . error ?. message } </ span > ;
32
+ if ( exchangeRatesQuery . isError || ordinalsMarketcapQuery . isError ) {
33
+ return (
34
+ < span >
35
+ Error: { exchangeRatesQuery . error ?. message } { " " }
36
+ { ordinalsMarketcapQuery . error ?. message }
37
+ </ span >
38
+ ) ;
33
39
}
34
40
35
41
const exchangeRates = exchangeRatesQuery . data ;
@@ -40,11 +46,15 @@ export default function AccountOverview({ tokens }: OverviewProps) {
40
46
if ( isNaN ( bValue ) ) return - 1 ;
41
47
return bValue - aValue ;
42
48
} ) ;
49
+ console . log ( sortedTokens ) ;
50
+
51
+
52
+ const ordinalsMarketcap = ordinalsMarketcapQuery . data ;
43
53
44
54
return (
45
- < div className = ' flex-1' >
46
- < div className = ' w-full overflow-x-auto rounded-md border border-shade-800 bg-shade-900' >
47
- < table className = ' custom-table' >
55
+ < div className = " flex-1" >
56
+ < div className = " w-full overflow-x-auto rounded-md border border-shade-800 bg-shade-900" >
57
+ < table className = " custom-table" >
48
58
< thead >
49
59
< tr >
50
60
< th > TOKEN</ th >
@@ -53,27 +63,37 @@ export default function AccountOverview({ tokens }: OverviewProps) {
53
63
</ tr >
54
64
</ thead >
55
65
< tbody >
56
- { sortedTokens . map ( ( token ) => (
66
+ { sortedTokens
67
+ . filter ( ( token ) => token . contract !== 'ord.libre' && token . amount !== 0 )
68
+ . map ( ( token ) => (
69
+ // ... Rest of your code for rendering each token
70
+
71
+
72
+
57
73
< tr key = { token . symbol } >
58
74
< td >
59
- < div className = 'flex items-center space-x-4' >
60
- < div className = "" >
61
- { [ 'PBTC' , 'PUSDT' , 'BTCUSD' , 'LIBRE' , 'BTCLIB' ] . includes ( token . symbol . toUpperCase ( ) ) ? (
62
- < img
63
- src = { `/images/symbols/${ token . symbol . toUpperCase ( ) } .svg` }
64
- alt = { token . symbol . toUpperCase ( ) }
65
- className = "h-8 w-8 shrink-0"
66
- />
67
- ) : (
68
- < div className = "w-11 h-11 rounded-full bg-blue-500 flex flex-col justify-center items-center" >
69
- < a className = "uppercase text-xs" > { token . symbol . toUpperCase ( ) } </ a >
70
- </ div >
71
- ) }
72
- </ div >
75
+ < div className = "flex items-center space-x-4" >
76
+ < div className = "" >
77
+ { [ "PBTC" , "PUSDT" , "BTCUSD" , "LIBRE" , "BTCLIB" ] . includes (
78
+ token . symbol . toUpperCase ( )
79
+ ) ? (
80
+ < img
81
+ src = { `/images/symbols/${ token . symbol . toUpperCase ( ) } .svg` }
82
+ alt = { token . symbol . toUpperCase ( ) }
83
+ className = "h-8 w-8 shrink-0"
84
+ />
85
+ ) : (
86
+ < div className = "flex h-11 w-11 flex-col items-center justify-center rounded-full bg-blue-500" >
87
+ < a className = "text-xs uppercase" >
88
+ { token . symbol . toUpperCase ( ) }
89
+ </ a >
90
+ </ div >
91
+ ) }
92
+ </ div >
73
93
74
94
< Link
75
- href = { ' ../tokens' }
76
- className = ' inline-block max-w-full truncate align-middle hover:underline'
95
+ href = { " ../tokens" }
96
+ className = " inline-block max-w-full truncate align-middle hover:underline"
77
97
>
78
98
< span > { token . symbol } </ span >
79
99
</ Link >
@@ -82,11 +102,17 @@ export default function AccountOverview({ tokens }: OverviewProps) {
82
102
< td > { token ?. amount ?? 0 } </ td >
83
103
< td >
84
104
{ isNaN ( token . amount * exchangeRates [ token . symbol ] ) ? (
85
- < span style = { { color : 'gray' } } > SOON</ span >
105
+ < span style = { { color : "white" } } >
106
+ ${ token . amount * ( ordinalsMarketcap . tokens . find ( ( t ) => t . mappedName === token . symbol ) ?. price ?? 0 ) }
107
+
108
+
109
+ </ span >
86
110
) : (
87
- < span style = { { color : ' white' } } >
111
+ < span style = { { color : " white" } } >
88
112
$
89
- { ( token . amount * exchangeRates [ token . symbol ] ) . toLocaleString ( 'en-US' , {
113
+ { (
114
+ token . amount * exchangeRates [ token . symbol ]
115
+ ) . toLocaleString ( "en-US" , {
90
116
maximumFractionDigits : 3 ,
91
117
} ) }
92
118
</ span >
@@ -99,8 +125,11 @@ export default function AccountOverview({ tokens }: OverviewProps) {
99
125
100
126
< div > </ div >
101
127
</ table >
102
- < div className = ' flex justify-center py-3 text-[15px]' >
103
- < div > Total: ${ totalValue . toLocaleString ( 'en-US' , { maximumFractionDigits : 3 } ) } </ div >
128
+ < div className = " flex justify-center py-3 text-[15px]" >
129
+ < div >
130
+ Total: $
131
+ { totalValue . toLocaleString ( "en-US" , { maximumFractionDigits : 3 } ) }
132
+ </ div >
104
133
</ div >
105
134
</ div >
106
135
</ div >
0 commit comments