This commit is contained in:
2026-02-17 03:53:59 +05:30
commit dcb19e0a2f
28 changed files with 2766 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
interface Todo {
title: string | undefined;
done: boolean | undefined;
id: number;
}
export const useTodoActions = () => {
const fetchTodos = () =>
$fetch<{ limit: number; todos: Array<Todo>; total: number }>("/api/todo", {
method: "POST",
body: { action: "get" },
});
const createTodo = (title: string) =>
$fetch("/api/todo", {
method: "POST",
body: { action: "create", data: { title } },
});
const deleteTodo = (id: number) =>
$fetch("/api/todo", {
method: "POST",
body: { action: "delete", data: { id } },
});
const toggleTodo = (todo: any) =>
$fetch("/api/todo", {
method: "POST",
body: { action: "toggle", data: todo },
});
return { fetchTodos, createTodo, deleteTodo, toggleTodo };
};

View File

@@ -0,0 +1,4 @@
export const useUser = () => {
const getUser = () => $fetch("/api/user");
return { getUser };
};