feat: teacher's assignments full stack geimplementeerd
This commit is contained in:
		
							parent
							
								
									509dd6bfab
								
							
						
					
					
						commit
						c03669eda7
					
				
					 5 changed files with 49 additions and 0 deletions
				
			
		|  | @ -3,6 +3,7 @@ import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from | |||
| import type { QuestionsResponse } from "@/controllers/questions.ts"; | ||||
| import type { ClassesResponse } from "@/controllers/classes.ts"; | ||||
| import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; | ||||
| import type { AssignmentsResponse } from "./assignments"; | ||||
| 
 | ||||
| export interface TeachersResponse { | ||||
|     teachers: TeacherDTO[] | string[]; | ||||
|  | @ -36,6 +37,10 @@ export class TeacherController extends BaseController { | |||
|         return this.get<ClassesResponse>(`/${username}/classes`, { full }); | ||||
|     } | ||||
| 
 | ||||
|     async getAssignments(username: string, full = true): Promise<AssignmentsResponse> { | ||||
|         return this.get<AssignmentsResponse>(`/${username}/assignments`, { full }); | ||||
|     } | ||||
| 
 | ||||
|     async getStudents(username: string, full = false): Promise<StudentsResponse> { | ||||
|         return this.get<StudentsResponse>(`/${username}/students`, { full }); | ||||
|     } | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from | |||
| import type { QuestionsResponse } from "@/controllers/questions.ts"; | ||||
| import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; | ||||
| import { studentJoinRequestQueryKey, studentJoinRequestsQueryKey } from "@/queries/students.ts"; | ||||
| import type { AssignmentResponse, AssignmentsResponse } from "@/controllers/assignments"; | ||||
| 
 | ||||
| const teacherController = new TeacherController(); | ||||
| 
 | ||||
|  | @ -29,6 +30,10 @@ function teacherClassesQueryKey(username: string, full: boolean): [string, strin | |||
|     return ["teacher-classes", username, full]; | ||||
| } | ||||
| 
 | ||||
| function teacherAssignmentsQueryKey(username: string, full: boolean): [string, string, boolean] { | ||||
|     return ["teacher-assignments", username, full]; | ||||
| } | ||||
| 
 | ||||
| function teacherStudentsQueryKey(username: string, full: boolean): [string, string, boolean] { | ||||
|     return ["teacher-students", username, full]; | ||||
| } | ||||
|  | @ -69,6 +74,17 @@ export function useTeacherClassesQuery( | |||
|     }); | ||||
| } | ||||
| 
 | ||||
| export function useTeacherAssignmentsQuery( | ||||
|     username: MaybeRefOrGetter<string | undefined>, | ||||
|     full: MaybeRefOrGetter<boolean> = false, | ||||
| ): UseQueryReturnType<AssignmentsResponse, Error> { | ||||
|     return useQuery({ | ||||
|         queryKey: computed(() => teacherAssignmentsQueryKey(toValue(username)!, toValue(full))), | ||||
|         queryFn: async () => teacherController.getAssignments(toValue(username)!, toValue(full)), | ||||
|         enabled: () => Boolean(toValue(username)), | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| export function useTeacherStudentsQuery( | ||||
|     username: MaybeRefOrGetter<string | undefined>, | ||||
|     full: MaybeRefOrGetter<boolean> = false, | ||||
|  |  | |||
		Reference in a new issue
	
	 Adriaan Jacquet
						Adriaan Jacquet