1
0
Fork 0

Flesh out the state wiring for auth

This commit is contained in:
Amarpreet Minhas 2019-09-16 20:53:34 -04:00
parent 251c3fc25d
commit bbb64c4111
3 changed files with 12 additions and 4 deletions

View file

@ -24,4 +24,5 @@ export const userLogin = (username, password) => async (dispatch) => {
password: password
})
dispatch({ type: 'USER_LOGIN', payload: response })
return(response)
};

View file

@ -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() {

View file

@ -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;
}