import React, { Component } from 'react';
import { reduxForm } from 'redux-form';
import * as actions from '../../actions';

class Signup extends Component {
  render() {
    const { handleSubmit, fields: { email, password, passwordConfirm } } = this.props;
    return (
      <form>
        <fieldset className="form-group">
          <label>Email:</label>
          <input className="form-control" {...email} />
        </fieldset>
        <fieldset className="form-group">
          <label>Password:</label>
          <input className="form-control" {...password} type="password" />
        </fieldset>
        <fieldset className="form-group">
          <label>Confirm Password:</label>
          <input className="form-control" {...passwordConfirm} type="password" />
        </fieldset>
        <button action="submit" className="btn btn-primary">Sign Up!</button>
      </form>
    );
  }
}


export default reduxForm({
  form: 'signup',
  fields: ['email', 'password', 'passwordConfirm']
})(Signup);


@@ -403,24 +403,111 @@
 ..email%7D /%3E%0A
+          %7Bemail.touched && email.error && %3Cdiv className=%22error%22%3E%7Bemail.error%7D%3C/div%3E%7D%0A
         %3C/fi
@@ -658,32 +658,128 @@
 e=%22password%22 /%3E%0A
+          %7Bpassword.touched && password.error && %3Cdiv className=%22error%22%3E%7Bpassword.error%7D%3C/div%3E%7D%0A
         %3C/fields
@@ -941,32 +941,149 @@
 e=%22password%22 /%3E%0A
+          %7BpasswordConfirm.touched && passwordConfirm.error && %3Cdiv className=%22error%22%3E%7BpasswordConfirm.error%7D%3C/div%3E%7D%0A
         %3C/fields
@@ -1192,16 +1192,492 @@
 %0A  %7D%0A%7D%0A%0A
+function validate(formProps) %7B%0A  const errors = %7B%7D;%0A%0A  if (!formProps.email) %7B%0A    errors.email = 'Please enter an email';%0A  %7D%0A%0A  if (!formProps.password) %7B%0A    errors.password = 'Please enter a password';%0A  %7D%0A%0A  if (!formProps.passwordConfirm) %7B%0A    errors.passwordConfirm = 'Please enter password confirmation';%0A  %7D  %0A%0A  if (formProps.password !== formProps.passwordConfirm) %7B%0A    errors.password = 'Passwords must match';%0A  %7D%0A%0A  console.log(formProps);%0A%0A  return errors;%0A%7D%0A
 %0Aexport 
@@ -1764,16 +1764,29 @@
 onfirm'%5D
+, %0A  validate
 %0A%7D)(Sign

handle signin form validation