From a53d397ac1bc78a5f4de62b556a3cd1510a969f2 Mon Sep 17 00:00:00 2001 From: data Date: Sat, 5 Oct 2019 16:18:27 +0100 Subject: [PATCH] add new projects and tasks via websocket only --- src/App.js | 1 - src/components/project.js | 1 + src/controllers/projects.js | 2 +- src/controllers/tasks.js | 4 ---- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index d62c5fe..b5be9c6 100644 --- a/src/App.js +++ b/src/App.js @@ -49,7 +49,6 @@ const defaultState = { tasks: [], projects: [], component: 'projects', - // TODO try to get rid of: search: '', newArticle: '', newTask: '', diff --git a/src/components/project.js b/src/components/project.js index 9f9e19e..dc1355d 100644 --- a/src/components/project.js +++ b/src/components/project.js @@ -14,6 +14,7 @@ function Project(props) { return (
+ props.navigate('projects')}>Back

{project.name}

diff --git a/src/controllers/projects.js b/src/controllers/projects.js index 0ee7692..6476975 100644 --- a/src/controllers/projects.js +++ b/src/controllers/projects.js @@ -14,7 +14,7 @@ export async function createProject(e) { alert(`Received error when creating project ${project.name}: ${error}`) } else if (data.id) { this.setState({ - projects: this.state.projects.concat(data), + // projects: this.state.projects.concat(data), newProject: '', }) console.log(`Added project: `, data) diff --git a/src/controllers/tasks.js b/src/controllers/tasks.js index 4efb890..d30bb9b 100644 --- a/src/controllers/tasks.js +++ b/src/controllers/tasks.js @@ -7,7 +7,6 @@ export async function createTask(e) { alert("Why don't you enter a name for this task?") return } - const newTask = { desc: this.state.newTask, projectId: this.state.selectedProjectId, @@ -16,7 +15,6 @@ export async function createTask(e) { alert('Task description is empty.') return } - try { console.log('Adding task: ', newTask) const { data, error } = await axios.post(API + '/api/tasks', newTask) @@ -47,8 +45,6 @@ export async function updateTask(e, updatedTask) { if (error) { alert('Received error when updating task: ', error) } else if (data.desc && data.projectId) { - const oldTasks = this.state.tasks.filter(t => t.id !== updatedTask.id) - this.setState({ tasks: oldTasks.concat(updatedTask) }) console.log('Successfully updated task:', data) } else { console.log('Received malformed data when updating task: ', data)