Files
tout-doux/resources/ts/api/tasks.ts
T
klemek 56a41989f0
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
fix: working tasks after first tests
2026-07-05 23:07:11 +02:00

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",
});
}