feat: add subjects and tasks API, hooks, and related types
- Implemented subjects API with functions for creating, updating, and retrieving subjects, including history and bibliography. - Added tasks API for managing user tasks, including listing and marking tasks as completed. - Created hooks for managing AI interactions, authentication, subjects, tasks, and metadata queries. - Established query keys for caching and managing query states. - Introduced Supabase client and environment variable management for better configuration. - Defined types for database and domain models to ensure type safety across the application.
This commit is contained in:
22
src/data/hooks/useTasks.ts
Normal file
22
src/data/hooks/useTasks.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { qk } from "../query/keys";
|
||||
import { tareas_marcar_completada, tareas_mias_list } from "../api/tasks.api";
|
||||
|
||||
export function useMisTareas() {
|
||||
return useQuery({
|
||||
queryKey: qk.tareas(),
|
||||
queryFn: tareas_mias_list,
|
||||
staleTime: 15_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useMarcarTareaCompletada() {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: tareas_marcar_completada,
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: qk.tareas() });
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user