feat: typescript requests
TS Lint / ESLint (push) Successful in 45s
Python Lint CI / ruff (push) Successful in 56s
Python Lint CI / ruff-format-check (push) Successful in 57s
Python Lint CI / ty (push) Successful in 1m4s
TS Lint / Oxlint (push) Successful in 6m39s
TS Lint / TypeScript (push) Successful in 6m31s
TS Lint / ESLint (push) Successful in 45s
Python Lint CI / ruff (push) Successful in 56s
Python Lint CI / ruff-format-check (push) Successful in 57s
Python Lint CI / ty (push) Successful in 1m4s
TS Lint / Oxlint (push) Successful in 6m39s
TS Lint / TypeScript (push) Successful in 6m31s
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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(
|
||||
list: string,
|
||||
taskId: string,
|
||||
data: TaskUpdateData,
|
||||
): Promise<RawTask> {
|
||||
const response = await fetch(`/api/lists/${list}/tasks/${taskId}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ data }),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export async function deleteTask(list: string, taskId: string): Promise<void> {
|
||||
await fetch(`/api/lists/${list}/tasks/${taskId}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
@@ -4,3 +4,28 @@ export interface Comment {
|
||||
updated_at: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface RawTask {
|
||||
id: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
list: string;
|
||||
name: string;
|
||||
reset_cron: string | null;
|
||||
check_date: string | null;
|
||||
previous_check_date: string | null;
|
||||
}
|
||||
|
||||
export interface TaskCreateData {
|
||||
name: string;
|
||||
reset_cron: string | null;
|
||||
check_date?: string | null;
|
||||
previous_check_date?: string | null;
|
||||
}
|
||||
|
||||
export interface TaskUpdateData {
|
||||
name?: string;
|
||||
reset_cron?: string | null;
|
||||
check_date?: string | null;
|
||||
previous_check_date?: string | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user