diff --git a/frontend/src/views/classes/StudentClasses.vue b/frontend/src/views/classes/StudentClasses.vue index 1ff60cb1..a59481b4 100644 --- a/frontend/src/views/classes/StudentClasses.vue +++ b/frontend/src/views/classes/StudentClasses.vue @@ -7,9 +7,12 @@ import { useCreateJoinRequestMutation, useStudentClassesQuery } from "@/queries/students"; import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; import { StudentController } from "@/controllers/students"; + import { type TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; + import { TeacherController } from "@/controllers/teachers"; const { t } = useI18n(); const studentController: StudentController = new StudentController(); + const teacherController: TeacherController = new TeacherController(); // Username of logged in student const username = ref(undefined); @@ -40,16 +43,19 @@ // Students of selected class are shown when logged in student presses on the member count const selectedClass = ref(null); const students = ref([]); + const teachers = ref([]); + const getStudents = ref(false); // Boolean that handles visibility for dialogs // Clicking on membercount will show a dialog with all members const dialog = ref(false); // Function to display all members of a class in a dialog - async function openDialog(c: ClassDTO): Promise { + async function openStudentDialog(c: ClassDTO): Promise { selectedClass.value = c; // Clear previous value + getStudents.value = true; students.value = []; dialog.value = true; @@ -69,6 +75,30 @@ students.value = studentDTOs.filter(Boolean) as StudentDTO[]; } + async function openTeacherDialog(c: ClassDTO): Promise { + selectedClass.value = c; + + // clear previous value + getStudents.value = false; + teachers.value = []; + dialog.value = true; + + // Fetch names of teachers + const teacherDTOs: (TeacherDTO | null)[] = await Promise.all( + c.teachers.map(async (uid) => { + try { + const res = await teacherController.getByUsername(uid); + console.log(res); + return res.teacher; + } catch (_) { + return null; + } + }), + ); + + teachers.value = teacherDTOs.filter(Boolean) as TeacherDTO[]; + } + // Hold the code a student gives in to join a class const code = ref(""); @@ -158,6 +188,7 @@ {{ t("classes") }} + {{ t("teachers") }} {{ t("members") }} @@ -169,7 +200,13 @@ {{ c.displayName }} + {{ c.teachers.length }} + + {{ c.students.length }} @@ -187,7 +224,7 @@ {{ selectedClass?.displayName }} -
    +
    +
      +
    • + {{ teacher.firstName + " " + teacher.lastName }} +
    • +