1- import { useState } from 'react' ;
1+ import { useEffect , useState } from 'react' ;
22import './index.css' ;
33import Separator from '../Separator' ;
4- import CopyAccountInfo from './CopyAccountInfo' ;
54import { useDaemonContext } from '../../providers/DaemonProvider' ;
65import Skeleton from '../Skeleton' ;
76
8- import { ReactComponent as ConetToken } from './assets/conet-token.svg' ;
9- import { ReactComponent as ConetEthToken } from './assets/conet-eth-token.svg' ;
10- import { ReactComponent as SolanaToken } from './assets/solana-token.svg' ;
11- import { ReactComponent as SpToken } from './assets/sp-token.svg' ;
12- import PassportInfo from '../PassportInfo' ;
13- import SelectActivePassportPopup from '../SelectActivePassportPopup' ;
14- import { refreshSolanaBalances , storeSystemData } from '../../services/wallets' ;
15- import { CoNET_Data } from '../../utils/globals' ;
16- import { useNavigate } from 'react-router-dom' ;
177import { ethers } from 'ethers' ;
188
199import { ReactComponent as VisibilityOnIcon } from "./assets/visibility-on.svg" ;
2010import { ReactComponent as VisibilityOffIcon } from "./assets/visibility-off.svg" ;
11+ import { getPassportTitle } from '../../utils/utils' ;
12+ import { currentPageInvitees , setCurrentPageInvitees } from '../../utils/globals' ;
13+ import { getRefereesPage } from '../../services/wallets' ;
2114
2215const SP_EARNED_FROM_REFERRAL = 10
2316
@@ -27,6 +20,30 @@ export default function ReferralProgram() {
2720
2821 const [ isAddressHidden , setIsAddressHidden ] = useState ( true ) ;
2922 const [ copied , setCopied ] = useState ( false ) ;
23+ const [ shouldRerender , setShouldRerender ] = useState ( false ) ;
24+
25+
26+ const handlePreviousPage = async ( ) => {
27+ if ( currentPageInvitees > 0 ) {
28+ setCurrentPageInvitees ( currentPageInvitees - 1 )
29+ await getRefereesPage ( profiles [ 0 ] , currentPageInvitees )
30+ setShouldRerender ( true )
31+ }
32+ }
33+
34+ const handleNextPage = async ( ) => {
35+ if ( currentPageInvitees < Math . ceil ( profiles ?. [ 0 ] ?. spClub ?. totalReferees / 100 ) ) {
36+ setCurrentPageInvitees ( currentPageInvitees + 1 )
37+ await getRefereesPage ( profiles [ 0 ] , currentPageInvitees )
38+ setShouldRerender ( true )
39+ }
40+ }
41+
42+ useEffect ( ( ) => {
43+ if ( shouldRerender ) {
44+ setShouldRerender ( false )
45+ }
46+ } , [ shouldRerender ] )
3047
3148 function handleCopy ( ) {
3249 navigator . clipboard . writeText ( profiles ?. [ 0 ] ?. keyID ) ;
@@ -42,9 +59,9 @@ export default function ReferralProgram() {
4259 }
4360
4461 return (
45- < div className = { `account-wrapper ${ isOpen ? 'active' : '' } ` } >
46- { /* <div className="account-main-card" onClick={() => setIsOpen((prev) => !prev)}> */ }
47- < div className = "disabled account-main-card" >
62+ < div className = { `account-wrapper fit-content ${ isOpen ? 'active' : '' } ` } >
63+ < div className = "account-main-card" onClick = { ( ) => setIsOpen ( ( prev ) => ! prev ) } >
64+ { /* <div className="disabled account-main-card"> */ }
4865 < div className = "name" >
4966 < h3 > Referral Program</ h3 >
5067 < img height = '16px' width = '16px' className = "chevron" src = "./assets/right-chevron.svg" />
@@ -56,7 +73,7 @@ export default function ReferralProgram() {
5673 { profiles ?. [ 0 ] ?. keyID ?
5774 < >
5875 < div className = "copy-text" >
59- < p > Wallet Address </ p >
76+ < p > Copy this wallet address to invite your friends to Silent Pass </ p >
6077 {
6178 isAddressHidden ?
6279 < div style = { { filter : 'blur(3px)' } } >
@@ -97,32 +114,46 @@ export default function ReferralProgram() {
97114 </ div >
98115 < div style = { { marginLeft : '16px' } } >
99116 < div style = { { display : 'flex' , alignItems : 'center' , gap : '4px' } } >
100- < p > Referees </ p >
117+ < p > Invitees </ p >
101118 </ div >
102119 < p > { profiles ?. [ 0 ] ?. spClub ?. referees ?. length } </ p >
103120 </ div >
104121 < div style = { { marginLeft : '16px' } } >
105122 < div style = { { display : 'flex' , alignItems : 'center' , gap : '4px' } } >
106123 < p > $SP</ p >
107124 </ div >
108- < p > { ( Number ( profiles ?. [ 0 ] ?. spClub ?. totalReferees ) * SP_EARNED_FROM_REFERRAL ) || 0 } </ p >
125+ < p > 0 </ p >
109126 </ div >
110127 </ div >
111128
112129 < Separator />
113130
114- < div className = "info-wrapper" style = { { maxHeight : '200px' , overflowY : 'auto' , } } >
115- < p > History</ p >
116- < div style = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' , gap : '8px' , width : '100%' , paddingLeft : '16px' } } >
117- { profiles ?. [ 0 ] ?. spClub ?. referees
118- ? profiles ?. [ 0 ] ?. spClub . referees ?. map ( ( referee : any ) =>
119- < div style = { { display : 'flex' , flexDirection : 'row' , alignItems : 'center' , width : '100%' , gap : '8px' } } >
120- < p style = { { width : 'auto' , fontSize : '16px' , color : '#989899' , fontWeight : 400 } } > { referee ?. slice ( 0 , 5 ) + '...' + referee ?. slice ( - 5 ) } </ p >
121- < p style = { { width : 'auto' , fontSize : '16px' , color : '#9FBFE5FE' , fontWeight : 400 } } > + { SP_EARNED_FROM_REFERRAL } $SP</ p >
122- </ div >
123- )
131+ < div className = "info-wrapper" style = { { display : 'flex' , flexDirection : 'column' , justifyContent : 'space-between' , gap : '16px' } } >
132+ < p > Invitees</ p >
133+
134+ < div style = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' , gap : '8px' , width : '100%' , paddingLeft : '16px' , maxHeight : '100px' , overflowY : 'auto' , paddingRight : '10px' } } >
135+ { profiles ?. [ 0 ] ?. spClub
136+ ?
137+ profiles ?. [ 0 ] . spClub ?. totalReferees > 0 ?
138+ profiles ?. [ 0 ] ?. spClub . referees ?. map ( ( referee : any ) =>
139+ < div style = { { display : 'flex' , flexDirection : 'row' , alignItems : 'center' , width : '100%' , gap : '8px' } } >
140+ < p style = { { width : 'auto' , fontSize : '16px' , color : '#FFFFFF' , fontWeight : 400 } } > { getPassportTitle ( referee ?. activePassport ) } </ p >
141+ < p style = { { width : 'auto' , fontSize : '16px' , color : '#989899' , fontWeight : 400 } } > { referee ?. walletAddress ?. slice ( 0 , 5 ) + '...' + referee ?. walletAddress ?. slice ( - 5 ) } </ p >
142+ </ div >
143+ ) :
144+ < p > No invitees</ p >
124145 : < Skeleton width = { '100%' } height = { '20px' } /> }
125146 </ div >
147+
148+ < div style = { { width : '100%' , display : 'flex' , flexDirection : 'row' , alignItems : 'center' , justifyContent : 'center' , gap : '8px' } } >
149+ < div style = { { cursor : 'pointer' } } onClick = { handlePreviousPage } >
150+ < img src = "/assets/chevron-blue.svg" alt = "Back" width = { 16 } height = { 16 } />
151+ </ div >
152+ < div > { currentPageInvitees + 1 } of { Math . ceil ( profiles ?. [ 0 ] ?. spClub ?. totalReferees / 100 ) } </ div >
153+ < div style = { { cursor : 'pointer' } } onClick = { handleNextPage } >
154+ < img src = "/assets/chevron-blue.svg" alt = "Back" width = { 16 } height = { 16 } style = { { transform : 'rotate(180deg)' } } />
155+ </ div >
156+ </ div >
126157 </ div >
127158 </ div >
128159 </ div >
0 commit comments