fix: teacher class join request query key
This commit is contained in:
		
							parent
							
								
									43d76d796b
								
							
						
					
					
						commit
						59f6d63377
					
				
					 2 changed files with 9 additions and 1 deletions
				
			
		|  | @ -20,6 +20,7 @@ import type { GroupsResponse } from "@/controllers/groups.ts"; | |||
| import type { SubmissionsResponse } from "@/controllers/submissions.ts"; | ||||
| import type { QuestionsResponse } from "@/controllers/questions.ts"; | ||||
| import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; | ||||
| import {teacherClassJoinRequests} from "@/queries/teachers.ts"; | ||||
| 
 | ||||
| const studentController = new StudentController(); | ||||
| 
 | ||||
|  | @ -181,6 +182,7 @@ export function useCreateJoinRequestMutation(): UseMutationReturnType< | |||
|             await queryClient.invalidateQueries({ | ||||
|                 queryKey: studentJoinRequestsQueryKey(newJoinRequest.request.requester.username), | ||||
|             }); | ||||
|             await queryClient.invalidateQueries({ queryKey: teacherClassJoinRequests(classId) }); | ||||
|         }, | ||||
|     }); | ||||
| } | ||||
|  | @ -200,6 +202,7 @@ export function useDeleteJoinRequestMutation(): UseMutationReturnType< | |||
|             const classId = deletedJoinRequest.request.class; | ||||
|             await queryClient.invalidateQueries({ queryKey: studentJoinRequestsQueryKey(username) }); | ||||
|             await queryClient.invalidateQueries({ queryKey: studentJoinRequestQueryKey(username, classId) }); | ||||
|             await queryClient.invalidateQueries({ queryKey: teacherClassJoinRequests(classId) }); | ||||
|         }, | ||||
|     }); | ||||
| } | ||||
|  |  | |||
|  | @ -37,6 +37,10 @@ function teacherQuestionsQueryKey(username: string, full: boolean): [string, str | |||
|     return ["teacher-questions", username, full]; | ||||
| } | ||||
| 
 | ||||
| export function teacherClassJoinRequests(classId: string): [string, string] { | ||||
|     return ["teacher-class-join-requests", classId]; | ||||
| } | ||||
| 
 | ||||
| export function useTeachersQuery(full: MaybeRefOrGetter<boolean> = false): UseQueryReturnType<TeachersResponse, Error> { | ||||
|     return useQuery({ | ||||
|         queryKey: computed(() => teachersQueryKey(toValue(full))), | ||||
|  | @ -92,7 +96,7 @@ export function useTeacherJoinRequestsQuery( | |||
|     classId: MaybeRefOrGetter<string | undefined>, | ||||
| ): UseQueryReturnType<JoinRequestsResponse, Error> { | ||||
|     return useQuery({ | ||||
|         queryKey: computed(() => JOIN_REQUESTS_QUERY_KEY(toValue(username)!, toValue(classId)!)), | ||||
|         queryKey: computed(() => teacherClassJoinRequests(toValue(classId)!)), | ||||
|         queryFn: async () => teacherController.getStudentJoinRequests(toValue(username)!, toValue(classId)!), | ||||
|         enabled: () => Boolean(toValue(username)) && Boolean(toValue(classId)), | ||||
|     }); | ||||
|  | @ -137,6 +141,7 @@ export function useUpdateJoinRequestMutation(): UseMutationReturnType< | |||
|             const classId = deletedJoinRequest.request.class; | ||||
|             await queryClient.invalidateQueries({ queryKey: studentJoinRequestsQueryKey(username) }); | ||||
|             await queryClient.invalidateQueries({ queryKey: studentJoinRequestQueryKey(username, classId) }); | ||||
|             await queryClient.invalidateQueries({ queryKey: teacherClassJoinRequests(classId) }); | ||||
|         }, | ||||
|     }); | ||||
| } | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl