feat(frontend): layout header + drawer + router (9 routes)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
29
frontend/src/stores/tasks.js
Normal file
29
frontend/src/stores/tasks.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { tasksApi } from '@/api/tasks';
|
||||
export const useTasksStore = defineStore('tasks', () => {
|
||||
const tasks = ref([]);
|
||||
const loading = ref(false);
|
||||
async function fetchAll(params) {
|
||||
loading.value = true;
|
||||
tasks.value = await tasksApi.list(params);
|
||||
loading.value = false;
|
||||
}
|
||||
async function create(t) {
|
||||
const created = await tasksApi.create(t);
|
||||
tasks.value.push(created);
|
||||
return created;
|
||||
}
|
||||
async function updateStatut(id, statut) {
|
||||
const t = tasks.value.find(t => t.id === id);
|
||||
if (!t)
|
||||
return;
|
||||
const updated = await tasksApi.update(id, { ...t, statut });
|
||||
Object.assign(t, updated);
|
||||
}
|
||||
async function remove(id) {
|
||||
await tasksApi.delete(id);
|
||||
tasks.value = tasks.value.filter(t => t.id !== id);
|
||||
}
|
||||
return { tasks, loading, fetchAll, create, updateStatut, remove };
|
||||
});
|
||||
Reference in New Issue
Block a user