File size: 665 Bytes
714ed7b | 1 2 3 4 5 6 7 8 9 10 11 12 13 | import type { Comment, NewTask, Task, TaskPatch } from "../types";
import { api } from "./client";
export const tasksApi = {
list: (query = "") => api.get<Task[]>(query ? `/tasks?q=${encodeURIComponent(query)}` : "/tasks"),
get: (id: number) => api.get<Task>(`/tasks/${id}`),
create: (task: NewTask) => api.post<Task>("/tasks", task),
update: (id: number, patch: TaskPatch) => api.patch<Task>(`/tasks/${id}`, patch),
remove: (id: number) => api.del<{ ok: true }>(`/tasks/${id}`),
comments: (id: number) => api.get<Comment[]>(`/tasks/${id}/comments`),
addComment: (id: number, body: string) => api.post<Comment>(`/tasks/${id}/comments`, { body }),
};
|