Pass down username to state
This commit is contained in:
parent
45243c7e26
commit
92ef06cafc
4 changed files with 9 additions and 3 deletions
|
@ -23,5 +23,10 @@ export const userLogin = (username, password) => async (dispatch) => {
|
|||
username: username,
|
||||
password: password
|
||||
})
|
||||
dispatch({ type: 'USER_LOGIN', payload: response })
|
||||
if (response.status === 401) {
|
||||
alert("Please check your credentials")
|
||||
}
|
||||
if (response.status === 200) {
|
||||
dispatch({ type: 'USER_LOGIN', payload: response })
|
||||
}
|
||||
};
|
||||
|
|
|
@ -67,7 +67,7 @@ class AuthMenu extends Component {
|
|||
this.setState(state => ({
|
||||
auth_menu_visible: false
|
||||
}))
|
||||
console.log(res)
|
||||
this.props.close()
|
||||
}
|
||||
)
|
||||
.catch(err => {
|
||||
|
|
|
@ -29,7 +29,7 @@ class NavBar extends Component {
|
|||
<div onClick={this.handleLoginDropdown} className='item ui button dropdown'>
|
||||
Login
|
||||
<i className="dropdown icon"></i>
|
||||
<AuthMenu auth_menu_visible={this.state.auth_menu_visible}></AuthMenu>
|
||||
<AuthMenu auth_menu_visible={this.state.auth_menu_visible} close={ () => this.setState({auth_menu_visible: false})}></AuthMenu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,6 +9,7 @@ export default (state = initialState, action) => {
|
|||
case 'USER_LOGIN':
|
||||
return {...state, ...{
|
||||
jwt: action.payload.data.jwt,
|
||||
username: action.payload.data.username,
|
||||
user_logged_in: true
|
||||
}}
|
||||
default:
|
||||
|
|
Reference in a new issue