1- import classNames from "classnames"
21import { SpinnerCircular } from "spinners-react"
32import { ApiResponseDto_PageStatsDto } from "~/backendApi"
43import { Formatter } from "~/utils/misc/formatter"
4+ import { Diff } from "../pages/diff"
55import { PAGE_COLOR_CODE } from "~/constants"
66
7- const DOWN_ARROW = "M6 9L12 15L18 9"
8- const UP_ARROW = "M18 15L12 9L6 15"
7+
98
109const DelegationSummary = ( { data, isLoading, error } : {
1110 data : ApiResponseDto_PageStatsDto , isLoading : boolean , error : string
@@ -31,20 +30,10 @@ const DelegationSummary = ({ data, isLoading, error }: {
3130 console . log ( String ( error ) ) // should not happen
3231 }
3332
34- const delegatedNeg = typeof delegatedDiff == 'string' && delegatedDiff . startsWith ( '-' )
35- const delegatorNeg = typeof delegatorDiff == 'string' && delegatorDiff . startsWith ( '-' )
36-
37- if ( delegatedNeg ) {
38- delegatedDiff = delegatedDiff . slice ( 1 )
39- }
40- if ( delegatorNeg ) {
41- delegatorDiff = delegatorDiff . slice ( 1 )
42- }
43-
4433 return < div className = "page-stats-container" >
4534 < div className = "dashboard loading" >
46-
4735 < div className = "metrics-grid" >
36+
4837 < div className = "metric-card" data-start = "0" data-end = "7489" data-increment = "1" data-speed = "10" >
4938 < div className = "metric-title" >
5039 Total Delegated
@@ -53,11 +42,8 @@ const DelegationSummary = ({ data, isLoading, error }: {
5342 < span className = "counter-unit" > $</ span >
5443 < div className = "counter" id = "counter-1" > { delegated } </ div >
5544 </ div >
56- < div className = { classNames ( 'metric-trend' , { 'trend-down' : delegatedNeg , 'trend-up' : ! delegatedNeg } ) } >
57- < svg width = "12" height = "12" viewBox = "0 0 24 24" fill = "none" xmlns = "http://www.w3.org/2000/svg" >
58- < path d = { delegatedNeg ? DOWN_ARROW : UP_ARROW } stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" />
59- </ svg >
60- < span > { delegatedDiff } in 24h</ span >
45+ < div className = "metric-trend" >
46+ < Diff diff = { delegatedDiff } unit = { "in 24h" } />
6147 </ div >
6248 </ div >
6349
@@ -69,11 +55,8 @@ const DelegationSummary = ({ data, isLoading, error }: {
6955 < div className = "counter" id = "counter-2" > { delegators } </ div >
7056 < span className = "counter-unit" > users</ span >
7157 </ div >
72- < div className = { classNames ( 'metric-trend' , { 'trend-down' : delegatorNeg , 'trend-up' : ! delegatorNeg } ) } >
73- < svg width = "12" height = "12" viewBox = "0 0 24 24" fill = "none" xmlns = "http://www.w3.org/2000/svg" >
74- < path d = { delegatorNeg ? DOWN_ARROW : UP_ARROW } stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" />
75- </ svg >
76- < span > { delegatorDiff } in 24h</ span >
58+ < div className = "metric-trend" >
59+ < Diff diff = { delegatorDiff } unit = { "in 24h" } />
7760 </ div >
7861 </ div >
7962
0 commit comments