diff --git a/Lab01/app/database/database.go b/Lab01/app/database/database.go index a9eb9ed..c6d3218 100644 --- a/Lab01/app/database/database.go +++ b/Lab01/app/database/database.go @@ -45,6 +45,10 @@ func (db *Database) CreateTask(username string, description string) Task { return task } +func (db *Database) DeleteTask(id string) { + db.ORM.Delete(&Task{}, id) +} + func (db *Database) CreateUser(username string, password string) error { user := User{Username: username, Password: password} result := db.ORM.Create(&user) diff --git a/Lab01/app/templates/tasks.tmpl b/Lab01/app/templates/tasks.tmpl index 89eb3df..7a1608a 100644 --- a/Lab01/app/templates/tasks.tmpl +++ b/Lab01/app/templates/tasks.tmpl @@ -48,6 +48,16 @@ }); } + function deleteTask(id) { + axios.delete("/tasks/" + id, axiosConfig) + .then((response) => { + console.log(response); + }) + .catch((err) => { + showErrorToast(err.response.data.message); + }); + } + function addTaskToTasks(task) { const newTask = document.createElement('div'); newTask.classList.add('row', 'g-0', 'align-items-center', 'mb-1'); @@ -57,7 +67,7 @@