Flesh out the state wiring for auth
This commit is contained in:
parent
251c3fc25d
commit
bbb64c4111
3 changed files with 12 additions and 4 deletions
|
@ -24,4 +24,5 @@ export const userLogin = (username, password) => async (dispatch) => {
|
|||
password: password
|
||||
})
|
||||
dispatch({ type: 'USER_LOGIN', payload: response })
|
||||
return(response)
|
||||
};
|
||||
|
|
|
@ -63,9 +63,16 @@ class AuthMenu extends Component {
|
|||
|
||||
handleLogin() {
|
||||
this.props.userLogin(this.state.username, this.state.password)
|
||||
this.setState(state => ({
|
||||
auth_menu_visible: false,
|
||||
}));
|
||||
.then(res => {
|
||||
this.setState(state => ({
|
||||
auth_menu_visible: false
|
||||
}))
|
||||
console.log(res)
|
||||
}
|
||||
)
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
handleCreateAccount() {
|
||||
|
|
|
@ -7,7 +7,7 @@ const initialState = {
|
|||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case 'USER_LOGIN':
|
||||
return {jwt: action.payload}
|
||||
return {...state, ...{jwt: action.payload}}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Reference in a new issue