diff --git a/public/icons/trash.svg b/public/icons/trash.svg new file mode 100644 index 0000000..889267a --- /dev/null +++ b/public/icons/trash.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/modules/task/stores/useTask.store.ts b/src/modules/task/stores/useTask.store.ts index 304099a..f98bd63 100644 --- a/src/modules/task/stores/useTask.store.ts +++ b/src/modules/task/stores/useTask.store.ts @@ -18,6 +18,9 @@ export const useTaskStore = defineStore('task-store', { }, reset() { this.tasks = [] + }, + remove(taskId: string) { + this.tasks = this.tasks.filter((task) => task.id !== taskId) } }, getters: { diff --git a/src/views/task/TaskView.vue b/src/views/task/TaskView.vue index 0f122e5..6d227fe 100644 --- a/src/views/task/TaskView.vue +++ b/src/views/task/TaskView.vue @@ -3,18 +3,32 @@ import EstimationTimeArrival from '@/components/EstimationTimeArrival.vue' import TaskRecordPreview from '@/modules/record/components/TaskRecordPreview.vue' import { useTaskStore } from '@/modules/task/stores/useTask.store' import { computed } from 'vue' +import { useRouter } from 'vue-router' const props = defineProps<{ id: string }>() +const router = useRouter() const taskStore = useTaskStore() const task = computed(() => taskStore.getTask(props.id)) + +const deleteTask = () => { + if (window.confirm('Are you sure to delete this task?')) { + taskStore.remove(props.id) + router.push({ + name: 'home' + }) + } +}