update : handle login
This commit is contained in:
parent
93840908ba
commit
106f98c4ff
|
@ -12,13 +12,23 @@ import Hidden from '@material-ui/core/Hidden';
|
|||
import InputAdornment from '@material-ui/core/InputAdornment';
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
import { Link } from 'react-router-dom'
|
||||
import {inject, observer} from 'mobx-react';
|
||||
|
||||
@inject('appstate')
|
||||
@observer
|
||||
class BTNLoginPage extends React.Component{
|
||||
state = {
|
||||
email : "",
|
||||
password : "",
|
||||
showPassword : false
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.props = props;
|
||||
this.state = {
|
||||
email: "",
|
||||
password: "",
|
||||
showPassword : false
|
||||
};
|
||||
this.defaultState = Object.assign({}, this.state);
|
||||
this.authStore = props.appstate.auth;
|
||||
}
|
||||
|
||||
handleChange = name => event => {
|
||||
this.setState({
|
||||
|
@ -32,6 +42,20 @@ class BTNLoginPage extends React.Component{
|
|||
})
|
||||
};
|
||||
|
||||
login = () => {
|
||||
const email = this.state.email;
|
||||
const password = this.state.password;
|
||||
const data = {
|
||||
username: email,
|
||||
password: password,
|
||||
}
|
||||
this.authStore.login(data).then(res => {
|
||||
this.props.history.push(LINKS.DASHBOARD);
|
||||
}).catch(err => {
|
||||
alert(err.message);
|
||||
});
|
||||
};
|
||||
|
||||
render(){
|
||||
const { classes } = this.props;
|
||||
return (
|
||||
|
@ -93,7 +117,7 @@ class BTNLoginPage extends React.Component{
|
|||
}}
|
||||
/>
|
||||
<div style={{padding : 5,marginTop : 20}}>
|
||||
<Button fullWidth variant="contained" color="secondary">
|
||||
<Button onClick={()=>this.login()} fullWidth variant="contained" color="secondary">
|
||||
Sign In
|
||||
</Button>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user