@@ -3,7 +3,7 @@ import ldClient from "launchdarkly";
3
3
import { MetamaskProviderContext } from "@site/src/theme/Root" ;
4
4
import Select from "react-dropdown-select" ;
5
5
import Button from "@site/src/components/Button" ;
6
- import styles from "./styles.module.css " ;
6
+ import styles from "./styles.module.scss " ;
7
7
import { WALLET_LINK_TYPE } from "@site/src/components/AuthLogin/AuthModal" ;
8
8
9
9
const LOGIN_FF = "mm-unified-login" ;
@@ -15,6 +15,7 @@ const ProjectsBox = () => {
15
15
walletLinked,
16
16
metaMaskWalletIdConnectHandler,
17
17
walletLinkUrl,
18
+ setUserAPIKey,
18
19
} = useContext ( MetamaskProviderContext ) ;
19
20
const options = Object . keys ( projects ) . map ( ( v ) => ( {
20
21
value : v ,
@@ -25,6 +26,12 @@ const ProjectsBox = () => {
25
26
) ;
26
27
const [ ldReady , setLdReady ] = useState ( false ) ;
27
28
const [ loginEnabled , setLoginEnabled ] = useState ( false ) ;
29
+ const [ isWalletLinking , setIsWalletLinking ] = useState ( false ) ;
30
+
31
+ const metaMaskWalletConnectionHandler = ( ) => {
32
+ setIsWalletLinking ( true ) ;
33
+ metaMaskWalletIdConnectHandler ( ) ;
34
+ }
28
35
29
36
useEffect ( ( ) => {
30
37
ldClient . waitUntilReady ( ) . then ( ( ) => {
@@ -41,9 +48,24 @@ const ProjectsBox = () => {
41
48
} , [ ] ) ;
42
49
43
50
useEffect ( ( ) => {
44
- if ( ! currentProject . length && options [ 0 ] ) setCurrentProject ( [ options [ 0 ] ] ) ;
51
+ if ( ! currentProject . length && options [ 0 ] ) {
52
+ setCurrentProject ( [ options [ 0 ] ] ) ;
53
+ setUserAPIKey ( options [ 0 ] . value ) ;
54
+ }
45
55
} , [ projects ] ) ;
46
56
57
+ useEffect ( ( ) => {
58
+ if ( options ?. length > 0 ) {
59
+ setUserAPIKey ( options [ 0 ] . value ) ;
60
+ }
61
+ } , [ options . length ] ) ;
62
+
63
+ useEffect ( ( ) => {
64
+ if ( walletLinked ) {
65
+ setIsWalletLinking ( false ) ;
66
+ }
67
+ } , [ walletLinked ] )
68
+
47
69
return (
48
70
ldReady &&
49
71
loginEnabled && (
@@ -57,14 +79,17 @@ const ProjectsBox = () => {
57
79
searchable = { false }
58
80
options = { options }
59
81
values = { currentProject }
60
- onChange = { ( value ) => setCurrentProject ( value ) }
82
+ onChange = { ( value ) => {
83
+ setCurrentProject ( value ) ;
84
+ setUserAPIKey ( value [ 0 ] . value ) ;
85
+ } }
61
86
contentRenderer = { ( { state } ) => {
62
87
return (
63
88
< div >
64
89
{ state . values . map ( ( item ) => (
65
90
< div key = { item . value } >
66
- < div > { item . label } </ div >
67
- < div > { item . value } </ div >
91
+ < div className = { styles . selectDropdownLabel } > { item . label } </ div >
92
+ < div className = { styles . selectDropdownValue } > { item . value } </ div >
68
93
</ div >
69
94
) ) }
70
95
</ div >
@@ -75,12 +100,12 @@ const ProjectsBox = () => {
75
100
< div className = { styles . selectDropdown } >
76
101
{ options . map ( ( option ) => (
77
102
< div
103
+ className = { styles . selectDropdownOption }
78
104
key = { option . value }
79
- style = { { padding : "8px 16px" } }
80
105
onClick = { ( ) => methods . addItem ( option ) }
81
106
>
82
- < div > { option . label } </ div >
83
- < div > { option . value } </ div >
107
+ < div className = { styles . selectDropdownLabel } > { option . label } </ div >
108
+ < div className = { styles . selectDropdownValue } > { option . value } </ div >
84
109
</ div >
85
110
) ) }
86
111
</ div >
@@ -92,13 +117,17 @@ const ProjectsBox = () => {
92
117
{ walletLinked === undefined && (
93
118
< >
94
119
< div >
95
- Connect your MetaMask wallet to start sending requests to your
96
- Infura API keys.
120
+ { isWalletLinking ?
121
+ "Don’t close or exit this page. Please continue connecting on your extension." :
122
+ "Connect your MetaMask wallet to start sending requests to your Infura API keys."
123
+ }
97
124
</ div >
98
125
< Button
99
126
thin
100
127
className = { styles . connectButton }
101
- onClick = { metaMaskWalletIdConnectHandler }
128
+ onClick = { metaMaskWalletConnectionHandler }
129
+ textColor = "light"
130
+ isLoading = { isWalletLinking }
102
131
>
103
132
Connect Wallet
104
133
</ Button >
@@ -112,7 +141,8 @@ const ProjectsBox = () => {
112
141
</ div >
113
142
< Button
114
143
thin
115
- className = { styles . connectButton }
144
+ variant = "secondary"
145
+ wrapText = { false }
116
146
onClick = { ( ) => ( window . location . href = walletLinkUrl ) }
117
147
>
118
148
Link Infura Account
0 commit comments