import React, { Component } from "react"; import axios from "axios"; import PropTypes from "prop-types"; // TODO: Fix font, so that it is roboto // TODO: Add a read-only '@' in the left side of the handle input // TODO: Add a cancel button, that takes the user back to their profile page // TODO: Sort imports // TODO: Add comments // Material-UI stuff import TextField from "@material-ui/core/TextField"; import Typography from "@material-ui/core/Typography"; import withStyles from "@material-ui/core/styles/withStyles"; import Grid from "@material-ui/core/Grid"; import Button from "@material-ui/core/Button"; import CircularProgress from '@material-ui/core/CircularProgress'; const styles = { form: { textAlign: "center" }, textField: { marginBottom: 40 }, pageTitle: { marginTop: 40, marginBottom: 40 }, button: { positon: 'relative', }, progress: { position: 'absolute', } }; export class edit extends Component { componentDidMount() { axios .get("/getProfileInfo") .then((res) => { this.setState({ firstName: res.data.firstName, lastName: res.data.lastName, email: res.data.email, handle: res.data.handle, bio: res.data.bio }); }) .catch((err) => { console.error(err); }); } constructor() { super(); this.state = { firstName: "", lastName: "", email: "", handle: "", bio: "", loading: false, errors: {} }; } handleSubmit = (event) => { event.preventDefault(); this.setState({ loading: true }); const newProfileData = { firstName: this.state.firstName, lastName: this.state.lastName, email: this.state.email, handle: this.state.handle, bio: this.state.bio }; axios .post("/updateProfileInfo", newProfileData) .then((res) => { this.setState({ loading: false }); // this.props.history.push('/'); // TODO: Need to redirect user to their profile page }) .catch((err) => { this.setState({ errors: err.response.data, loading: false }); }); }; handleChange = (event) => { this.setState({ [event.target.name]: event.target.value, errors: { [event.target.name]: null, } }); }; render() { const { classes } = this.props; const { errors, loading } = this.state; return ( Edit Profile
); } } edit.propTypes = { classes: PropTypes.object.isRequired }; export default withStyles(styles)(edit);