don't allow createProject with empty name

This commit is contained in:
notnull 2019-06-26 07:42:30 -04:00
parent 278be8c120
commit 19eb55fd60
2 changed files with 5 additions and 17 deletions

View File

@ -25,13 +25,15 @@ const TaskRow = props => {
</button> </button>
{props.component === 'project' ? ( {props.component === 'project' ? (
'' ''
) : ( ) : task.projectId ? (
<button <button
className="btn ml-3 mr-2 float-right" className="btn ml-3 mr-2 float-right"
onClick={() => props.selectProject(task.projectId)} onClick={() => props.selectProject(task.projectId)}
> >
{project.name} {project.name}
</button> </button>
) : (
''
)} )}
</li> </li>
) )

View File

@ -7,30 +7,16 @@ export async function createTask(e) {
alert("Why don't you enter a name for this task?") alert("Why don't you enter a name for this task?")
return return
} }
{
/*if (!this.state.selectedProjectId) {
alert('No project selected, silly!')
return
}*/
}
const newTask = { const newTask = {
desc: this.state.newTask, desc: this.state.newTask,
projectId: this.state.selectedProjectId, 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 === '') { if (newTask.desc === '') {
alert('Task description is empty.') alert('Task description is empty.')
return return
} }
{
/*} else if (!newTask.projectName) {
alert('Select a project for new task.')
return
}*/
}
try { try {
console.log('Adding task: ', newTask) console.log('Adding task: ', newTask)
const { data, error } = await axios.post(API + '/api/tasks', newTask) const { data, error } = await axios.post(API + '/api/tasks', newTask)