feat(frontend): API layer + stores Pinia

Ajoute le client Axios, les modules API (gardens, varieties, plantings,
tasks) et les stores Pinia correspondants. Corrige tsconfig.json pour
inclure vite/client et DOM.Iterable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-22 04:10:16 +01:00
parent b8edb6bc0a
commit f29f90a16f
10 changed files with 245 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { tasksApi, type Task } from '@/api/tasks'
export const useTasksStore = defineStore('tasks', () => {
const tasks = ref<Task[]>([])
const loading = ref(false)
async function fetchAll(params?: { statut?: string; garden_id?: number }) {
loading.value = true
tasks.value = await tasksApi.list(params)
loading.value = false
}
async function create(t: Partial<Task>) {
const created = await tasksApi.create(t)
tasks.value.push(created)
return created
}
async function updateStatut(id: number, statut: string) {
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: number) {
await tasksApi.delete(id)
tasks.value = tasks.value.filter(t => t.id !== id)
}
return { tasks, loading, fetchAll, create, updateStatut, remove }
})