style: lint
This commit is contained in:
		
							parent
							
								
									65144b8cb3
								
							
						
					
					
						commit
						b25901cbb7
					
				
					 3 changed files with 41 additions and 47 deletions
				
			
		|  | @ -3,7 +3,6 @@ | ||||||
|     import authState from "@/services/auth/auth-service.ts"; |     import authState from "@/services/auth/auth-service.ts"; | ||||||
|     import { computed, onMounted, ref, type ComputedRef } from "vue"; |     import { computed, onMounted, ref, type ComputedRef } from "vue"; | ||||||
|     import { validate, version } from "uuid"; |     import { validate, version } from "uuid"; | ||||||
|     import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; |  | ||||||
|     import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; |     import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; | ||||||
|     import { useCreateJoinRequestMutation, useStudentClassesQuery } from "@/queries/students"; |     import { useCreateJoinRequestMutation, useStudentClassesQuery } from "@/queries/students"; | ||||||
|     import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; |     import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; | ||||||
|  | @ -12,56 +11,56 @@ | ||||||
|     const { t } = useI18n(); |     const { t } = useI18n(); | ||||||
|     const studentController: StudentController = new StudentController(); |     const studentController: StudentController = new StudentController(); | ||||||
| 
 | 
 | ||||||
|     // username of logged in student |     // Username of logged in student | ||||||
|     const username = ref<string | undefined>(undefined); |     const username = ref<string | undefined>(undefined); | ||||||
| 
 | 
 | ||||||
