feat(intrants): frontend API clients + Pinia stores
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// frontend/src/api/achats.ts
|
||||
import client from './client'
|
||||
|
||||
export interface AchatIntrant {
|
||||
id?: number
|
||||
categorie: string // terreau | engrais | traitement | autre
|
||||
nom: string
|
||||
marque?: string
|
||||
boutique_nom?: string
|
||||
boutique_url?: string
|
||||
prix?: number
|
||||
poids?: string
|
||||
date_achat?: string
|
||||
dluo?: string
|
||||
notes?: string
|
||||
jardin_id?: number
|
||||
plantation_id?: number
|
||||
tache_id?: number
|
||||
}
|
||||
|
||||
export const achatsApi = {
|
||||
list: (params?: { categorie?: string; jardin_id?: number }) =>
|
||||
client.get<AchatIntrant[]>('/api/achats', { params }).then(r => r.data),
|
||||
get: (id: number) => client.get<AchatIntrant>(`/api/achats/${id}`).then(r => r.data),
|
||||
create: (a: Partial<AchatIntrant>) => client.post<AchatIntrant>('/api/achats', a).then(r => r.data),
|
||||
update: (id: number, a: Partial<AchatIntrant>) => client.put<AchatIntrant>(`/api/achats/${id}`, a).then(r => r.data),
|
||||
delete: (id: number) => client.delete(`/api/achats/${id}`),
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// frontend/src/api/fabrications.ts
|
||||
import client from './client'
|
||||
|
||||
export interface Ingredient {
|
||||
nom: string
|
||||
quantite: string
|
||||
}
|
||||
|
||||
export interface Fabrication {
|
||||
id?: number
|
||||
type: string // compost | decoction | purin | autre
|
||||
nom: string
|
||||
ingredients?: Ingredient[]
|
||||
date_debut?: string
|
||||
date_fin_prevue?: string
|
||||
statut?: string // en_cours | pret | utilise | echec
|
||||
quantite_produite?: string
|
||||
notes?: string
|
||||
jardin_id?: number
|
||||
plantation_id?: number
|
||||
tache_id?: number
|
||||
}
|
||||
|
||||
export const fabricationsApi = {
|
||||
list: (params?: { type?: string; statut?: string; jardin_id?: number }) =>
|
||||
client.get<Fabrication[]>('/api/fabrications', { params }).then(r => r.data),
|
||||
get: (id: number) => client.get<Fabrication>(`/api/fabrications/${id}`).then(r => r.data),
|
||||
create: (f: Partial<Fabrication>) => client.post<Fabrication>('/api/fabrications', f).then(r => r.data),
|
||||
update: (id: number, f: Partial<Fabrication>) => client.put<Fabrication>(`/api/fabrications/${id}`, f).then(r => r.data),
|
||||
updateStatut: (id: number, statut: string) => client.patch<Fabrication>(`/api/fabrications/${id}/statut`, { statut }).then(r => r.data),
|
||||
delete: (id: number) => client.delete(`/api/fabrications/${id}`),
|
||||
}
|
||||
Reference in New Issue
Block a user