@@ -5,7 +5,8 @@ import { useGetConsensusEpochs } from '../../../oasis-nexus/api'
55import { useGetStatus } from '../../../oasis-nexus/api'
66import { SearchScope } from '../../../types/searchScope'
77import { SnapshotTextCard } from '../../components/Snapshots/SnapshotCard'
8- import { BrandProgressBar } from '../../components/ProgressBar'
8+ import { PercentageValue } from '../../components/PercentageValue'
9+ import { CustomProgress } from '../../components/ProgressBar'
910
1011// We need to get the previous epoch to compute end_height for the current one
1112// This may not be precise during abnormal network conditions, but such conditions never happened so far
@@ -18,17 +19,17 @@ export const SnapshotEpoch: FC<{ scope: SearchScope }> = ({ scope }) => {
1819 const epochsQuery = useGetConsensusEpochs ( scope . network , { limit : epochsLimit } )
1920 const epochs = epochsQuery . data ?. data . epochs
2021 const epoch = epochs ?. length && epochs [ 0 ] . id
21- let percentageValue = undefined
22+ let epochDiffHeight = undefined
23+ let completedBlocksInCurrentEpoch = undefined
2224
2325 if ( epochs && epochs [ 1 ] ?. end_height && blockHeight ) {
24- const epochDiffHeight = epochs [ 1 ] ?. end_height - epochs [ 1 ] ?. start_height
25- const completedBlocksInCurrentEpoch = blockHeight - epochs [ 0 ] ?. start_height
26- percentageValue = completedBlocksInCurrentEpoch / epochDiffHeight
26+ epochDiffHeight = epochs [ 1 ] ?. end_height - epochs [ 1 ] ?. start_height + 1
27+ completedBlocksInCurrentEpoch = blockHeight - epochs [ 0 ] ?. start_height
2728 }
2829
2930 return (
3031 < SnapshotTextCard
31- title = { t ( 'currentEpoch ' ) }
32+ title = { t ( 'snapshotEpochTitle ' ) }
3233 label = {
3334 blockHeight !== undefined && (
3435 < Typography className = "font-normal flex gap-2 items-center" >
@@ -46,30 +47,21 @@ export const SnapshotEpoch: FC<{ scope: SearchScope }> = ({ scope }) => {
4647 }
4748 >
4849 { epoch !== undefined && (
49- < >
50- { percentageValue !== undefined && (
51- < div className = "-mt-2 mb-2" >
52- < BrandProgressBar value = { percentageValue * 100 } variant = "determinate" />
53- </ div >
54- ) }
55- < div className = "flex items-baseline gap-2" >
56- { epoch . toLocaleString ( ) }
57- { percentageValue !== undefined && (
58- < Typography variant = "xsmall" textColor = "muted" >
59- (
60- { t ( 'common.valuePair' , {
61- value : percentageValue ,
62- formatParams : {
63- value : {
64- style : 'percent' ,
65- } satisfies Intl . NumberFormatOptions ,
66- } ,
67- } ) }
68- )
69- </ Typography >
70- ) }
71- </ div >
72- </ >
50+ < CustomProgress
51+ value = { completedBlocksInCurrentEpoch }
52+ max = { epochDiffHeight }
53+ label = {
54+ < >
55+ < span className = "font-bold" > { completedBlocksInCurrentEpoch } </ span > /{ epochDiffHeight } (
56+ < PercentageValue
57+ value = { completedBlocksInCurrentEpoch }
58+ total = { epochDiffHeight }
59+ maximumFractionDigits = { 1 }
60+ />
61+ )
62+ </ >
63+ }
64+ />
7365 ) }
7466 </ SnapshotTextCard >
7567 )
0 commit comments