Skip to content

Commit b4ac9b6

Browse files
committed
Bug fix for logic for setting token for re-authenticated accounts
1 parent 608927b commit b4ac9b6

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/components/account.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const Account = props => {
4040
'Content-Type': 'application/json'
4141
}
4242
}).then(data => {
43-
props.handleOnUpdateAccountResponse(data)
43+
props.handleOnUpdateAccountResponse(data, props.details.nickname)
4444
})
4545
}
4646

src/components/accounts.jsx

+16-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Link from 'next/link'
88
class Accounts extends React.Component {
99
constructor(props) {
1010
super(props)
11-
this.state = { newAccountNickname: '', accounts: false }
11+
this.state = { currentAccountNickname: '', accounts: false }
1212
}
1313

1414
componentDidMount = async () => {
@@ -18,7 +18,7 @@ class Accounts extends React.Component {
1818
}
1919

2020
handleOnNewAccountNameChange = e => {
21-
this.setState({ newAccountNickname: e.currentTarget.value })
21+
this.setState({ currentAccountNickname: e.currentTarget.value })
2222
}
2323

2424
handleOnSuccess = (public_token, metadata) => {
@@ -27,7 +27,7 @@ class Accounts extends React.Component {
2727
}
2828
const body = {
2929
public_token,
30-
accountNickname: this.state.newAccountNickname
30+
accountNickname: this.state.currentAccountNickname
3131
}
3232
fetch(`http://${process.env.HOST}:${process.env.PORT}/token`, {
3333
method: 'POST',
@@ -38,16 +38,18 @@ class Accounts extends React.Component {
3838
})
3939
}
4040

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+
)
5153
}
5254

5355
render = () => {
@@ -102,7 +104,7 @@ class Accounts extends React.Component {
102104
onSuccess={this.handleOnSuccess}
103105
style={{
104106
background: '#137cbd',
105-
display: this.state.newAccountNickname ? 'flex' : 'none'
107+
display: this.state.currentAccountNickname ? 'flex' : 'none'
106108
}}
107109
>
108110
Add New Account

0 commit comments

Comments
 (0)