feat: start join requests leerkracht
This commit is contained in:
		
							parent
							
								
									9cb44949ac
								
							
						
					
					
						commit
						74acea493d
					
				
					 2 changed files with 41 additions and 10 deletions
				
			
		|  | @ -15,7 +15,7 @@ export function makeTestClasses(em: EntityManager, students: Student[], teachers | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     const studentsClass02: Student[] = students.slice(0, 2).concat(students.slice(3, 4)); |     const studentsClass02: Student[] = students.slice(0, 2).concat(students.slice(3, 4)); | ||||||
|     const teacherClass02: Teacher[] = teachers.slice(1, 2); |     const teacherClass02: Teacher[] = teachers.slice(1, 2).concat(teachers.slice(4,5)); | ||||||
| 
 | 
 | ||||||
|     const class02 = em.create(Class, { |     const class02 = em.create(Class, { | ||||||
|         classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89', |         classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89', | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ | ||||||
|     import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; |     import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; | ||||||
|     import { useStudentJoinRequestQuery } from "@/queries/students"; |     import { useStudentJoinRequestQuery } from "@/queries/students"; | ||||||
|     import UsingQueryResult from "@/components/UsingQueryResult.vue"; |     import UsingQueryResult from "@/components/UsingQueryResult.vue"; | ||||||
|     import { useTeacherJoinRequestsQuery } 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"; | ||||||
| 
 | 
 | ||||||
|     const { t } = useI18n(); |     const { t } = useI18n(); | ||||||
|  | @ -27,6 +27,7 @@ | ||||||
|     const students = ref<StudentDTO[]>([]); |     const students = ref<StudentDTO[]>([]); | ||||||
| 
 | 
 | ||||||
|     const joinRequestsQuery = useTeacherJoinRequestsQuery(username, classId); |     const joinRequestsQuery = useTeacherJoinRequestsQuery(username, classId); | ||||||
|  |     const { mutate } = useUpdateJoinRequestMutation(); | ||||||
| 
 | 
 | ||||||
|     // 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 | ||||||
|  | @ -66,12 +67,34 @@ | ||||||
|         //TODO when query; reload table so student not longer in table |         //TODO when query; reload table so student not longer in table | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function acceptStudent(s: StudentDTO) { |     function handleJoinRequest(c: ClassJoinRequestDTO, accepted: boolean) { | ||||||
|         //TODO |         mutate( | ||||||
|  |             { | ||||||
|  |                 teacherUsername: username.value!, | ||||||
|  |                 studentUsername: c.requester.username, | ||||||
|  |                 classId: c.class, | ||||||
|  |                 accepted: accepted, | ||||||
|  |             }, | ||||||
|  |             { | ||||||
|  |                 onSuccess: () => { | ||||||
|  |                     showSnackbar(t("sent"), "success"); | ||||||
|  |                 }, | ||||||
|  |                 onError: (e) => { | ||||||
|  |                     showSnackbar(t("failed") + ": " + e.message, "error"); | ||||||
|  |                 }, | ||||||
|  |             }, | ||||||
|  |         ); | ||||||
|     } |     } | ||||||
|  |     const snackbar = ref({ | ||||||
|  |         visible: false, | ||||||
|  |         message: "", | ||||||
|  |         color: "success", | ||||||
|  |     }); | ||||||
| 
 | 
 | ||||||
|     function rejectStudent(joinRequest: ClassJoinRequestDTO) { |     function showSnackbar(message: string, color: string): void { | ||||||
|         //TODO |         snackbar.value.message = message; | ||||||
|  |         snackbar.value.color = color; | ||||||
|  |         snackbar.value.visible = true; | ||||||
|     } |     } | ||||||
| </script> | </script> | ||||||
| <template> | <template> | ||||||
|  | @ -132,7 +155,7 @@ | ||||||
|                             sm="6" |                             sm="6" | ||||||
|                             md="6" |                             md="6" | ||||||
|                         > |                         > | ||||||
|                             <v-table class="table"> |                             <!-- <v-table class="table"> | ||||||
|                                 <thead> |                                 <thead> | ||||||
|                                     <tr> |                                     <tr> | ||||||
|                                         <th class="header">{{ t("classJoinRequests") }}</th> |                                         <th class="header">{{ t("classJoinRequests") }}</th> | ||||||
|  | @ -149,7 +172,7 @@ | ||||||
|                                         </td> |                                         </td> | ||||||
|                                         <td> |                                         <td> | ||||||
|                                             <v-btn |                                             <v-btn | ||||||
|                                                 @click="acceptStudent" |                                                 @click="handleJoinRequest(jr, true)" | ||||||
|                                                 class="mr-2" |                                                 class="mr-2" | ||||||
|                                                 color="green" |                                                 color="green" | ||||||
|                                             > |                                             > | ||||||
|  | @ -157,7 +180,7 @@ | ||||||
|                                             > |                                             > | ||||||
| 
 | 
 | ||||||
|                                             <v-btn |                                             <v-btn | ||||||
|                                                 @click="rejectStudent" |                                                 @click="handleJoinRequest(jr, false)" | ||||||
|                                                 class="mr-2" |                                                 class="mr-2" | ||||||
|                                                 color="red" |                                                 color="red" | ||||||
|                                             > |                                             > | ||||||
|  | @ -166,7 +189,8 @@ | ||||||
|                                         </td> |                                         </td> | ||||||
|                                     </tr> |                                     </tr> | ||||||
|                                 </tbody> |                                 </tbody> | ||||||
|                             </v-table> |                             </v-table> TODO schrijf nieuwe controller + query--> | ||||||
|  |                             <p>{{ joinRequests.data.joinRequests }}</p> | ||||||
|                         </v-col> |                         </v-col> | ||||||
|                     </using-query-result> |                     </using-query-result> | ||||||
|                 </v-row> |                 </v-row> | ||||||
|  | @ -195,6 +219,13 @@ | ||||||
|                 </v-card-actions> |                 </v-card-actions> | ||||||
|             </v-card> |             </v-card> | ||||||
|         </v-dialog> |         </v-dialog> | ||||||
|  |         <v-snackbar | ||||||
|  |             v-model="snackbar.visible" | ||||||
|  |             :color="snackbar.color" | ||||||
|  |             timeout="3000" | ||||||
|  |         > | ||||||
|  |             {{ snackbar.message }} | ||||||
|  |         </v-snackbar> | ||||||
|     </main> |     </main> | ||||||
| </template> | </template> | ||||||
| <style scoped> | <style scoped> | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 laurejablonski
						laurejablonski