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" ;
2111import { getPassportTitle } from '../../utils/utils' ;
12+ import { currentPageInvitees , setCurrentPageInvitees } from '../../utils/globals' ;
13+ import { getRefereesPage } from '../../services/wallets' ;
2214
2315const SP_EARNED_FROM_REFERRAL = 10
2416
@@ -28,6 +20,30 @@ export default function ReferralProgram() {
2820
2921 const [ isAddressHidden , setIsAddressHidden ] = useState ( true ) ;
3022 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 ] )
3147
3248 function handleCopy ( ) {
3349 navigator . clipboard . writeText ( profiles ?. [ 0 ] ?. keyID ) ;
@@ -57,7 +73,7 @@ export default function ReferralProgram() {
5773 { profiles ?. [ 0 ] ?. keyID ?
5874 < >
5975 < div className = "copy-text" >
60- < p > Wallet Address </ p >
76+ < p > Copy this wallet address to invite your friends to Silent Pass </ p >
6177 {
6278 isAddressHidden ?
6379 < div style = { { filter : 'blur(3px)' } } >
@@ -98,23 +114,24 @@ export default function ReferralProgram() {
98114 </ div >
99115 < div style = { { marginLeft : '16px' } } >
100116 < div style = { { display : 'flex' , alignItems : 'center' , gap : '4px' } } >
101- < p > Referees </ p >
117+ < p > Invitees </ p >
102118 </ div >
103119 < p > { profiles ?. [ 0 ] ?. spClub ?. referees ?. length } </ p >
104120 </ div >
105121 < div style = { { marginLeft : '16px' } } >
106122 < div style = { { display : 'flex' , alignItems : 'center' , gap : '4px' } } >
107123 < p > $SP</ p >
108124 </ div >
109- < p > { ( Number ( profiles ?. [ 0 ] ?. spClub ?. totalReferees ) * SP_EARNED_FROM_REFERRAL ) || 0 } </ p >
125+ < p > 0 </ p >
110126 </ div >
111127 </ div >
112128
113129 < Separator />
114130
115- < div className = "info-wrapper" style = { { maxHeight : '200px ' , overflowY : 'auto' , } } >
131+ < div className = "info-wrapper" style = { { display : 'flex ' , flexDirection : 'column' , justifyContent : 'space-between' , gap : '16px' } } >
116132 < p > Invitees</ p >
117- < div style = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' , gap : '8px' , width : '100%' , paddingLeft : '16px' } } >
133+
134+ < div style = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' , gap : '8px' , width : '100%' , paddingLeft : '16px' , maxHeight : '100px' , overflowY : 'auto' , paddingRight : '10px' } } >
118135 { profiles ?. [ 0 ] ?. spClub
119136 ?
120137 profiles ?. [ 0 ] . spClub ?. totalReferees > 0 ?
@@ -127,6 +144,16 @@ export default function ReferralProgram() {
127144 < p > No invitees</ p >
128145 : < Skeleton width = { '100%' } height = { '20px' } /> }
129146 </ 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 >
130157 </ div >
131158 </ div >
132159 </ div >
0 commit comments