@@ -8,27 +8,26 @@ import { POIDH_ABI } from '@/lib/poidh/abi';
88import { POIDH_CONTRACTS } from '@/lib/poidh/config' ;
99import { Card , CardContent , CardHeader , CardTitle } from '@/components/ui/card' ;
1010
11- function useDeadlineCountdown ( deadlineSeconds : number ) : string {
11+ function useDeadlineCountdown ( deadlineSeconds : number ) : { label : string ; expired : boolean } {
1212 const calc = ( ) => {
13- if ( ! deadlineSeconds ) return '' ;
13+ if ( ! deadlineSeconds ) return { label : '' , expired : false } ;
1414 const diff = deadlineSeconds * 1000 - Date . now ( ) ;
15- if ( diff <= 0 ) return 'Expired' ;
15+ if ( diff <= 0 ) return { label : 'Expired' , expired : true } ;
1616 const hours = Math . floor ( diff / 3_600_000 ) ;
1717 const minutes = Math . floor ( ( diff % 3_600_000 ) / 60_000 ) ;
18- if ( hours > 0 ) return `${ hours } h ${ minutes } m` ;
19- return `${ minutes } m` ;
18+ return { label : hours > 0 ? `${ hours } h ${ minutes } m` : `${ minutes } m` , expired : false } ;
2019 } ;
2120
22- const [ label , setLabel ] = useState ( calc ) ;
21+ const [ state , setState ] = useState ( calc ) ;
2322
2423 useEffect ( ( ) => {
2524 if ( ! deadlineSeconds ) return ;
26- const id = setInterval ( ( ) => setLabel ( calc ( ) ) , 30_000 ) ;
25+ const id = setInterval ( ( ) => setState ( calc ( ) ) , 30_000 ) ;
2726 return ( ) => clearInterval ( id ) ;
2827 // eslint-disable-next-line react-hooks/exhaustive-deps
2928 } , [ deadlineSeconds ] ) ;
3029
31- return label ;
30+ return state ;
3231}
3332
3433interface VoteDashboardProps {
@@ -52,7 +51,7 @@ export function VoteDashboard({ chainId, onChainBountyId }: VoteDashboardProps)
5251 } ) ;
5352
5453 const deadlineSec = tracker ? Number ( tracker [ 2 ] ) : 0 ;
55- const deadline = useDeadlineCountdown ( deadlineSec ) ;
54+ const { label : deadline , expired : isExpired } = useDeadlineCountdown ( deadlineSec ) ;
5655
5756 if ( ! tracker || deadlineSec === 0 ) return null ;
5857
@@ -62,7 +61,6 @@ export function VoteDashboard({ chainId, onChainBountyId }: VoteDashboardProps)
6261 const noEth = parseFloat ( formatEther ( noWei ) ) ;
6362 const total = yesEth + noEth ;
6463 const yesPercent = total > 0 ? Math . round ( ( yesEth / total ) * 100 ) : 50 ;
65- const isExpired = deadlineSec * 1000 < Date . now ( ) ;
6664
6765 return (
6866 < Card className = "border-yellow-500/20 bg-yellow-500/5" >
0 commit comments