feat: start invitations
This commit is contained in:
		
							parent
							
								
									dcb099f45b
								
							
						
					
					
						commit
						baa6cd6ce5
					
				
					 2 changed files with 38 additions and 33 deletions
				
			
		|  | @ -14,6 +14,7 @@ import { invalidateAllAssignmentKeys } from "./assignments"; | ||||||
| import { invalidateAllGroupKeys } from "./groups"; | import { invalidateAllGroupKeys } from "./groups"; | ||||||
| import { invalidateAllSubmissionKeys } from "./submissions"; | import { invalidateAllSubmissionKeys } from "./submissions"; | ||||||
| import type { TeachersResponse } from "@/controllers/teachers"; | import type { TeachersResponse } from "@/controllers/teachers"; | ||||||
|  | import type { TeacherInvitationsResponse } from "@/controllers/teacher-invitations"; | ||||||
| 
 | 
 | ||||||
| const classController = new ClassController(); | const classController = new ClassController(); | ||||||
| 
 | 
 | ||||||
|  | @ -205,7 +206,7 @@ export function useClassDeleteTeacherMutation(): UseMutationReturnType< | ||||||
| export function useClassTeacherInvitationsQuery( | export function useClassTeacherInvitationsQuery( | ||||||
|     id: MaybeRefOrGetter<string | undefined>, |     id: MaybeRefOrGetter<string | undefined>, | ||||||
|     full: MaybeRefOrGetter<boolean> = true, |     full: MaybeRefOrGetter<boolean> = true, | ||||||
| ): UseQueryReturnType<StudentsResponse, Error> { | ): UseQueryReturnType<TeacherInvitationsResponse, Error> { | ||||||
|     return useQuery({ |     return useQuery({ | ||||||
|         queryKey: computed(() => classTeacherInvitationsKey(toValue(id)!, toValue(full))), |         queryKey: computed(() => classTeacherInvitationsKey(toValue(id)!, toValue(full))), | ||||||
|         queryFn: async () => classController.getTeacherInvitations(toValue(id)!, toValue(full)), |         queryFn: async () => classController.getTeacherInvitations(toValue(id)!, toValue(full)), | ||||||
|  |  | ||||||
|  | @ -8,7 +8,8 @@ | ||||||
|     import { useTeacherClassesQuery } from "@/queries/teachers"; |     import { useTeacherClassesQuery } from "@/queries/teachers"; | ||||||
|     import { type ClassesResponse, type ClassResponse } from "@/controllers/classes"; |     import { type ClassesResponse, type ClassResponse } from "@/controllers/classes"; | ||||||
|     import UsingQueryResult from "@/components/UsingQueryResult.vue"; |     import UsingQueryResult from "@/components/UsingQueryResult.vue"; | ||||||
|     import { useCreateClassMutation } from "@/queries/classes"; |     import { useClassesQuery, useClassTeacherInvitationsQuery, useCreateClassMutation } from "@/queries/classes"; | ||||||
|  |     import type { TeacherInvitationsResponse } from "@/controllers/teacher-invitations"; | ||||||
| 
 | 
 | ||||||
|     const { t } = useI18n(); |     const { t } = useI18n(); | ||||||
| 
 | 
 | ||||||
|  | @ -24,7 +25,9 @@ | ||||||
| 
 | 
 | ||||||
|     // Fetch all classes of the logged in teacher |     // Fetch all classes of the logged in teacher | ||||||
|     const classesQuery = useTeacherClassesQuery(username, true); |     const classesQuery = useTeacherClassesQuery(username, true); | ||||||
|  |     const allClassesQuery = useClassesQuery(); | ||||||
|     const { mutate } = useCreateClassMutation(); |     const { mutate } = useCreateClassMutation(); | ||||||
|  |     const getInvitationsQuery = useClassTeacherInvitationsQuery(username); | ||||||
| 
 | 
 | ||||||
|     // Boolean that handles visibility for dialogs |     // Boolean that handles visibility for dialogs | ||||||
|     // Creating a class will generate a popup with the generated code |     // Creating a class will generate a popup with the generated code | ||||||
|  | @ -33,19 +36,14 @@ | ||||||
|     // Code generated when new class was created |     // Code generated when new class was created | ||||||
|     const code = ref<string>(""); |     const code = ref<string>(""); | ||||||
| 
 | 
 | ||||||
|     // TODO: waiting on frontend controllers |  | ||||||
|     const invitations = ref<TeacherInvitationDTO[]>([]); |  | ||||||
| 
 |  | ||||||
|     // Function to handle a accepted invitation request |     // Function to handle a accepted invitation request | ||||||
|     function acceptRequest(): void { |     function acceptRequest(): void { | ||||||
|         //TODO: avoid linting issues when merging by filling the function |         //TODO: avoid linting issues when merging by filling the function | ||||||
|         invitations.value = []; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Function to handle a denied invitation request |     // Function to handle a denied invitation request | ||||||
|     function denyRequest(): void { |     function denyRequest(): void { | ||||||
|         //TODO: avoid linting issues when merging by filling the function |         //TODO: avoid linting issues when merging by filling the function | ||||||
|         invitations.value = []; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Teacher should be able to set a displayname when making a class |     // Teacher should be able to set a displayname when making a class | ||||||
|  | @ -250,33 +248,39 @@ | ||||||
|                     </tr> |                     </tr> | ||||||
|                 </thead> |                 </thead> | ||||||
|                 <tbody> |                 <tbody> | ||||||
|                     <tr |                     <using-query-result | ||||||
|                         v-for="i in invitations" |                         :query-result="getInvitationsQuery" | ||||||
|                         :key="i.classId" |                         v-slot="invitationsResponse: { data: TeacherInvitationsResponse }" | ||||||
|                     > |                     > | ||||||
|                         <td> |                     <using-query-result :query-result="allClassesQuery" v-slot="classesResponse: {data: ClassesResponse}"> | ||||||
|                             {{ i.classId }} |                         <tr | ||||||
|                             <!-- TODO fetch display name via classId because db only returns classId field --> |                             v-for="i in invitationsResponse.data.invitations as TeacherInvitationDTO[]" | ||||||
|                         </td> |                             :key="i.classId" | ||||||
|                         <td>{{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }}</td> |                         > | ||||||
|                         <td class="text-right"> |                             <td> | ||||||
|                             <div> |                                 {{ (classesResponse.data.classes as ClassDTO[]).filter((c) => c.id == i.classId)[0] }} | ||||||
|                                 <v-btn |                             </td> | ||||||
|                                     color="green" |                             <td>{{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }}</td> | ||||||
|                                     @click="acceptRequest" |                             <td class="text-right"> | ||||||
|                                     class="mr-2" |                                 <div> | ||||||
|                                 > |                                     <v-btn | ||||||
|                                     {{ t("accept") }} |                                         color="green" | ||||||
|                                 </v-btn> |                                         @click="acceptRequest" | ||||||
|                                 <v-btn |                                         class="mr-2" | ||||||
|                                     color="red" |                                     > | ||||||
|                                     @click="denyRequest" |                                         {{ t("accept") }} | ||||||
|                                 > |                                     </v-btn> | ||||||
|                                     {{ t("deny") }} |                                     <v-btn | ||||||
|                                 </v-btn> |                                         color="red" | ||||||
|                             </div> |                                         @click="denyRequest" | ||||||
|                         </td> |                                     > | ||||||
|                     </tr> |                                         {{ t("deny") }} | ||||||
|  |                                     </v-btn> | ||||||
|  |                                 </div> | ||||||
|  |                             </td> | ||||||
|  |                         </tr> | ||||||
|  |                     </using-query-result> | ||||||
|  |                     </using-query-result> | ||||||
|                 </tbody> |                 </tbody> | ||||||
|             </v-table> |             </v-table> | ||||||
|         </div> |         </div> | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 laurejablonski
						laurejablonski