/* eslint-disable */ import React, { Component } from 'react'; // import '../App.css'; import PropTypes from 'prop-types'; import logo from '../images/twistter-logo.png'; // Material-UI stuff import Button from "@material-ui/core/Button"; import CircularProgress from "@material-ui/core/CircularProgress"; import Grid from "@material-ui/core/Grid"; import TextField from "@material-ui/core/TextField"; import Typography from "@material-ui/core/Typography"; import withStyles from "@material-ui/core/styles/withStyles"; // Redux stuff import { connect } from 'react-redux'; import { signupUser } from '../redux/actions/userActions'; import { border } from '@material-ui/system'; const styles = { form: { textAlign: "center" }, textField: { marginBottom: 20, //border: "1px solid #234", display: "inline-block", boxSizing: "border-box", }, pageTitle: { marginBottom: 40 }, button: { positon: "relative", marginBottom: 30 }, progress: { position: "absolute" }, div: { borderRadius: "5px", backgroundColor: "grey", padding: "20px", }, p: { fontFamily: "Segoe UI", } }; export class Signup extends Component { // Constructor for the state constructor() { super(); this.state = { handle: "", email: "", password:"", confirmPassword: "", errors: {} }; } componentWillReceiveProps(nextProps) { if (nextProps.UI.errors) { this.setState({ errors: nextProps.UI.errors }); } } // Runs whenever the submit button is clicked. // Updates the database entry of the signed in user with the // data stored in the state. handleSubmit = (event) => { event.preventDefault(); const signupData = { handle: this.state.handle, email: this.state.email, password: this.state.password, confirmPassword: this.state.confirmPassword }; console.log(signupData) this.props.signupUser(signupData, this.props.history); }; // Updates the state whenever one of the textboxes changes. // The key is the name of the textbox and the value is the // value in the text box. handleChange = (event) => { this.setState({ [event.target.name]: event.target.value, errors: { [event.target.name]: null } }); }; render() { const { classes, UI: { loading } } = this.props; const { errors } = this.state; return ( logo



Create a new account







{errors.general && ( Invalid username/email or password )}
); } } // Proptypes just confirms that all data in it exists and is of the type that it // is declared to be Signup.propTypes = { classes: PropTypes.object.isRequired, signupUser: PropTypes.func.isRequired, user: PropTypes.object.isRequired, UI: PropTypes.object.isRequired }; const mapStateToProps = (state) => ({ user: state.user, UI: state.UI, }); const mapActionsToProps = { signupUser } Signup.propTypes = { classes: PropTypes.object.isRequired }; // This mapStateToProps is just synchronizing the 'state' to 'this.props' so we can access it // The state contains info about the current logged in user export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Signup));