2016-06-09 02:52:59 +02:00
|
|
|
import React from 'react'
|
2016-06-09 22:28:21 +02:00
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import * as UserActions from '../../redux/actions/user'
|
|
|
|
import { reduxForm } from 'redux-form'
|
2016-06-09 02:52:59 +02:00
|
|
|
|
|
|
|
class SignupView extends React.Component {
|
|
|
|
render() {
|
2016-06-09 22:28:21 +02:00
|
|
|
const {fields: { username, email, password, confirmPassword }, handleSubmit} = this.props;
|
2016-06-09 02:52:59 +02:00
|
|
|
return (
|
2016-06-09 22:28:21 +02:00
|
|
|
<form onSubmit={handleSubmit(this.props.signUpUser.bind(this))}>
|
|
|
|
<input type="text" placeholder="Username" {...username}/>
|
|
|
|
<input type="text" placeholder="Email" {...email}/>
|
|
|
|
<input type="password" placeholder="Password" {...password}/>
|
|
|
|
<input type="password" placeholder="Confirm Password" {...confirmPassword}/>
|
2016-06-09 02:52:59 +02:00
|
|
|
<input type="submit" value="Sign Up" />
|
|
|
|
</form>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-09 22:28:21 +02:00
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
user: state.user
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return bindActionCreators(UserActions, dispatch);
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate(formProps) {
|
|
|
|
const errors = {};
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
// export default connect(mapStateToProps, mapDispatchToProps)(SignupView);
|
|
|
|
export default reduxForm({
|
|
|
|
form: 'signup',
|
|
|
|
fields: ['username', 'email', 'password', 'passwordConfirm'],
|
|
|
|
validate
|
|
|
|
}, mapStateToProps, mapDispatchToProps)(SignupView);
|