import client from './client'

export interface Recolte {
  id?: number
  plantation_id?: number
  quantite: number
  unite: string  // kg|g|unites|litres|bottes
  date_recolte: string
  notes?: string
  created_at?: string
}

export const recoltesApi = {
  list: (plantingId: number) =>
    client.get<Recolte[]>(`/api/plantings/${plantingId}/recoltes`).then(r => r.data),

  create: (plantingId: number, data: Omit<Recolte, 'id' | 'plantation_id' | 'created_at'>) =>
    client.post<Recolte>(`/api/plantings/${plantingId}/recoltes`, data).then(r => r.data),

  delete: (id: number) => client.delete(`/api/recoltes/${id}`),
}
