persist task store
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { Taskable } from '../interfaces/taskable'
|
||||
|
||||
interface StoredTaskable extends Omit<Taskable, 'date'> {
|
||||
date: string
|
||||
}
|
||||
|
||||
export interface TaskStoreState {
|
||||
tasks: Taskable[]
|
||||
tasks: StoredTaskable[]
|
||||
}
|
||||
|
||||
export const useTaskStore = defineStore('task-store', {
|
||||
@@ -11,7 +15,15 @@ export const useTaskStore = defineStore('task-store', {
|
||||
}),
|
||||
actions: {
|
||||
saveTask(task: Taskable) {
|
||||
this.tasks.push(task)
|
||||
this.tasks.push({
|
||||
...task,
|
||||
totalEstimation: task.totalEstimation,
|
||||
date: task.date.toISOString()
|
||||
})
|
||||
},
|
||||
reset() {
|
||||
this.tasks = []
|
||||
}
|
||||
}
|
||||
},
|
||||
persist: true
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user