|     // 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 | ||||||
|     onMounted(async () => { |     onMounted(async () => { | ||||||
|         const userObject = await authState.loadUser(); |         const userObject = await authState.loadUser(); | ||||||
|         username.value = userObject?.profile?.preferred_username ?? undefined; |         username.value = userObject?.profile?.preferred_username ?? undefined; | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // fetch all classes of the logged in student |     // Fetch all classes of the logged in student | ||||||
|     const { data: classesResponse, isLoading, error } = useStudentClassesQuery(username); |     const { data: classesResponse, isLoading, error } = useStudentClassesQuery(username); | ||||||
| 
 | 
 | ||||||
|     // empty list when classes are not yet loaded, else the list of classes of the user |     // Empty list when classes are not yet loaded, else the list of classes of the user | ||||||
|     const classes: ComputedRef<ClassDTO[]> = computed(() => { |     const classes: ComputedRef<ClassDTO[]> = computed(() => { | ||||||
|         // the classes are not yet fetched |         // The classes are not yet fetched | ||||||
|         if (!classesResponse.value) { |         if (!classesResponse.value) { | ||||||
|             return []; |             return []; | ||||||
|         } |         } | ||||||
|         // the user has no classes |         // The user has no classes | ||||||
|         if (classesResponse.value.classes.length === 0) { |         if (classesResponse.value.classes.length === 0) { | ||||||
|             return []; |             return []; | ||||||
|         } |         } | ||||||
|         if (typeof classesResponse.value.classes[0] === "string") { |         if (typeof classesResponse.value.classes[0] === "string") { | ||||||
|             // should not occur because value of *full* is true |             // Should not occur because value of *full* is true | ||||||
|             // must be caught because typescript can't know the type |             // Must be caught because typescript can't know the type | ||||||
|             // i chose to return an empty list if this occurs |             // I chose to return an empty list if this occurs | ||||||
|             // it is also possible to fetch all classes from the id's returned |             // It is also possible to fetch all classes from the id's returned | ||||||
|             return []; |             return []; | ||||||
|         } |         } | ||||||
|         return classesResponse.value.classes as ClassDTO[]; |         return classesResponse.value.classes as ClassDTO[]; | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // students of selected class are shown when logged in student presses on the member count |     // Students of selected class are shown when logged in student presses on the member count | ||||||
|     const selectedClass = ref<ClassDTO | null>(null); |     const selectedClass = ref<ClassDTO | null>(null); | ||||||
|     const students = ref<StudentDTO[]>([]); |     const students = ref<StudentDTO[]>([]); | ||||||
| 
 | 
 | ||||||
|     // Boolean that handles visibility for dialogs |     // Boolean that handles visibility for dialogs | ||||||
|     // clicking on membercount will show a dialog with all members |     // Clicking on membercount will show a dialog with all members | ||||||
|     const dialog = ref(false); |     const dialog = ref(false); | ||||||
| 
 | 
 | ||||||
|     // Function to display all members of a class in a dialog |     // Function to display all members of a class in a dialog | ||||||
|     async function openDialog(c: ClassDTO) { |     async function openDialog(c: ClassDTO) : Promise<void> { | ||||||
|         selectedClass.value = c; |         selectedClass.value = c; | ||||||
| 
 | 
 | ||||||
|         // Clear previous value |         // Clear previous value | ||||||
|         students.value = []; |         students.value = []; | ||||||
|         dialog.value = true; |         dialog.value = true; | ||||||
| 
 | 
 | ||||||
|         // fetch students from their usernames to display their full names |         // Fetch students from their usernames to display their full names | ||||||
|         const studentDTOs: (StudentDTO | null)[] = await Promise.all( |         const studentDTOs: (StudentDTO | null)[] = await Promise.all( | ||||||
|             c.students.map(async (uid) => { |             c.students.map(async (uid) => { | ||||||
|                 try { |                 try { | ||||||
|  | @ -73,11 +72,11 @@ | ||||||
|             }), |             }), | ||||||
|         ); |         ); | ||||||
| 
 | 
 | ||||||
|         // only show students that are not fetched ass *null* |         // Only show students that are not fetched ass *null* | ||||||
|         students.value = studentDTOs.filter(Boolean) as StudentDTO[]; |         students.value = studentDTOs.filter(Boolean) as StudentDTO[]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // hold the code a student gives in to join a class |     // Hold the code a student gives in to join a class | ||||||
|     const code = ref<string>(""); |     const code = ref<string>(""); | ||||||
| 
 | 
 | ||||||
|     // The code a student sends in to join a class needs to be formatted as v4 to be valid |     // The code a student sends in to join a class needs to be formatted as v4 to be valid | ||||||
|  | @ -89,15 +88,14 @@ | ||||||
|         }, |         }, | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     // used to send the actual class join request |     // Used to send the actual class join request | ||||||
|     const { mutate, isError } = useCreateJoinRequestMutation(); |     const { mutate, isError } = useCreateJoinRequestMutation(); | ||||||
| 
 | 
 | ||||||
|     // Function called when a student submits a code to join a class |     // Function called when a student submits a code to join a class | ||||||
|     function submitCode() { |     function submitCode() { | ||||||
|         // Check if the code is valid |         // Check if the code is valid | ||||||
|         if (code.value !== undefined && validate(code.value) && version(code.value) === 4) { |         if (code.value !== undefined && validate(code.value) && version(code.value) === 4) { | ||||||
|             // TODO: uncomment when fixed |             mutate( { username : username.value! , classId : code.value }); | ||||||
|             // mutate( { username : username.value! , classId : code.value }); |  | ||||||
| 
 | 
 | ||||||
|             console.log("Code submitted:", code.value); |             console.log("Code submitted:", code.value); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -2,12 +2,8 @@ | ||||||
|     import { useI18n } from "vue-i18n"; |     import { useI18n } from "vue-i18n"; | ||||||
|     import authState from "@/services/auth/auth-service.ts"; |     import authState from "@/services/auth/auth-service.ts"; | ||||||
|     import { computed, onMounted, ref, type ComputedRef } from "vue"; |     import { computed, onMounted, ref, type ComputedRef } from "vue"; | ||||||
|     import { validate, version } from "uuid"; |  | ||||||
|     import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; |     import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; | ||||||
|     import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; |     import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; | ||||||
|     import { useCreateJoinRequestMutation, useStudentClassesQuery } from "@/queries/students"; |  | ||||||
|     import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; |  | ||||||
|     import { StudentController } from "@/controllers/students"; |  | ||||||
| 
 | 
 | ||||||
|     const { t } = useI18n(); |     const { t } = useI18n(); | ||||||
| 
 | 
 | ||||||
|  | @ -19,11 +15,11 @@ | ||||||
|         receiver: TeacherDTO; |         receiver: TeacherDTO; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // username of logged in teacher |     // Username of logged in teacher | ||||||
|     const username = ref<string | undefined>(undefined); |     const username = ref<string | undefined>(undefined); | ||||||
| 
 | 
 | ||||||
|     // 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 | ||||||
|     onMounted(async () => { |     onMounted(async () => { | ||||||
|         const userObject = await authState.loadUser(); |         const userObject = await authState.loadUser(); | ||||||
|         username.value = userObject?.profile?.preferred_username ?? undefined; |         username.value = userObject?.profile?.preferred_username ?? undefined; | ||||||
|  | @ -32,40 +28,40 @@ | ||||||
|     // TODO: fetch all classes of the logged in teacher |     // TODO: fetch all classes of the logged in teacher | ||||||
|     const isLoading = ref(false); |     const isLoading = ref(false); | ||||||
|     const error = ref<Error | null>(null); |     const error = ref<Error | null>(null); | ||||||
|     // const { data: classesResponse, isLoading, error } = useStudentClassesQuery(username); |     // Const { data: classesResponse, isLoading, error } = useStudentClassesQuery(username); | ||||||
| 
 | 
 | ||||||
|     // empty list when classes are not yet loaded, else the list of classes of the user |     // Empty list when classes are not yet loaded, else the list of classes of the user | ||||||
|     const classes: ComputedRef<ClassDTO[]> = computed(() => { |     const classes: ComputedRef<ClassDTO[]> = computed(() =>  | ||||||
|         return []; |          [] | ||||||
|         // TODO |         // TODO | ||||||
|         // // the classes are not yet fetched |         // // the classes are not yet fetched | ||||||
|         // if (!classesResponse.value) { |         // If (!classesResponse.value) { | ||||||
|         //     return []; |         //     Return []; | ||||||
|         // } |         // } | ||||||
|         //     // the user has no classes |         //     // the user has no classes | ||||||
|         //     if (classesResponse.value.classes.length === 0) { |         //     If (classesResponse.value.classes.length === 0) { | ||||||
|         //         return []; |         //         Return []; | ||||||
|         //     } |         //     } | ||||||
|         //     if (typeof classesResponse.value.classes[0] === "string") { |         //     If (typeof classesResponse.value.classes[0] === "string") { | ||||||
|         //         // should not occur because value of *full* is true |         //         // should not occur because value of *full* is true | ||||||
|         //         // must be caught because typescript can't know the type |         //         // must be caught because typescript can't know the type | ||||||
|         //         // i chose to return an empty list if this occurs |         //         // i chose to return an empty list if this occurs | ||||||
|         //         // it is also possible to fetch all classes from the id's returned |         //         // it is also possible to fetch all classes from the id's returned | ||||||
|         //         return []; |         //         Return []; | ||||||
|         //     } |         //     } | ||||||
|         //     return classesResponse.value.classes as ClassDTO[]; |         //     Return classesResponse.value.classes as ClassDTO[]; | ||||||
|     }); |     ); | ||||||
| 
 | 
 | ||||||
|     // 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 | ||||||
|     const dialog = ref(false); |     const dialog = ref(false); | ||||||
| 
 | 
 | ||||||
|     // duntion to display the dialog showing generated code for created class |     // Duntion to display the dialog showing generated code for created class | ||||||
|     function openDialog() { |     function openDialog() : void { | ||||||
|         //TODO |         //TODO | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // code generated when new class was created |     // Code generated when new class was created | ||||||
|     const code = ref<string>(""); |     const code = ref<string>(""); | ||||||
| 
 | 
 | ||||||
|     // TODO: implement correctly |     // TODO: implement correctly | ||||||
|  | @ -83,7 +79,7 @@ | ||||||
|         console.log("request denied"); |         console.log("request denied"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // teacher should be able to set a displayname when making a class |     // Teacher should be able to set a displayname when making a class | ||||||
|     const className = ref<string>(""); |     const className = ref<string>(""); | ||||||
| 
 | 
 | ||||||
|     // The name can only contain dash, underscore letters and numbers |     // The name can only contain dash, underscore letters and numbers | ||||||
|  | @ -112,7 +108,7 @@ | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // show the teacher, copying of the code was a successs |     // Show the teacher, copying of the code was a successs | ||||||
|     const copied = ref(false); |     const copied = ref(false); | ||||||
| 
 | 
 | ||||||
|     // Copy the generated code to the clipboard |     // Copy the generated code to the clipboard | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ | ||||||
|     import TeacherClasses from "./TeacherClasses.vue"; |     import TeacherClasses from "./TeacherClasses.vue"; | ||||||
|     import StudentClasses from "./StudentClasses.vue"; |     import StudentClasses from "./StudentClasses.vue"; | ||||||
| 
 | 
 | ||||||
|     // determine if role is student or teacher to render correct view |     // Determine if role is student or teacher to render correct view | ||||||
|     const role: string = authState.authState.activeRole!; |     const role: string = authState.authState.activeRole!; | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 laurejablonski
						laurejablonski