Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @connect((store) => ({
- errors: store.adminLogin.error
- })
- class Login extends React.Component {
- constructor(props){
- super(props)
- this.state = {
- user:{
- email:'',
- password:''
- },
- };
- this.home = this.home.bind(this);
- this.onChange = this.onChange.bind(this);
- this.processForm = this.processForm.bind(this);
- }
- home(){
- this.props.history.push('/')
- }
- onChange(e){
- const user = this.state.user;
- const name = e.target.name;
- user[name] = e.target.value;
- this.setState({ user });
- }
- processForm(event) {
- event.preventDefault();
- // create a string for an HTTP body message
- const email = encodeURIComponent(this.state.user.email);
- const password = encodeURIComponent(this.state.user.password);
- const formData = `email=${email}&password=${password}`;
- this.props.dispatch(postLogin(formData));
- }
- render() {
- return (
- <LoginCompo
- onSubmit={this.processForm}
- home={this.home}
- user={this.state.user}
- onChange={this.onChange}
- errors={this.props.errors}
- />
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement