update: login function and purchased item store

This commit is contained in:
Rifqy Zacky Ariadhy
2019-01-06 15:18:00 +07:00
parent 02c17264b7
commit d7b2b8fdd1
12 changed files with 122 additions and 195 deletions

View File

@@ -12,16 +12,31 @@ export default class LoginComponent extends React.Component {
super(props);
this.props = props;
this.state = {
email: "",
username: "",
password: "",
};
this.defaultState = Object.assign({}, this.state);
this.authStore = props.appstate.auth;
}
componentDidMount() {
}
login = () => {
const username = this.state.username;
const password = this.state.password;
const data = {
username: username,
password: password,
}
this.authStore.login(data).then(res => {
this.props.history.push(LINKS.DASHBOARD);
}).catch(err => {
alert(err.message);
});
};
render() {
return (
@@ -35,15 +50,17 @@ export default class LoginComponent extends React.Component {
<input
className={'usernameForm'}
placeholder="Username"
onChange={(e) => this.setState({username: e.target.value})}
/>
<input
className={'passwordForm'}
placeholder="Password"
onChange={(e) => this.setState({password: e.target.value})}
type="password"
/>
</div>
<button onClick={() => this.props.history.push(LINKS.DASHBOARD)} className={'buttonLogin'}>
<button onClick={() => this.login()} className={'buttonLogin'}>
Sign In
</button>
</div>