persist task store

This commit is contained in:
Julien Calixte
2023-04-09 10:33:05 +02:00
parent d0f638077a
commit eed7255173
2 changed files with 18 additions and 6 deletions

View File

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