From 19eb55fd60b3229bd0d614add9f355112d2b9a6a Mon Sep 17 00:00:00 2001 From: notnull Date: Wed, 26 Jun 2019 07:42:30 -0400 Subject: [PATCH] don't allow createProject with empty name --- src/components/task-row.js | 4 +++- src/controllers/tasks.js | 18 ++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/components/task-row.js b/src/components/task-row.js index ddd5d31..32de14e 100644 --- a/src/components/task-row.js +++ b/src/components/task-row.js @@ -25,13 +25,15 @@ const TaskRow = props => { {props.component === 'project' ? ( '' - ) : ( + ) : task.projectId ? ( + ) : ( + '' )} ) diff --git a/src/controllers/tasks.js b/src/controllers/tasks.js index 0c1b4fb..4efb890 100644 --- a/src/controllers/tasks.js +++ b/src/controllers/tasks.js @@ -7,30 +7,16 @@ export async function createTask(e) { alert("Why don't you enter a name for this task?") return } - { - /*if (!this.state.selectedProjectId) { - alert('No project selected, silly!') - return - }*/ - } + const newTask = { desc: this.state.newTask, projectId: this.state.selectedProjectId, - // TODO - // the backend expects projectName because it creates the project on the fly if none exists with that name - // this feature comes at the price that there can't be two independent projects with the same name - // which could be handy if users want to have private projects } if (newTask.desc === '') { alert('Task description is empty.') return } - { - /*} else if (!newTask.projectName) { - alert('Select a project for new task.') - return - }*/ - } + try { console.log('Adding task: ', newTask) const { data, error } = await axios.post(API + '/api/tasks', newTask)