mirasim's picture
Add the tasks, judges, harness, app under test, docs and report; merge the repository README into the card (part 4)
714ed7b verified
Raw History Blame Contribute Delete
665 Bytes
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 }),
};