@@ -8,7 +8,7 @@ import Link from 'next/link'
8
8
class Accounts extends React . Component {
9
9
constructor ( props ) {
10
10
super ( props )
11
- this . state = { newAccountNickname : '' , accounts : false }
11
+ this . state = { currentAccountNickname : '' , accounts : false }
12
12
}
13
13
14
14
componentDidMount = async ( ) => {
@@ -18,7 +18,7 @@ class Accounts extends React.Component {
18
18
}
19
19
20
20
handleOnNewAccountNameChange = e => {
21
- this . setState ( { newAccountNickname : e . currentTarget . value } )
21
+ this . setState ( { currentAccountNickname : e . currentTarget . value } )
22
22
}
23
23
24
24
handleOnSuccess = ( public_token , metadata ) => {
@@ -27,7 +27,7 @@ class Accounts extends React.Component {
27
27
}
28
28
const body = {
29
29
public_token,
30
- accountNickname : this . state . newAccountNickname
30
+ accountNickname : this . state . currentAccountNickname
31
31
}
32
32
fetch ( `http://${ process . env . HOST } :${ process . env . PORT } /token` , {
33
33
method : 'POST' ,
@@ -38,16 +38,18 @@ class Accounts extends React.Component {
38
38
} )
39
39
}
40
40
41
- handleOnUpdateAccountResponse = data => {
42
- window . Plaid . create ( {
43
- clientName : 'Mintable' ,
44
- env : this . props . config . PLAID_ENVIRONMENT ,
45
- product : [ 'auth' , 'transactions' ] ,
46
- key : this . props . config . PLAID_PUBLIC_KEY ,
47
- onExit : this . handleOnExit ,
48
- onSuccess : this . handleOnSuccess ,
49
- token : data
50
- } ) . open ( )
41
+ handleOnUpdateAccountResponse = ( data , nickname ) => {
42
+ this . setState ( { currentAccountNickname : nickname } , ( ) =>
43
+ window . Plaid . create ( {
44
+ clientName : 'Mintable' ,
45
+ env : this . props . config . PLAID_ENVIRONMENT ,
46
+ product : [ 'auth' , 'transactions' ] ,
47
+ key : this . props . config . PLAID_PUBLIC_KEY ,
48
+ onExit : this . handleOnExit ,
49
+ onSuccess : this . handleOnSuccess ,
50
+ token : data
51
+ } ) . open ( )
52
+ )
51
53
}
52
54
53
55
render = ( ) => {
@@ -102,7 +104,7 @@ class Accounts extends React.Component {
102
104
onSuccess = { this . handleOnSuccess }
103
105
style = { {
104
106
background : '#137cbd' ,
105
- display : this . state . newAccountNickname ? 'flex' : 'none'
107
+ display : this . state . currentAccountNickname ? 'flex' : 'none'
106
108
} }
107
109
>
108
110
Add New Account
0 commit comments