Files
jardin/frontend/src/api/plantings.ts
gilles f29f90a16f 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>
2026-02-22 04:10:16 +01:00

32 lines
1.0 KiB
TypeScript

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