1- import { useState } from 'react'
1+ import { useEffect , useState } from 'react'
22
33import "./index.css" ;
44import SpClubCongratsPopup from '../SpClubCongratsPopup' ;
@@ -8,14 +8,25 @@ import { useDaemonContext } from '../../providers/DaemonProvider';
88import { getSpClubMemberId } from '../../services/wallets' ;
99import { isPassportValid } from '../../utils/utils' ;
1010
11+ const OneDayInSeconds = 86400 ;
12+
1113export default function SpClub ( ) {
1214 const [ isOpen , setIsOpen ] = useState < boolean > ( false ) ;
1315 const [ isCongratsPopupOpen , setIsCongratsPopupOpen ] = useState < boolean > ( false ) ;
1416 const [ isLoading , setIsLoading ] = useState < boolean > ( false ) ;
1517 const [ memberId , setMemberId ] = useState < string > ( '0' ) ;
1618 const [ referrer , setReferrer ] = useState < string > ( '' ) ;
19+ const [ passportTimeLeft , setPassportTimeLeft ] = useState < number > ( 0 ) ;
20+
21+ const { miningData, profiles, setIsPassportInfoPopupOpen, activePassportUpdated, activePassport } = useDaemonContext ( ) ;
1722
18- const { profiles } = useDaemonContext ( ) ;
23+ useEffect ( ( ) => {
24+ const passportExpiration = profiles ?. [ 0 ] ?. activePassport ?. expires
25+ if ( passportExpiration ) {
26+ const timeLeft = passportExpiration - Math . floor ( Date . now ( ) / 1000 )
27+ setPassportTimeLeft ( timeLeft )
28+ }
29+ } , [ activePassportUpdated , profiles ] )
1930
2031 const fetchMemberIdWithRetry = async ( startTime = Date . now ( ) ) : Promise < string | null > => {
2132 const _memberId = await getSpClubMemberId ( profiles [ 0 ] ) ;
@@ -120,7 +131,15 @@ export default function SpClub() {
120131 < div className = "account-main-card" onClick = { ( ) => setIsOpen ( ( prev ) => ! prev ) } >
121132 { /* <div className="disabled account-main-card"> */ }
122133 < div className = "name" >
123- < h3 > Join SP Club</ h3 >
134+ < div style = { { display : 'flex' , flexDirection : 'row' , gap : '16px' , alignItems : 'center' } } >
135+ < h3 > Join SP Club</ h3 >
136+ < div
137+ style = { {
138+ width : '12px' ,
139+ height : '12px' ,
140+ } }
141+ className = { `circle ${ passportTimeLeft < OneDayInSeconds ? passportTimeLeft <= 0 ? "red" : "yellow" : "green" } ` } > </ div >
142+ </ div >
124143 < img height = '16px' width = '16px' className = "chevron" src = "./assets/right-chevron.svg" />
125144 </ div >
126145 </ div >
0 commit comments