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:
31
frontend/src/api/plantings.ts
Normal file
31
frontend/src/api/plantings.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import client from './client'
|
||||
|
||||
export interface Planting {
|
||||
id?: number
|
||||
garden_id: number
|
||||
variety_id: number
|
||||
cell_id?: number
|
||||
date_plantation?: string
|
||||
quantite: number
|
||||
statut: string
|
||||
notes?: string
|
||||
}
|
||||
|
||||
export interface PlantingEvent {
|
||||
id?: number
|
||||
planting_id?: number
|
||||
type: string
|
||||
note?: string
|
||||
ts?: string
|
||||
}
|
||||
|
||||
export const plantingsApi = {
|
||||
list: () => client.get<Planting[]>('/api/plantings').then(r => r.data),
|
||||
get: (id: number) => client.get<Planting>(`/api/plantings/${id}`).then(r => r.data),
|
||||
create: (p: Partial<Planting>) => client.post<Planting>('/api/plantings', p).then(r => r.data),
|
||||
update: (id: number, p: Partial<Planting>) => client.put<Planting>(`/api/plantings/${id}`, p).then(r => r.data),
|
||||
delete: (id: number) => client.delete(`/api/plantings/${id}`),
|
||||
events: (id: number) => client.get<PlantingEvent[]>(`/api/plantings/${id}/events`).then(r => r.data),
|
||||
addEvent: (id: number, e: Partial<PlantingEvent>) =>
|
||||
client.post<PlantingEvent>(`/api/plantings/${id}/events`, e).then(r => r.data),
|
||||
}
|
||||
Reference in New Issue
Block a user