p5.js-web-editor/client/modules/User/pages/SignupView.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-06-24 00:29:55 +02:00
import React from 'react';
import { bindActionCreators } from 'redux';
import * as UserActions from '../actions';
import { reduxForm } from 'redux-form';
import SignupForm from '../components/SignupForm';
2016-06-25 00:18:22 +02:00
function SignupView(props) {
return (
<div className="signup">
<h1>Sign Up</h1>
<SignupForm {...props} />
</div>
);
2016-06-24 00:29:55 +02:00
}
function mapStateToProps(state) {
return {
user: state.user
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(UserActions, dispatch);
}
function validate(formProps) {
const errors = {};
2016-06-24 20:22:32 +02:00
if (!formProps.username) {
errors.username = 'Please enter a username';
}
if (!formProps.email) {
errors.email = 'Please enter an email';
}
if (!formProps.password) {
errors.password = 'Please enter a password';
}
if (!formProps.confirmPassword) {
errors.confirmPassword = 'Please enter a password confirmation';
}
2016-06-25 00:08:52 +02:00
if (formProps.password !== formProps.confirmPassword) {
2016-06-24 20:22:32 +02:00
errors.password = 'Passwords must match';
}
2016-06-25 00:08:52 +02:00
2016-06-24 00:29:55 +02:00
return errors;
}
// export default connect(mapStateToProps, mapDispatchToProps)(SignupView);
export default reduxForm({
form: 'signup',
2016-06-25 00:08:52 +02:00
fields: ['username', 'email', 'password', 'confirmPassword'],
2016-06-24 00:29:55 +02:00
validate
}, mapStateToProps, mapDispatchToProps)(SignupView);