@@ -6,44 +6,92 @@ interface WalletModalProps {
6
6
}
7
7
8
8
const WalletModal = ( { isOpen, onDisconnect } : WalletModalProps ) => {
9
- const { balance, enabledWallet, walletAddress } = useWalletStore ( )
9
+ const { balance, enabledWallet, walletAddress, isConnected , connect } = useWalletStore ( )
10
10
11
11
if ( ! isOpen ) return null
12
12
13
+ const handleConnect = async ( ) => {
14
+ try {
15
+ const walletNames = [ 'nami' , 'eternl' , 'flint' , 'yoroi' , 'gerowallet' ]
16
+ let connected = false
17
+
18
+ for ( const walletName of walletNames ) {
19
+ const success = await connect ( walletName )
20
+ if ( success ) {
21
+ connected = true
22
+ break
23
+ }
24
+ }
25
+
26
+ if ( ! connected ) {
27
+ console . warn ( 'No compatible wallets found. Please install a supported Cardano wallet.' )
28
+ }
29
+ } catch ( error ) {
30
+ console . error ( 'Failed to connect wallet:' , error )
31
+ }
32
+ }
33
+
13
34
return (
14
35
< div className = "w-full bg-transparent flex justify-end" >
15
36
< div className = "min-w-full sm:min-w-[37.8125rem] px-4 py-8" >
16
37
< div className = "border-1 border-white rounded-md bg-transparent p-6" >
17
- < div className = "flex justify-between items-start" >
18
- { /* Left side */ }
19
- < div className = "flex flex-col gap-4 " >
38
+ { ! isConnected ? (
39
+ // Wallet not connected - show connection prompt
40
+ < div className = "flex flex-col items-start gap-2 " >
20
41
< div className = "flex items-center gap-3" >
21
42
< img
22
43
src = "/wallet-icon-white.svg"
23
44
alt = "Wallet"
24
45
className = "w-8 h-8"
25
46
/>
26
47
< div className = "flex flex-col" >
27
- < h3 className = "text-white font-medium text-lg" > Your Wallet</ h3 >
28
- < p className = "text-white/70 text-sm max-w-[10rem] truncate" > { enabledWallet } : { walletAddress } </ p >
48
+ < h3 className = "text-white font-medium text-lg" > Connect Wallet</ h3 >
49
+ < p className = "text-white/70 text-sm" > Connect your wallet to purchase VPN access </ p >
29
50
</ div >
30
51
</ div >
52
+ < div className = "text-center" >
53
+ < p className = "text-white text-lg font-bold" > 0.00 < span className = "text-sm font-normal" > ADA</ span > </ p >
54
+ </ div >
31
55
< button
32
- onClick = { onDisconnect }
33
- className = "bg-white text-black px-6 py-2 rounded-lg font-medium w-fit self-start "
56
+ onClick = { handleConnect }
57
+ className = "bg-white text-black px-6 py-2 rounded-lg font-medium w-fit"
34
58
>
35
- Disconnect
59
+ Connect Wallet
36
60
</ button >
37
61
</ div >
62
+ ) : (
63
+ // Wallet connected - show wallet info
64
+ < div className = "flex justify-between items-start" >
65
+ { /* Left side */ }
66
+ < div className = "flex flex-col gap-4" >
67
+ < div className = "flex items-center gap-3" >
68
+ < img
69
+ src = "/wallet-icon-white.svg"
70
+ alt = "Wallet"
71
+ className = "w-8 h-8"
72
+ />
73
+ < div className = "flex flex-col" >
74
+ < h3 className = "text-white font-medium text-lg" > Your Wallet</ h3 >
75
+ < p className = "text-white/70 text-sm max-w-[10rem] truncate" > { enabledWallet } : { walletAddress } </ p >
76
+ </ div >
77
+ </ div >
78
+ < button
79
+ onClick = { onDisconnect }
80
+ className = "bg-white text-black px-6 py-2 rounded-lg font-medium w-fit self-start"
81
+ >
82
+ Disconnect
83
+ </ button >
84
+ </ div >
38
85
39
- { /* Right side */ }
40
- < div className = "text-right" >
41
- < p className = "text-white/70 text-sm mb-2 font-normal" > Wallet Balance</ p >
42
- < p className = "text-white text-2xl font-bold" >
43
- { balance || "0.00" } < span className = "text-sm font-normal" > ADA</ span >
44
- </ p >
86
+ { /* Right side */ }
87
+ < div className = "text-right" >
88
+ < p className = "text-white/70 text-sm mb-2 font-normal" > Wallet Balance</ p >
89
+ < p className = "text-white text-2xl font-bold" >
90
+ { balance || "0.00" } < span className = "text-sm font-normal" > ADA</ span >
91
+ </ p >
92
+ </ div >
45
93
</ div >
46
- </ div >
94
+ ) }
47
95
</ div >
48
96
</ div >
49
97
</ div >
0 commit comments