feat(frontend): eerste queries voor assignments

This commit is contained in:
Joyelle Ndagijimana 2025-04-11 13:01:58 +02:00
parent ce5e9cd342
commit 45cb020861
10 changed files with 560 additions and 218 deletions

View file

@ -1,22 +0,0 @@
import {useQuery, type UseQueryReturnType} from "@tanstack/vue-query";
import {computed, type MaybeRefOrGetter, toValue} from "vue";
import type {StudentsResponse} from "@/controllers/students.ts";
import {getClassController} from "@/controllers/controllers.ts";
const classController = getClassController();
function classStudentsQueryKey(classId: string, full: boolean): [string, string, boolean] {
return ["class-students", classId, full];
}
export function useClassStudentsQuery(
classId: MaybeRefOrGetter<string | undefined>,
full: MaybeRefOrGetter<boolean> = true,
): UseQueryReturnType<StudentsResponse, Error> {
return useQuery({
queryKey: computed(() => classStudentsQueryKey(toValue(classId)!, toValue(full))),
queryFn: async () => classController.getStudents(toValue(classId)!, toValue(full)),
enabled: () => Boolean(toValue(classId)),
});
}