Skip to content

Commit d611896

Browse files
committed
style: sp club
1 parent 6303d6c commit d611896

File tree

10 files changed

+606
-180
lines changed

10 files changed

+606
-180
lines changed

public/assets/clapping-hands.png

10.8 KB
Loading

src/components/AccountList/ReferralProgram.tsx

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,15 @@ import { ethers } from 'ethers';
1919
import { ReactComponent as VisibilityOnIcon } from "./assets/visibility-on.svg";
2020
import { ReactComponent as VisibilityOffIcon } from "./assets/visibility-off.svg";
2121

22+
const SP_EARNED_FROM_REFERRAL = 10
23+
2224
export default function ReferralProgram() {
23-
const [openAccountList, setOpenAccountList] = useState<string[]>([]);
24-
const { profiles, activePassport, setProfiles, randomSolanaRPC, getAllNodes } = useDaemonContext();
25+
const [isOpen, setIsOpen] = useState<boolean>(false);
26+
const { profiles } = useDaemonContext();
2527

26-
const [mainAccountAddressCopied, setMainAccountAddressCopied] = useState(false);
27-
const [solanaAccountAddressCopied, setSolanaAccountAddressCopied] = useState(false);
28-
const [passportToChange, setPassportToChange] = useState();
29-
const [isRefreshingSolanaBalances, setIsRefreshingSolanaBalances] = useState(false);
3028
const [isAddressHidden, setIsAddressHidden] = useState(true);
3129
const [copied, setCopied] = useState(false);
3230

33-
const { isSelectPassportPopupOpen, setIsSelectPassportPopupOpen } = useDaemonContext();
34-
35-
function toggleAccount(accountAddress: string) {
36-
setOpenAccountList((prev) => (
37-
prev.includes(accountAddress) ? prev.filter((item) => item !== accountAddress) : [...prev, accountAddress]
38-
))
39-
}
40-
4131
function handleCopy() {
4232
navigator.clipboard.writeText(profiles?.[0]?.keyID);
4333
setCopied(true)
@@ -52,8 +42,8 @@ export default function ReferralProgram() {
5242
}
5343

5444
return (
55-
<div className={`account-wrapper ${openAccountList.includes(profiles?.[0]?.keyID) ? 'active' : ''}`}>
56-
{/* <div className="account-main-card" onClick={() => toggleAccount(profiles?.[0]?.keyID)}> */}
45+
<div className={`account-wrapper ${isOpen ? 'active' : ''}`}>
46+
{/* <div className="account-main-card" onClick={() => setIsOpen((prev) => !prev)}> */}
5747
<div className="disabled account-main-card">
5848
<div className="name">
5949
<h3>Referral Program</h3>
@@ -109,13 +99,13 @@ export default function ReferralProgram() {
10999
<div style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
110100
<p>Referees</p>
111101
</div>
112-
<p>{100}</p>
102+
<p>{profiles?.[0]?.spClub?.referees?.length}</p>
113103
</div>
114104
<div style={{ marginLeft: '16px' }}>
115105
<div style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
116106
<p>$SP</p>
117107
</div>
118-
<p>{100.0006453}</p>
108+
<p>{(Number(profiles?.[0]?.spClub?.totalReferees) * SP_EARNED_FROM_REFERRAL) || 0}</p>
119109
</div>
120110
</div>
121111

@@ -124,12 +114,11 @@ export default function ReferralProgram() {
124114
<div className="info-wrapper" style={{ maxHeight: '200px', overflowY: 'auto', }}>
125115
<p>History</p>
126116
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '8px', width: '100%', paddingLeft: '16px' }}>
127-
{(profiles?.[0]?.silentPassPassports && profiles?.[0]?.activePassport)
128-
?
129-
(
117+
{profiles?.[0]?.spClub?.referees
118+
? profiles?.[0]?.spClub.referees?.map((referee: any) =>
130119
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', width: '100%', gap: '8px' }}>
131-
<p style={{ width: 'auto', fontSize: '16px', color: '#989899', fontWeight: 400 }}>{'0x628r9823u98u98sud9f8u'.slice(0, 5) + '...' + '0x628r9823u98u98sud9f8u'.slice(-5)}</p>
132-
<p style={{ width: 'auto', fontSize: '16px', color: '#9FBFE5FE', fontWeight: 400 }}>+ 10 $SP</p>
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>
133122
</div>
134123
)
135124
: <Skeleton width={'100%'} height={'20px'} />}

src/components/AccountList/SpClub.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default function SpClub() {
77
const [isOpen, setIsOpen] = useState<boolean>(false);
88
const [walletAddress, setWalletAddress] = useState('');
99
const [isCongratsPopupOpen, setIsCongratsPopupOpen] = useState<boolean>(false);
10+
const [isLoading, setIsLoading] = useState<boolean>(false);
1011

1112
return (
1213
<>
@@ -40,7 +41,7 @@ export default function SpClub() {
4041
<p style={{ width: '100%', textAlign: 'center', fontSize: '16px' }}>Get Silent Pass Passport and join the club</p>
4142
</div>
4243

43-
<button><p>Confirm</p></button>
44+
<button><p>Join Club</p></button>
4445
</div>
4546
</div>
4647
</div>

src/components/SpClubCongratsPopup/index.tsx

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,28 @@ const Backdrop = styled.div`
1818
const PopupContainer = styled.div`
1919
display: flex;
2020
flex-direction: column;
21+
align-items: center;
2122
gap: 56px;
2223
background: #191919;
2324
border-radius: 16px;
24-
padding: 16px;
2525
width: 100%;
2626
max-width: 380px;
2727
`;
2828

29+
const PopupContent = styled.div`
30+
display: flex;
31+
flex-direction: column;
32+
gap: 56px;
33+
padding: 0 16px 16px 16px;
34+
width: 100%;
35+
`;
36+
37+
const CardTop = styled.div`
38+
display: flex;
39+
flex-direction: column;
40+
align-items: center;
41+
`
42+
2943
const TextContent = styled.div`
3044
display: flex;
3145
flex-direction: column;
@@ -67,25 +81,34 @@ const Button = styled.button`
6781
background-color: #9fbfe533;
6882
`;
6983

70-
const SpClubCongratsPopup = ({ setIsCongratsPopupOpen }: { setIsCongratsPopupOpen: React.Dispatch<React.SetStateAction<boolean>> }) => {
84+
const SP_EARNED_FROM_REFERRAL = 10
85+
86+
const SpClubCongratsPopup = ({ setIsCongratsPopupOpen, memberId }: any) => {
7187

7288
return (
7389
<Backdrop onClick={() => setIsCongratsPopupOpen(false)}>
7490
<PopupContainer onClick={(e) => e.stopPropagation()}>
75-
<TextContent>
76-
<TitleContainer>
77-
<div style={{ fontSize: '32px' }}>Congratulations!</div>
78-
<div style={{ fontSize: '20px', width: '300px' }}>You've earned <span style={{ color: '#9FBFE5FE', fontWeight: '700' }}>10 $SP</span> and unlocked access to the <span style={{ color: '#9FBFE5FE', fontWeight: '700' }}>$SP Club!</span></div>
79-
</TitleContainer>
80-
<InfoContainer>
81-
<div style={{ fontSize: '16px', color: '#989899' }}>Your SP Club Member ID:</div>
82-
<div style={{ fontSize: '16px' }}>#123454354</div>
83-
</InfoContainer>
84-
</TextContent>
91+
<CardTop>
92+
<img src="/assets/congrats-card-top.png" alt="congrats" style={{ width: '100%', height: '100%', borderRadius: '16px 16px 0 0' }} />
93+
<img src="/assets/clapping-hands.png" alt="congrats" style={{ width: '88px', height: '88px', marginTop: '-65px' }} />
94+
</CardTop>
95+
96+
<PopupContent>
97+
<TextContent>
98+
<TitleContainer>
99+
<div style={{ fontSize: '32px' }}>Congratulations!</div>
100+
<div style={{ fontSize: '20px', width: '300px' }}>You've earned <span style={{ color: '#9FBFE5FE', fontWeight: '700' }}>{SP_EARNED_FROM_REFERRAL} $SP</span> and unlocked access to the <span style={{ color: '#9FBFE5FE', fontWeight: '700' }}>$SP Club!</span></div>
101+
</TitleContainer>
102+
<InfoContainer>
103+
<div style={{ fontSize: '16px', color: '#989899' }}>Your SP Club Member ID:</div>
104+
<div style={{ fontSize: '16px' }}>{memberId}</div>
105+
</InfoContainer>
106+
</TextContent>
85107

86-
<ButtonsContainer>
87-
<Button onClick={() => setIsCongratsPopupOpen(false)}>Close</Button>
88-
</ButtonsContainer>
108+
<ButtonsContainer>
109+
<Button onClick={() => setIsCongratsPopupOpen(false)}>Close</Button>
110+
</ButtonsContainer>
111+
</PopupContent>
89112
</PopupContainer>
90113
</Backdrop>
91114
);

src/pages/Home/index.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const Home = () => {
177177
let error = false;
178178
setErrorMessage('');
179179
let selectedCountryIndex = -1
180-
180+
181181
if (power) {
182182
if (window?.webkit) {
183183
window?.webkit?.messageHandlers["stopVPN"].postMessage(null)
@@ -266,20 +266,20 @@ const Home = () => {
266266
const base64VPNMessage = btoa(stringifiedVPNMessageObject);
267267
window?.webkit?.messageHandlers["startVPN"].postMessage(base64VPNMessage)
268268
}
269-
try {
270-
await startSilentPass(startVPNMessageObject);
271-
} catch (ex) {
272-
// error = true
273-
// setErrorMessage(GENERIC_ERROR);
274-
}
269+
try {
270+
await startSilentPass(startVPNMessageObject);
271+
} catch (ex) {
272+
// error = true
273+
// setErrorMessage(GENERIC_ERROR);
274+
}
275275

276276
setTimeout(() => {
277277
setIsConnectionLoading(false)
278278

279279
if (!error) {
280-
setPower(true);
281-
}
282-
280+
setPower(true);
281+
}
282+
283283
}, 1000)
284284

285285
return
@@ -288,7 +288,7 @@ const Home = () => {
288288
return (
289289
<>
290290
<Header />
291-
<div className="home">
291+
<div className="home" style={{ overflowX: 'hidden' }}>
292292
{isInitialLoading ? (
293293
<>
294294
<button

src/services/listeners.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { initProfileTokens } from "../utils/utils";
1616
import { checkCurrentRate } from "../services/passportPurchase";
1717
import {
1818
getPassportsInfoForProfile,
19+
getSpClubInfo,
1920
getVpnTimeUsed,
2021
storeSystemData,
2122
} from "./wallets";
@@ -45,9 +46,10 @@ const listenProfileVer = async (
4546
setProcessingBlock(true);
4647

4748
if (block % 10 === 0) {
48-
await getProfileAssets(profiles[0], profiles[1]);
4949
checkCurrentRate(setMiningData);
50+
await getProfileAssets(profiles[0], profiles[1]);
5051
await getVpnTimeUsed();
52+
await getSpClubInfo(profiles[0]);
5153
}
5254

5355
if (block % 2 === 0) {

src/services/wallets.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,55 @@ const refreshSolanaBalances = async (
737737
}
738738
};
739739

740+
const getSpClubInfo = async (profile: profile) => {
741+
const temp = CoNET_Data;
742+
743+
if (!temp) {
744+
return false;
745+
}
746+
747+
const wallet = new ethers.Wallet(profile.privateKeyArmor, conetDepinProvider);
748+
const contract = new ethers.Contract(
749+
contracts.SpClub.address,
750+
contracts.SpClub.abi,
751+
wallet
752+
);
753+
754+
if (!profile.spClub) {
755+
profile.spClub = {
756+
memberId: "0",
757+
referrer: "",
758+
referees: [],
759+
totalReferees: 0,
760+
};
761+
}
762+
763+
try {
764+
const result = await contract.membership(profile.keyID);
765+
profile.spClub.memberId = result;
766+
} catch (error) {
767+
console.log(error);
768+
}
769+
770+
try {
771+
const result = await contract.getReferrer(profile.keyID);
772+
profile.spClub.referrer = result;
773+
} catch (error) {
774+
console.log(error);
775+
}
776+
777+
try {
778+
const result = await contract.getReferees(profile.keyID, 0);
779+
profile.spClub.referees = result.referees;
780+
profile.spClub.totalReferees = result._total_length;
781+
} catch (error) {
782+
console.log(error);
783+
}
784+
785+
temp.profiles[0] = profile;
786+
setCoNET_Data(temp);
787+
};
788+
740789
export {
741790
createOrGetWallet,
742791
createGPGKey,
@@ -751,4 +800,5 @@ export {
751800
getVpnTimeUsed,
752801
getPassportsInfoForProfile,
753802
refreshSolanaBalances,
803+
getSpClubInfo,
754804
};

src/types.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ interface profile extends keyPair {
6868
tokens: conet_tokens;
6969
isNode: boolean;
7070
referrer: string | null | undefined;
71+
spClub?: SpClub;
7172
data?: any;
7273
type?: keyPairType;
7374
nodeID?: number;
@@ -78,6 +79,13 @@ interface profile extends keyPair {
7879
silentPassPassports?: passportInfo[];
7980
}
8081

82+
interface SpClub {
83+
memberId: string;
84+
referrer: string;
85+
referees: string[];
86+
totalReferees: number;
87+
}
88+
8189
type encrypt_keys_object = {
8290
profiles: profile[];
8391
isReady: boolean;
@@ -149,7 +157,7 @@ interface nodeResponse {
149157
currentCCNTP?: string;
150158
minerResponseHash?: string;
151159
userWallets?: string[];
152-
totalUsers: string
160+
totalUsers: string;
153161
nodeWallets?: string[];
154162
online?: string;
155163
}

0 commit comments

Comments
 (0)