import client from './client'

export interface Tool {
  id?: number
  nom: string
  description?: string
  categorie?: string
  photo_url?: string
}

export const toolsApi = {
  list: () => client.get<Tool[]>('/api/tools').then(r => r.data),
  get: (id: number) => client.get<Tool>(`/api/tools/${id}`).then(r => r.data),
  create: (t: Partial<Tool>) => client.post<Tool>('/api/tools', t).then(r => r.data),
  update: (id: number, t: Partial<Tool>) => client.put<Tool>(`/api/tools/${id}`, t).then(r => r.data),
  delete: (id: number) => client.delete(`/api/tools/${id}`),
}
