Tasks: print newly added tasks, fixed some bugs

This commit is contained in:
2023-12-31 02:39:01 +01:00
parent 4c9765b4a3
commit 5c769bfa2f
3 changed files with 46 additions and 6 deletions

View File

@@ -6,11 +6,11 @@ import TaskRecord from '@/components/TaskRecord.vue'
<template>
<main>
<TrackerTimer />
<TrackerTimer @get-tasks="getTasks" />
<div class="task-day-wrapper">
<TaskHeader />
<div class="task-wrapper" v-for="task in tasks" :key="task._id">
<div class="task-wrapper" v-for="task in sortedData" :key="task._id">
<TaskRecord :task="task" />
</div>
</div>
@@ -26,6 +26,17 @@ export default {
tasks: AppStore.data.fetchedTasks
}
},
methods: {
async getTasks() {
await AppStore.fetchData()
this.tasks = AppStore.data.fetchedTasks
}
},
computed: {
sortedData() {
return this.tasks.slice().sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
}
},
async mounted() {
await AppStore.fetchData()
this.tasks = AppStore.data.fetchedTasks