import client from './client'

export interface Task {
  id?: number
  titre: string
  description?: string
  garden_id?: number
  priorite: string
  echeance?: string
  statut: string
}

export const tasksApi = {
  list: (params?: { statut?: string; garden_id?: number }) =>
    client.get<Task[]>('/api/tasks', { params }).then(r => r.data),
  get: (id: number) => client.get<Task>(`/api/tasks/${id}`).then(r => r.data),
  create: (t: Partial<Task>) => client.post<Task>('/api/tasks', t).then(r => r.data),
  update: (id: number, t: Partial<Task>) => client.put<Task>(`/api/tasks/${id}`, t).then(r => r.data),
  delete: (id: number) => client.delete(`/api/tasks/${id}`),
}
