import React from 'react'; import {withRouter} from 'react-router-dom'; class SignupForm extends React.Component { constructor(props) { super(props); this.state = { email: "", password: "", fname: "", lname: "", birthday: "", sex: "", }; this.err = { email_error:"", password_error:"", fname_error:"", lname_error:"", birthday_error:"", sex_error:"" }; this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit(e) { e.preventDefault(); const user = Object.assign({}, this.state); this.props.processForm(user); } update(field) { return (e) => { this.setState({[field]: e.target.value}); }; } updateSex(value){ return(e)=>{ this.setState({sex:value}); }; } renderErrors(){ const {errors} = this.props; errors.signupErrors.forEach((error) => { if (error === "Email can't be blank"){ this.err.email_error = "You'll use this when you log in and if you ever need to reset your password."; }else if(error === "Fname can't be blank"){ this.err.fname_error = "Whats your name?"; }else if(error === "Lname can't be blank"){ this.err.lname_error ="Whats your name?"; }else if(error === "Birthday can't be blank"){ this.err.birthday_error ="Select your birthday. You can change who can see this later."; }else if(error === "Password is too short (minimum is 6 characters)"){ this.err.password_error = "Enter a combination of at least six numbers, letters and punctuation marks (like ! and &)."; } }); } renderSmallErrors(variable){ console.log(variable); if (variable){ return({variable}); }else { return(null); } } renderSignup(){ const {formType} = this.props; if (formType === "SIGNUP"){ return(