TS Lint / ESLint (push) Successful in 1m0s
Python Lint CI / ty (push) Successful in 1m6s
Python Lint CI / ruff (push) Successful in 1m7s
Python Lint CI / ruff-format-check (push) Successful in 1m12s
TS Lint / Oxlint (push) Failing after 4m55s
TS Lint / TypeScript (push) Successful in 5m15s
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import type { RawTask, TaskCreateData, TaskUpdateData } from "@/types";
|
|
|
|
export async function getTasks(list: string): Promise<RawTask[]> {
|
|
const response = await fetch(`/api/lists/${list}/tasks`);
|
|
return await response.json();
|
|
}
|
|
|
|
export async function createTask(
|
|
list: string,
|
|
data: TaskCreateData,
|
|
): Promise<RawTask> {
|
|
const response = await fetch(`/api/lists/${list}/tasks`, {
|
|
method: "POST",
|
|
body: JSON.stringify({ ...data }),
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
return await response.json();
|
|
}
|
|
|
|
export async function updateTask(
|
|
taskId: string,
|
|
data: TaskUpdateData,
|
|
): Promise<RawTask> {
|
|
const response = await fetch(`/api/tasks/${taskId}`, {
|
|
method: "PUT",
|
|
body: JSON.stringify({ ...data }),
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
return await response.json();
|
|
}
|
|
|
|
export async function deleteTask(taskId: string): Promise<void> {
|
|
await fetch(`/api/tasks/${taskId}`, {
|
|
method: "DELETE",
|
|
});
|
|
}
|