diff --git a/twistter-frontend/src/App.js b/twistter-frontend/src/App.js index 9e29d2e..1ed56dc 100644 --- a/twistter-frontend/src/App.js +++ b/twistter-frontend/src/App.js @@ -74,7 +74,7 @@ class App extends Component { - + diff --git a/twistter-frontend/src/pages/editProfile.js b/twistter-frontend/src/pages/editProfile.js index d90b601..b4f7c2e 100644 --- a/twistter-frontend/src/pages/editProfile.js +++ b/twistter-frontend/src/pages/editProfile.js @@ -1,14 +1,14 @@ import React, { Component } from "react"; +import { Link } from 'react-router-dom'; import axios from "axios"; import PropTypes from "prop-types"; -// 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 // Material-UI stuff +import Box from "@material-ui/core/Box" import Button from "@material-ui/core/Button"; -import { Link } from 'react-router-dom'; import CircularProgress from "@material-ui/core/CircularProgress"; import Grid from "@material-ui/core/Grid"; +import Popover from "@material-ui/core/Popover"; import TextField from "@material-ui/core/TextField"; import Typography from "@material-ui/core/Typography"; import withStyles from "@material-ui/core/styles/withStyles"; @@ -38,14 +38,23 @@ const styles = { }, progress: { position: "absolute" + }, + popoverBackground: { + marginTop: "-100px", + width: "calc(100vw)", + height: 'calc(100vh + 100px)', + backgroundColor: "gray", + position: "absolute", + opacity: "70%" } }; -export class edit extends Component { +export class editProfile extends Component { // Runs as soon as the page loads. // Sets the default values of all the textboxes to the data // that is stored in the database for the user. componentDidMount() { + this.setState({pageLoading: true}) axios .get("/getProfileInfo") .then((res) => { @@ -54,16 +63,15 @@ export class edit extends Component { lastName: res.data.lastName, email: res.data.email, handle: res.data.handle, - bio: res.data.bio + bio: res.data.bio, + pageLoading: false }); }) .catch((err) => { console.error(err); if (err.response.status === 403) { - alert("You are not logged in"); - // TODO: Redirect them, to the profile they are trying to edit - // If they are on /itsjimmy/edit, they will be redirected to /itsjimmy - this.props.history.push('../'); + // This user is not logged in + this.props.history.push('/'); } }); } @@ -77,7 +85,9 @@ export class edit extends Component { email: "", handle: "", bio: "", + anchorEl: null, loading: false, + pageLoading: false, errors: {} }; } @@ -112,8 +122,7 @@ export class edit extends Component { this.setState({ loading: false }); - // this.props.history.push('/'); - // TODO: Need to redirect user to their profile page + this.props.history.push('/user'); }) .catch((err) => { console.log(err); @@ -137,142 +146,219 @@ export class edit extends Component { }); }; + handleOpenConfirmDelete = (event) => { + this.setState({ + // anchorEl: event.currentTarget + anchorEl: document.getElementById("container-grid") + }); + }; + + handleCloseConfirmDelete = () => { + this.setState({ + anchorEl: null, + createDMUsername: '' + }); + }; + render() { const { classes } = this.props; const { errors, loading } = this.state; + // Used for the delete button + const open = Boolean(this.state.anchorEl); + const id = open ? 'simple-popover' : undefined; + return ( - - - - - - - Edit Profile - -
- - - - - - - - - - - + this.state.pageLoading ? + + : + + - - + + + + Edit Profile + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + Are you sure you want to delete your account? + + + + + + + +
- - - -
); } } -edit.propTypes = { +editProfile.propTypes = { classes: PropTypes.object.isRequired }; -export default withStyles(styles)(edit); +export default withStyles(styles)(editProfile); diff --git a/twistter-frontend/src/pages/user.js b/twistter-frontend/src/pages/user.js index 97258b0..379cb56 100644 --- a/twistter-frontend/src/pages/user.js +++ b/twistter-frontend/src/pages/user.js @@ -248,7 +248,7 @@ class user extends Component { // showing the logged in users profile, instead of retreiving the // profile based on the URL entered let editButtonMarkup = true ? ( - +