feat: verwijderen student uit klas
This commit is contained in:
		
							parent
							
								
									de5248fd70
								
							
						
					
					
						commit
						25bf592eca
					
				
					 1 changed files with 14 additions and 7 deletions
				
			
		|  | @ -10,7 +10,8 @@ | ||||||
|     import UsingQueryResult from "@/components/UsingQueryResult.vue"; |     import UsingQueryResult from "@/components/UsingQueryResult.vue"; | ||||||
|     import { useTeacherJoinRequestsQuery, useUpdateJoinRequestMutation } from "@/queries/teachers"; |     import { useTeacherJoinRequestsQuery, useUpdateJoinRequestMutation } from "@/queries/teachers"; | ||||||
|     import type { ClassJoinRequestDTO } from "@dwengo-1/common/interfaces/class-join-request"; |     import type { ClassJoinRequestDTO } from "@dwengo-1/common/interfaces/class-join-request"; | ||||||
|     import { useClassQuery, useClassStudentsQuery } from "@/queries/classes"; |     import { useClassDeleteStudentMutation, useClassQuery, useClassStudentsQuery } from "@/queries/classes"; | ||||||
|  | import { RefSymbol } from "@vue/reactivity"; | ||||||
| 
 | 
 | ||||||
|     const { t } = useI18n(); |     const { t } = useI18n(); | ||||||
| 
 | 
 | ||||||
|  | @ -21,13 +22,11 @@ | ||||||
|     const route = useRoute(); |     const route = useRoute(); | ||||||
|     const classId: string = route.params.id as string; |     const classId: string = route.params.id as string; | ||||||
| 
 | 
 | ||||||
|     const currentClass = ref<ClassDTO | undefined>(undefined); |  | ||||||
|     const students = ref<StudentDTO[]>([]); |  | ||||||
| 
 |  | ||||||
|     const getClass = useClassQuery(classId); |     const getClass = useClassQuery(classId); | ||||||
|     const getStudents = useClassStudentsQuery(classId); |     const getStudents = useClassStudentsQuery(classId); | ||||||
|     const joinRequestsQuery = useTeacherJoinRequestsQuery(username, classId); |     const joinRequestsQuery = useTeacherJoinRequestsQuery(username, classId); | ||||||
|     const { mutate } = useUpdateJoinRequestMutation(); |     const { mutate } = useUpdateJoinRequestMutation(); | ||||||
|  |     const { mutate: deleteStudentMutation } = useClassDeleteStudentMutation(); | ||||||
| 
 | 
 | ||||||
|     // Find the username of the logged in user so it can be used to fetch other information |     // Find the username of the logged in user so it can be used to fetch other information | ||||||
|     // When loading the page |     // When loading the page | ||||||
|  | @ -36,7 +35,6 @@ | ||||||
|         username.value = userObject?.profile?.preferred_username ?? undefined; |         username.value = userObject?.profile?.preferred_username ?? undefined; | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // TODO: Boolean that handles visibility for dialogs |  | ||||||
|     // Popup to verify removing student |     // Popup to verify removing student | ||||||
|     const dialog = ref(false); |     const dialog = ref(false); | ||||||
|     const selectedStudent = ref<StudentDTO | null>(null); |     const selectedStudent = ref<StudentDTO | null>(null); | ||||||
|  | @ -48,10 +46,19 @@ | ||||||
| 
 | 
 | ||||||
|     // Remove student from class |     // Remove student from class | ||||||
|     async function removeStudentFromclass(): Promise<void> { |     async function removeStudentFromclass(): Promise<void> { | ||||||
|         // TODO: replace by query |         deleteStudentMutation({id: classId, username: selectedStudent.value!.username}, { | ||||||
|  |                 onSuccess: async () => { | ||||||
|  |                     dialog.value = false; | ||||||
|  |                     await getStudents.refetch(); | ||||||
|  |                     showSnackbar(t("success"), "success"); | ||||||
|  |                 }, | ||||||
|  |                 onError: (e) => { | ||||||
|  |                     dialog.value = false; | ||||||
|  |                     showSnackbar(t("failed") + ": " + e.message, "error"); | ||||||
|  |                 }, | ||||||
|  |             },) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // TODO: query + relaoding |  | ||||||
|     function handleJoinRequest(c: ClassJoinRequestDTO, accepted: boolean): void { |     function handleJoinRequest(c: ClassJoinRequestDTO, accepted: boolean): void { | ||||||
|         mutate( |         mutate( | ||||||
|             { |             { | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 laurejablonski
						laurejablonski