diff --git a/src/App.js b/src/App.js index bbebc9e..97b5441 100644 --- a/src/App.js +++ b/src/App.js @@ -42,6 +42,7 @@ class App extends React.Component { this.selectTask = this.selectTask.bind(this) this.updateTask = this.updateTask.bind(this) this.deleteProject = this.deleteProject.bind(this) + this.updateProfile = this.updateProfile.bind(this) } async fetchTasks() { @@ -261,6 +262,25 @@ class App extends React.Component { alert(`Failed to delete project '${project.name}': ${e}`) } } + async updateProfile(e) { + e.preventDefault() + const user = {} // TODO update properties from form + console.log(e.target) + try { + const { data, error } = await axios.put(api + `/api/user`, user) + console.log('Trying to update user profile: ', user) + if (error) { + alert('Received error when updating user profile: ', error) + } else if (data.desc && data.projectId) { + console.log('Successfully updated user profile:', data) + // TODO this.setState({ tasks: this.state.tasks.concat(data), newTask: '' }) + } else { + console.log('Received malformed data when updating user profile: ', data) + } + } catch (e) { + alert(`Updating user profile failed: ${e}`) + } + } renderLoading() { return