- 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.
23 lines
573 B
TypeScript
23 lines
573 B
TypeScript
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() });
|
|
},
|
|
});
|
|
}
|