diff options
author | Renard | 2019-09-23 12:33:09 -0300 |
---|---|---|
committer | Renard | 2019-09-23 12:33:09 -0300 |
commit | 629557fcc8b2561e77c1b9e53f79aabe814fd9c7 (patch) | |
tree | 96fd5ab6b56fde6a4d7f9277df6c35a974e1665d | |
parent | d700a5f9202e5771b51e3d83a2287a3e58e1f1b3 (diff) | |
download | bai-client-629557fcc8b2561e77c1b9e53f79aabe814fd9c7.tar.gz bai-client-629557fcc8b2561e77c1b9e53f79aabe814fd9c7.tar.xz bai-client-629557fcc8b2561e77c1b9e53f79aabe814fd9c7.zip |
Datos de usuario persistentes
-rw-r--r-- | src/ReplyForm.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ReplyForm.js b/src/ReplyForm.js index 9220501..8c942e7 100644 --- a/src/ReplyForm.js +++ b/src/ReplyForm.js @@ -22,6 +22,13 @@ class ReplyForm extends Component { this.handleSubmit = this.handleSubmit.bind(this); } + componentWillMount() { + let userData = JSON.parse(localStorage.getItem("userData")); + if (userData != null) { + this.setState({ name: userData.name, email: userData.email }); + } + } + handleChange(e) { const { name, value } = e.target; this.setState({ [name]: value }); @@ -48,6 +55,9 @@ class ReplyForm extends Component { password: "bai-client" }; + let userData = { name: name, email: email }; + localStorage.setItem("userData", JSON.stringify(userData)); + const formData = new FormData(); for (var key in data) { formData.append(key, data[key]); @@ -63,7 +73,7 @@ class ReplyForm extends Component { return response.json(); }) .then(resource => { - this.setState({ replyRes: resource }); + this.setState({ replyRes: resource, message: "" }); }); } ); |