From 569adf6518b101b2ca58bed5607d2c22bffae073 Mon Sep 17 00:00:00 2001 From: laurejablonski Date: Thu, 17 Apr 2025 10:42:27 +0200 Subject: [PATCH] style: lint + format --- frontend/src/views/classes/SingleClass.vue | 40 ++++++------ frontend/src/views/classes/StudentClasses.vue | 6 +- frontend/src/views/classes/TeacherClasses.vue | 63 ++++++++++--------- 3 files changed, 59 insertions(+), 50 deletions(-) diff --git a/frontend/src/views/classes/SingleClass.vue b/frontend/src/views/classes/SingleClass.vue index e35387e0..500a25f4 100644 --- a/frontend/src/views/classes/SingleClass.vue +++ b/frontend/src/views/classes/SingleClass.vue @@ -3,7 +3,7 @@ import authState from "@/services/auth/auth-service.ts"; import { onMounted, ref } from "vue"; import { useRoute } from "vue-router"; - import { type ClassResponse } from "@/controllers/classes"; + import type { ClassResponse } from "@/controllers/classes"; import type { JoinRequestsResponse, StudentsResponse } from "@/controllers/students"; import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; import UsingQueryResult from "@/components/UsingQueryResult.vue"; @@ -17,40 +17,41 @@ const classId: string = route.params.id as string; const username = ref(undefined); - // queries used to access the backend and catch loading or errors + // Queries used to access the backend and catch loading or errors - // gets the class a teacher wants to manage + // Gets the class a teacher wants to manage const getClass = useClassQuery(classId); - // get all students part of the class + // Get all students part of the class const getStudents = useClassStudentsQuery(classId); - // get all join requests for this class + // Get all join requests for this class const joinRequestsQuery = useTeacherJoinRequestsQuery(username, classId); - // handle accepting or rejecting join requests + // Handle accepting or rejecting join requests const { mutate } = useUpdateJoinRequestMutation(); - // handle deletion of a student from the class + // Handle deletion of a student from the class const { mutate: deleteStudentMutation } = useClassDeleteStudentMutation(); - // load current user before rendering the page + // Load current user before rendering the page onMounted(async () => { const userObject = await authState.loadUser(); username.value = userObject?.profile?.preferred_username ?? undefined; }); - // used to set the visibility of the dialog + // Used to set the visibility of the dialog const dialog = ref(false); - // student selected for deletion + // Student selected for deletion const selectedStudent = ref(null); - // let the teacher verify deletion of a student + // Let the teacher verify deletion of a student function showPopup(s: StudentDTO): void { selectedStudent.value = s; dialog.value = true; } - async function removeStudentFromclass(): Promise { - // delete student from class - deleteStudentMutation({id: classId, username: selectedStudent.value!.username}, { + // Delete student from class + deleteStudentMutation( + { id: classId, username: selectedStudent.value!.username }, + { onSuccess: async () => { dialog.value = false; await getStudents.refetch(); @@ -60,11 +61,12 @@ dialog.value = false; showSnackbar(t("failed") + ": " + e.message, "error"); }, - },) + }, + ); } function handleJoinRequest(c: ClassJoinRequestDTO, accepted: boolean): void { - // handle acception or rejection of a join request + // Handle acception or rejection of a join request mutate( { teacherUsername: username.value!, @@ -74,7 +76,7 @@ }, { onSuccess: async () => { - if (accepted){ + if (accepted) { await joinRequestsQuery.refetch(); await getStudents.refetch(); @@ -91,14 +93,14 @@ ); } - // default of snackbar values + // Default of snackbar values const snackbar = ref({ visible: false, message: "", color: "success", }); - // function to show snackbar on success or failure + // Function to show snackbar on success or failure function showSnackbar(message: string, color: string): void { snackbar.value.message = message; snackbar.value.color = color; diff --git a/frontend/src/views/classes/StudentClasses.vue b/frontend/src/views/classes/StudentClasses.vue index ba3294f0..920ba9aa 100644 --- a/frontend/src/views/classes/StudentClasses.vue +++ b/frontend/src/views/classes/StudentClasses.vue @@ -7,7 +7,7 @@ import { useCreateJoinRequestMutation, useStudentClassesQuery } from "@/queries/students"; import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; - import { type ClassesResponse } from "@/controllers/classes"; + import type { ClassesResponse } from "@/controllers/classes"; import UsingQueryResult from "@/components/UsingQueryResult.vue"; import { useClassStudentsQuery, useClassTeachersQuery } from "@/queries/classes"; import type { StudentsResponse } from "@/controllers/students"; @@ -44,7 +44,7 @@ async function openStudentDialog(c: ClassDTO): Promise { selectedClass.value = c; - // let the component know it should show the students in a class + // Let the component know it should show the students in a class getStudents.value = true; await getStudentsQuery.refetch(); dialog.value = true; @@ -53,7 +53,7 @@ async function openTeacherDialog(c: ClassDTO): Promise { selectedClass.value = c; - // let the component know it should show teachers of a class + // Let the component know it should show teachers of a class getStudents.value = false; await getTeachersQuery.refetch(); dialog.value = true; diff --git a/frontend/src/views/classes/TeacherClasses.vue b/frontend/src/views/classes/TeacherClasses.vue index b676e73f..81079356 100644 --- a/frontend/src/views/classes/TeacherClasses.vue +++ b/frontend/src/views/classes/TeacherClasses.vue @@ -6,7 +6,7 @@ import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; import type { TeacherInvitationDTO } from "@dwengo-1/common/interfaces/teacher-invitation"; import { useTeacherClassesQuery } from "@/queries/teachers"; - import { type ClassesResponse, type ClassResponse } from "@/controllers/classes"; + import type { ClassesResponse } from "@/controllers/classes"; import UsingQueryResult from "@/components/UsingQueryResult.vue"; import { useClassesQuery, useClassTeacherInvitationsQuery, useCreateClassMutation } from "@/queries/classes"; import type { TeacherInvitationsResponse } from "@/controllers/teacher-invitations"; @@ -252,34 +252,41 @@ :query-result="getInvitationsQuery" v-slot="invitationsResponse: { data: TeacherInvitationsResponse }" > - - - - {{ (classesResponse.data.classes as ClassDTO[]).filter((c) => c.id == i.classId)[0] }} - - {{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }} - -
- - {{ t("accept") }} - - - {{ t("deny") }} - -
- - -
+ + + {{ + (classesResponse.data.classes as ClassDTO[]).filter((c) => c.id == i.classId)[0] + }} + + + {{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }} + + +
+ + {{ t("accept") }} + + + {{ t("deny") }} + +
+ + +