From b07156e231fe4bc997c3178889da6ec45b356b26 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 11 Sep 2018 11:03:54 +0200 Subject: [PATCH] Update now updates the right user --- client/src/components/UserUpdate.js | 32 ++++++++++++++++++++++------- client/src/queries/queries.js | 2 ++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/client/src/components/UserUpdate.js b/client/src/components/UserUpdate.js index 5e5dda9d6..45e85ef47 100644 --- a/client/src/components/UserUpdate.js +++ b/client/src/components/UserUpdate.js @@ -12,7 +12,7 @@ class UserUpdate extends Component { this.defaultValuesSet = false; this.state = { - id: '5b90fc33ae71ee3798b2317d', // TODO this Id is the one that should be available to all components after the validation that the user is authenticated. + id: '', firstName: '', middleName: '', lastName: '', @@ -132,12 +132,15 @@ console.log("component will UNmount"); componentDidUpdate () { console.log("component did update"); + console.log("state", this.state); if (this.defaultValuesSet === false) { let user = JSON.parse(localStorage.getItem("loggedInUser")); console.log("user", user); this.defaultValuesSet= true; - this.refs.firstName.value = user.alias; + this.refs.email.value = user.email; + this.refs.emailVerified.checked = user.emailVerified; + this.setState({id: user.id}); console.log("setting defaults"); } } @@ -164,25 +167,40 @@ console.log("render");
- this.setState({ middleName:e.target.value})}/> + this.setState({ middleName:e.target.value})}> +
- this.setState({ lastName:e.target.value})}/> + this.setState({ last_name:e.target.value})}> +
- this.setState({ email:e.target.value})}/> - + + +
- +
diff --git a/client/src/queries/queries.js b/client/src/queries/queries.js index 45b2c38ce..d8cbd08d7 100644 --- a/client/src/queries/queries.js +++ b/client/src/queries/queries.js @@ -42,6 +42,8 @@ query($authId: String){ firstName middleName lastName + email + emailVerified role { id }