@@ -3,80 +3,50 @@ import {
33 Box ,
44 Typography ,
55 Button ,
6- TextField ,
76 Card ,
87 CardContent ,
98 IconButton ,
109 Snackbar ,
1110 Alert ,
1211 Chip
1312} from '@mui/material' ;
14- import { styled } from '@mui/material/styles' ;
1513import {
1614 PersonAdd as PersonAddIcon ,
1715 ContentCopy as CopyIcon ,
1816 Share as ShareIcon ,
1917 Twitter as TwitterIcon ,
18+ Wallet as WalletIcon ,
2019} from '@mui/icons-material' ;
2120import VaultService from '../services/VaultService' ;
21+ import { useVaultWallet } from '../hooks/useVaultWallet' ;
22+ import { useTruncateAddress } from '../utils' ;
23+ import {
24+ GlassCard ,
25+ VaultTextField ,
26+ SecondaryButton ,
27+ SectionHeader ,
28+ StatusChip
29+ } from './shared/StyledComponents' ;
30+
2231
23- const InviteCard = styled ( Card ) ( ( { theme } ) => ( {
24- background : 'rgba(255, 255, 255, 0.08)' ,
25- backdropFilter : 'blur(20px)' ,
26- border : '1px solid rgba(255, 255, 255, 0.1)' ,
27- borderRadius : 16 ,
28- transition : 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)' ,
29- } ) ) ;
30-
31- const SectionHeader = styled ( Box ) ( ( { theme } ) => ( {
32- display : 'flex' ,
33- alignItems : 'center' ,
34- marginBottom : theme . spacing ( 2 ) ,
35- '& h6' : {
36- display : 'flex' ,
37- alignItems : 'center' ,
38- gap : theme . spacing ( 1 ) ,
39- } ,
40- } ) ) ;
41-
42- const InviteLink = styled ( TextField ) ( ( { theme } ) => ( {
43- '& .MuiOutlinedInput-root' : {
44- background : 'rgba(255, 255, 255, 0.05)' ,
45- borderRadius : 12 ,
46- '&:hover' : {
47- background : 'rgba(255, 255, 255, 0.08)' ,
48- } ,
49- '&.Mui-focused' : {
50- background : 'rgba(255, 255, 255, 0.08)' ,
51- } ,
52- } ,
53- '& .MuiOutlinedInput-input' : {
54- color : '#FFD700' ,
55- fontFamily : 'monospace' ,
56- fontSize : '0.9rem' ,
57- } ,
58- } ) ) ;
59-
60- const BenefitChip = styled ( Chip ) ( ( { theme } ) => ( {
61- background : 'linear-gradient(135deg, #FF6B6B, #FF8E8E)' ,
62- color : '#fff' ,
63- fontWeight : 'bold' ,
64- margin : theme . spacing ( 0.5 ) ,
65- } ) ) ;
6632
6733const InviteSection : React . FC = ( ) => {
6834 const [ inviteLink , setInviteLink ] = useState ( '' ) ;
6935 const [ snackbar , setSnackbar ] = useState ( { open : false , message : '' , severity : 'success' as 'success' | 'error' } ) ;
7036
37+ const { walletAddress, isConnected, connectWallet, isConnecting } = useVaultWallet ( ) ;
38+ const truncateAddress = useTruncateAddress ( ) ;
7139 const vaultService = VaultService . getInstance ( ) ;
7240
7341 useEffect ( ( ) => {
74- // Generate invite link for current user (mock address for demo)
75- const mockUserAddress = '0xYourWallet123' ;
76- const link = vaultService . generateReferralLink ( mockUserAddress ) ;
77- setInviteLink ( link ) ;
78- // eslint-disable-next-line react-hooks/exhaustive-deps
79- } , [ ] ) ;
42+ // Generate invite link for current user
43+ if ( walletAddress ) {
44+ const link = vaultService . generateReferralLink ( walletAddress ) ;
45+ setInviteLink ( link ) ;
46+ } else {
47+ setInviteLink ( '' ) ;
48+ }
49+ } , [ walletAddress , vaultService ] ) ;
8050
8151 const handleCopyLink = async ( ) => {
8252 try {
@@ -117,7 +87,7 @@ const InviteSection: React.FC = () => {
11787 } ;
11888
11989 return (
120- < InviteCard >
90+ < GlassCard >
12191 < CardContent >
12292 < SectionHeader >
12393 < Typography variant = "h6" >
@@ -130,100 +100,117 @@ const InviteSection: React.FC = () => {
130100 Share your invite link and earn bonus lottery tickets when your friends start trading!
131101 </ Typography >
132102
103+ { /* Wallet Connection Status */ }
104+ < Box mb = { 3 } >
105+ < Box display = "flex" alignItems = "center" gap = { 2 } mb = { 2 } >
106+ < WalletIcon sx = { { color : isConnected ? '#4CAF50' : '#FFD700' } } />
107+ < Typography variant = "subtitle2" >
108+ Wallet Status:
109+ </ Typography >
110+ < StatusChip
111+ variant = { isConnected ? 'success' : 'warning' }
112+ label = { isConnected ? 'Connected' : 'Mock Address' }
113+ size = "small"
114+ />
115+ </ Box >
116+
117+ { walletAddress && (
118+ < Box mb = { 2 } >
119+ < Typography variant = "caption" color = "text.secondary" >
120+ Your Address: { truncateAddress ( walletAddress ) }
121+ </ Typography >
122+ </ Box >
123+ ) }
124+
125+ { ! isConnected && (
126+ < SecondaryButton
127+ size = "small"
128+ startIcon = { < WalletIcon /> }
129+ onClick = { connectWallet }
130+ disabled = { isConnecting }
131+ sx = { { mb : 2 } }
132+ >
133+ { isConnecting ? 'Connecting...' : 'Connect Wallet' }
134+ </ SecondaryButton >
135+ ) }
136+ </ Box >
137+
133138 { /* Benefits */ }
134139 < Box mb = { 3 } >
135140 < Typography variant = "subtitle2" gutterBottom >
136141 Referral Benefits:
137142 </ Typography >
138143 < Box >
139- < BenefitChip size = "small" label = "Bonus Lottery Tickets" />
140- < BenefitChip size = "small" label = "Fee Share Rewards" />
141- < BenefitChip size = "small" label = "Streak Multipliers" />
142- < BenefitChip size = "small" label = "Exclusive NFT Badges" />
144+ < StatusChip variant = "info" size = "small" label = "Bonus Lottery Tickets" sx = { { m : 0.5 } } />
145+ < StatusChip variant = "success" size = "small" label = "Fee Share Rewards" sx = { { m : 0.5 } } />
146+ < StatusChip variant = "warning" size = "small" label = "Streak Multipliers" sx = { { m : 0.5 } } />
147+ < StatusChip variant = "error" size = "small" label = "Exclusive NFT Badges" sx = { { m : 0.5 } } />
143148 </ Box >
144149 </ Box >
145150
146151 { /* Invite Link */ }
147- < Box mb = { 3 } >
148- < Typography variant = "subtitle2" gutterBottom >
149- Your Invite Link:
150- </ Typography >
151- < InviteLink
152- fullWidth
153- value = { inviteLink }
154- InputProps = { {
155- readOnly : true ,
156- endAdornment : (
157- < IconButton onClick = { handleCopyLink } sx = { { color : '#FFD700' } } >
158- < CopyIcon />
159- </ IconButton >
160- ) ,
161- } }
162- />
163- </ Box >
152+ { walletAddress && (
153+ < Box mb = { 3 } >
154+ < Typography variant = "subtitle2" gutterBottom >
155+ Your Invite Link:
156+ </ Typography >
157+ < VaultTextField
158+ fullWidth
159+ value = { inviteLink }
160+ InputProps = { {
161+ readOnly : true ,
162+ endAdornment : (
163+ < IconButton onClick = { handleCopyLink } sx = { { color : '#FFD700' } } >
164+ < CopyIcon />
165+ </ IconButton >
166+ ) ,
167+ } }
168+ />
169+ </ Box >
170+ ) }
164171
165172 { /* Share Buttons */ }
166- < div style = { { display : 'flex' , flexDirection : 'column' , gap : 16 } } >
167- < div style = { { display : 'flex' , flexDirection : 'row' , gap : 16 , flexWrap : 'wrap' } } >
168- < Button
169- sx = { {
170- flex : 1 ,
171- minWidth : 120 ,
172- background : 'linear-gradient(135deg, #4ECDC4, #44B7B8)' ,
173- color : '#fff' ,
174- fontWeight : 'bold' ,
175- borderRadius : 3 ,
176- textTransform : 'none' ,
177- '&:hover' : {
178- background : 'linear-gradient(135deg, #44B7B8, #3BAEA3)' ,
179- transform : 'translateY(-2px)' ,
180- } ,
181- } }
182- startIcon = { < CopyIcon /> }
183- onClick = { handleCopyLink }
184- >
185- Copy Link
186- </ Button >
187- < Button
188- sx = { {
189- flex : 1 ,
190- minWidth : 120 ,
191- background : 'linear-gradient(135deg, #1DA1F2, #0D8BD9)' ,
192- color : '#fff' ,
193- fontWeight : 'bold' ,
194- borderRadius : 3 ,
195- textTransform : 'none' ,
196- '&:hover' : {
197- background : 'linear-gradient(135deg, #0D8BD9, #0A7BC2)' ,
198- transform : 'translateY(-2px)' ,
199- } ,
200- } }
201- startIcon = { < TwitterIcon /> }
202- onClick = { handleShareOnTwitter }
203- >
204- Share on X
205- </ Button >
206- < Button
207- sx = { {
208- flex : 1 ,
209- minWidth : 120 ,
210- background : 'linear-gradient(135deg, #9B59B6, #8E44AD)' ,
211- color : '#fff' ,
212- fontWeight : 'bold' ,
213- borderRadius : 3 ,
214- textTransform : 'none' ,
215- '&:hover' : {
216- background : 'linear-gradient(135deg, #8E44AD, #7D3C98)' ,
217- transform : 'translateY(-2px)' ,
218- } ,
219- } }
220- startIcon = { < ShareIcon /> }
221- onClick = { handleGenericShare }
222- >
223- Share
224- </ Button >
225- </ div >
226- </ div >
173+ { walletAddress && (
174+ < Box display = "flex" flexDirection = "column" gap = { 2 } >
175+ < Box display = "flex" flexDirection = "row" gap = { 2 } flexWrap = "wrap" >
176+ < SecondaryButton
177+ sx = { { flex : 1 , minWidth : 120 } }
178+ startIcon = { < CopyIcon /> }
179+ onClick = { handleCopyLink }
180+ >
181+ Copy Link
182+ </ SecondaryButton >
183+ < SecondaryButton
184+ sx = { {
185+ flex : 1 ,
186+ minWidth : 120 ,
187+ background : 'linear-gradient(135deg, #1DA1F2, #0D8BD9)' ,
188+ '&:hover' : {
189+ background : 'linear-gradient(135deg, #0D8BD9, #0A7BC2)' ,
190+ } ,
191+ } }
192+ startIcon = { < TwitterIcon /> }
193+ onClick = { handleShareOnTwitter }
194+ >
195+ Share on X
196+ </ SecondaryButton >
197+ < SecondaryButton
198+ sx = { {
199+ flex : 1 ,
200+ minWidth : 120 ,
201+ background : 'linear-gradient(135deg, #9B59B6, #8E44AD)' ,
202+ '&:hover' : {
203+ background : 'linear-gradient(135deg, #8E44AD, #7D3C98)' ,
204+ } ,
205+ } }
206+ startIcon = { < ShareIcon /> }
207+ onClick = { handleGenericShare }
208+ >
209+ Share
210+ </ SecondaryButton >
211+ </ Box >
212+ </ Box >
213+ ) }
227214
228215 < Snackbar
229216 open = { snackbar . open }
@@ -236,7 +223,7 @@ const InviteSection: React.FC = () => {
236223 </ Alert >
237224 </ Snackbar >
238225 </ CardContent >
239- </ InviteCard >
226+ </ GlassCard >
240227 ) ;
241228} ;
242229
0 commit comments