From 49a4d55f1e808c1857b93dc0ff844f9ff5bead16 Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Tue, 3 Dec 2019 14:04:40 -0500 Subject: [PATCH 1/5] Rename edit class to editProfile to be more descriptive --- twistter-frontend/src/pages/editProfile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/twistter-frontend/src/pages/editProfile.js b/twistter-frontend/src/pages/editProfile.js index d90b601..703fa67 100644 --- a/twistter-frontend/src/pages/editProfile.js +++ b/twistter-frontend/src/pages/editProfile.js @@ -41,7 +41,7 @@ const styles = { } }; -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. @@ -271,8 +271,8 @@ export class edit extends Component { } } -edit.propTypes = { +editProfile.propTypes = { classes: PropTypes.object.isRequired }; -export default withStyles(styles)(edit); +export default withStyles(styles)(editProfile); From 825c126c6c12df2d75a0d302704777fd97f53598 Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Tue, 3 Dec 2019 16:26:16 -0500 Subject: [PATCH 2/5] Delete asks you to confirm --- twistter-frontend/src/pages/editProfile.js | 107 ++++++++++++++++++--- 1 file changed, 96 insertions(+), 11 deletions(-) diff --git a/twistter-frontend/src/pages/editProfile.js b/twistter-frontend/src/pages/editProfile.js index 703fa67..539fc8b 100644 --- a/twistter-frontend/src/pages/editProfile.js +++ b/twistter-frontend/src/pages/editProfile.js @@ -1,14 +1,16 @@ 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,6 +40,14 @@ const styles = { }, progress: { position: "absolute" + }, + popoverBackground: { + marginTop: "-100px", + width: "calc(100vw)", + height: 'calc(100vh + 100px)', + backgroundColor: "gray", + position: "absolute", + opacity: "70%" } }; @@ -77,6 +87,7 @@ export class editProfile extends Component { email: "", handle: "", bio: "", + anchorEl: null, loading: false, errors: {} }; @@ -137,12 +148,30 @@ export class editProfile 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 ( - + + + + + + + + Are you sure you want to delete your account? + + + + + + + + ); } From a4cce0b75ec3a616641ecf8b073b52b7d69c2b58 Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Tue, 3 Dec 2019 16:26:54 -0500 Subject: [PATCH 3/5] Circular progress when the editProfile page is loading --- twistter-frontend/src/pages/editProfile.js | 354 +++++++++++---------- 1 file changed, 180 insertions(+), 174 deletions(-) diff --git a/twistter-frontend/src/pages/editProfile.js b/twistter-frontend/src/pages/editProfile.js index 539fc8b..df947fb 100644 --- a/twistter-frontend/src/pages/editProfile.js +++ b/twistter-frontend/src/pages/editProfile.js @@ -56,6 +56,7 @@ export class editProfile extends Component { // 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) => { @@ -64,7 +65,8 @@ export class editProfile 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) => { @@ -89,6 +91,7 @@ export class editProfile extends Component { bio: "", anchorEl: null, loading: false, + pageLoading: false, errors: {} }; } @@ -171,187 +174,190 @@ export class editProfile extends Component { const id = open ? 'simple-popover' : undefined; return ( - - - - - - - Edit Profile - -
- - - - - - - - - - - + this.state.pageLoading ? + + : + + - - - - - - - - - + + + Edit Profile + +
+ + + + + + + + + + + + + + +
+ + + + + - - - Are you sure you want to delete your account? + + + + Are you sure you want to delete your account? + + + + + - - - - - -
-
-
+ + +
); } } From 5b5e78514244f539f2279f22590e6d20bb846c20 Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Tue, 3 Dec 2019 16:37:04 -0500 Subject: [PATCH 4/5] Changed the path of the editProfile page --- twistter-frontend/src/App.js | 2 +- twistter-frontend/src/pages/editProfile.js | 10 +++------- twistter-frontend/src/pages/user.js | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) 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 df947fb..fae7f27 100644 --- a/twistter-frontend/src/pages/editProfile.js +++ b/twistter-frontend/src/pages/editProfile.js @@ -3,7 +3,6 @@ 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" @@ -72,10 +71,8 @@ export class editProfile extends Component { .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('/'); } }); } @@ -126,8 +123,7 @@ export class editProfile 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); 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 ? ( - + From 2d426840c0d86bd3b57f24e04eb7dfead76c8126 Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Tue, 3 Dec 2019 16:37:57 -0500 Subject: [PATCH 5/5] Add @ next to handle on editProfile --- twistter-frontend/src/pages/editProfile.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/twistter-frontend/src/pages/editProfile.js b/twistter-frontend/src/pages/editProfile.js index fae7f27..b4f7c2e 100644 --- a/twistter-frontend/src/pages/editProfile.js +++ b/twistter-frontend/src/pages/editProfile.js @@ -2,7 +2,6 @@ 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 // Material-UI stuff import Box from "@material-ui/core/Box" @@ -243,7 +242,7 @@ export class editProfile extends Component { name="handle" label="Handle*" className={classes.textField} - value={this.state.handle} + value={"@" + this.state.handle} disabled helperText="(disabled)" // INFO: These will be uncommented if changing usernames is allowed