Grégoire Delattre 9ba4af9d7d Split actions to separate file
Only use the necessary actions for each component
2017-05-23 22:07:19 +02:00

57 lines
1.8 KiB
JavaScript

import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { userSignUp } from '../../actions/users'
const mapDispatchToProps = (dispatch) =>
bindActionCreators({ userSignUp }, dispatch)
class UserSignUp extends React.Component {
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(e) {
e.preventDefault();
this.props.userSignUp({
'username': this.refs.username.value,
'password': this.refs.password.value,
'password_confirm': this.refs.passwordConfirm.value,
});
}
render() {
return (
<div className="container">
<div className="content-fluid">
<div className="col-md-6 col-md-offset-3 col-xs-12">
<h2>Sign up</h2>
<hr />
<form ref="userSignUpForm" className="form-horizontal" onSubmit={(e) => this.handleSubmit(e)}>
<div className="form-group">
<label className="control-label">Username</label>
<input autoFocus="autofocus" className="form-control" type="text" ref="username" />
</div>
<div className="form-group">
<label className="control-label">Password</label>
<input className="form-control" ref="password" type="password" />
</div>
<div className="form-group">
<label className="control-label">Password confirm</label>
<input className="form-control" ref="passwordConfirm" type="password" />
</div>
<div>
<input className="btn btn-primary pull-right" type="submit" value="Sign up"/>
</div>
</form>
</div>
</div>
</div>
);
}
}
export default connect(null, mapDispatchToProps)(UserSignUp);