add new projects and tasks via websocket only

This commit is contained in:
data 2019-10-05 16:18:27 +01:00
parent d128262c31
commit a53d397ac1
4 changed files with 2 additions and 6 deletions

View File

@ -49,7 +49,6 @@ const defaultState = {
tasks: [],
projects: [],
component: 'projects',
// TODO try to get rid of:
search: '',
newArticle: '',
newTask: '',

View File

@ -14,6 +14,7 @@ function Project(props) {
return (
<div>
<span className="btn btn-primary" onClick={() => props.navigate('projects')}>Back</span>
<h2>{project.name}</h2>
<Tasks filtered={filtered} completed={completed} {...props} />
</div>

View File

@ -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)

View File

@ -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)