import type { Comment, NewTask, Task, TaskPatch } from "../types"; import { api } from "./client"; export const tasksApi = { list: (query = "") => api.get(query ? `/tasks?q=${encodeURIComponent(query)}` : "/tasks"), get: (id: number) => api.get(`/tasks/${id}`), create: (task: NewTask) => api.post("/tasks", task), update: (id: number, patch: TaskPatch) => api.patch(`/tasks/${id}`, patch), remove: (id: number) => api.del<{ ok: true }>(`/tasks/${id}`), comments: (id: number) => api.get(`/tasks/${id}/comments`), addComment: (id: number, body: string) => api.post(`/tasks/${id}/comments`, { body }), };