@@ -5,7 +5,9 @@ import { useCourtDetails, CourtDetailsQuery } from "queries/useCourtDetails";
55import { useCoinPrice } from "hooks/useCoinPrice" ;
66import { KLEROS_CONTRACT_ADDRESS , WETH_CONTRACT_ADDRESS } from "consts/index" ;
77import { formatETH , formatPNK , formatUnitsWei , formatUSD , isUndefined } from "utils/index" ;
8+ import { calculateSubtextRender } from "utils/calculateSubtextRender" ;
89import StatDisplay , { IStatDisplay } from "components/StatDisplay" ;
10+ import { StyledSkeleton } from "components/StyledSkeleton" ;
911import BalanceIcon from "svgs/icons/law-balance.svg" ;
1012import MinStake from "svgs/icons/min-stake.svg" ;
1113import VoteStake from "svgs/icons/vote-stake.svg" ;
@@ -25,7 +27,7 @@ interface IStat {
2527 title : string ;
2628 coinId ?: number ;
2729 getText : ( data : CourtDetailsQuery [ "court" ] ) => string ;
28- getSubtext : ( data : CourtDetailsQuery [ "court" ] , coinPrice ?: number ) => string ;
30+ getSubtext ? : ( data : CourtDetailsQuery [ "court" ] , coinPrice ?: number ) => string ;
2931 color : IStatDisplay [ "color" ] ;
3032 icon : React . FC < React . SVGAttributes < SVGElement > > ;
3133}
@@ -50,7 +52,6 @@ const stats: IStat[] = [
5052 {
5153 title : "Active Jurors" ,
5254 getText : ( data ) => data ?. numberStakedJurors ,
53- getSubtext : ( ) => "" ,
5455 color : "purple" ,
5556 icon : PNKRedistributedIcon ,
5657 } ,
@@ -65,14 +66,12 @@ const stats: IStat[] = [
6566 {
6667 title : "Cases" ,
6768 getText : ( data ) => data ?. numberDisputes ,
68- getSubtext : ( ) => "" ,
6969 color : "orange" ,
7070 icon : BalanceIcon ,
7171 } ,
7272 {
7373 title : "In Progress" ,
7474 getText : ( data ) => data ?. numberDisputes ,
75- getSubtext : ( ) => "" ,
7675 color : "orange" ,
7776 icon : BalanceIcon ,
7877 } ,
@@ -108,12 +107,13 @@ const Stats = () => {
108107 < StyledCard >
109108 { stats . map ( ( { title, coinId, getText, getSubtext, color, icon } , i ) => {
110109 const coinPrice = ! isUndefined ( pricesData ) ? pricesData [ coinIdToAddress [ coinId ! ] ] ?. price : undefined ;
110+
111111 return (
112112 < StatDisplay
113113 key = { i }
114114 { ...{ title, color, icon } }
115- text = { data ? getText ( data . court ) : "Fetching..." }
116- subtext = { data ? getSubtext ( data . court , coinPrice ) : "Fetching..." }
115+ text = { data ? getText ( data . court ) : < StyledSkeleton /> }
116+ subtext = { calculateSubtextRender ( data ? data . court : undefined , getSubtext , coinPrice ) }
117117 />
118118 ) ;
119119 } ) }
0 commit comments