feat(frontend): eerste queries voor assignments
This commit is contained in:
parent
ce5e9cd342
commit
45cb020861
10 changed files with 560 additions and 218 deletions
22
frontend/src/queries/classes-temp.ts
Normal file
22
frontend/src/queries/classes-temp.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import {getClassController} from "@/controllers/controllers.ts";
|
||||
import {computed, type MaybeRefOrGetter, toValue} from "vue";
|
||||
import {useQuery, type UseQueryReturnType} from "@tanstack/vue-query";
|
||||
import type {StudentsResponse} from "@/controllers/students.ts";
|
||||
|
||||
const classController = getClassController();
|
||||
|
||||
function classStudentsQueryKey(classId: string, full: boolean): [string, string, boolean] {
|
||||
return ["class-students", classId, full];
|
||||
}
|
||||
|
||||
//TODO: delete and use the one in classes.ts
|
||||
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)),
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue