style: run npm run lint
This commit is contained in:
		
							parent
							
								
									3eac5190c3
								
							
						
					
					
						commit
						d2a7eed4ad
					
				
					 1 changed files with 27 additions and 28 deletions
				
			
		|  | @ -1,30 +1,29 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
|     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, watch, watchEffect, 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 { 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 { useStudentClassesQuery, useStudentQuery } from "@/queries/students"; |     import { useStudentClassesQuery } from "@/queries/students"; | ||||||
|     import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; |     import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; | ||||||
|     import { StudentController } from "@/controllers/students"; |     import { StudentController } from "@/controllers/students"; | ||||||
| 
 | 
 | ||||||
|     const { t } = useI18n(); |     const { t } = useI18n(); | ||||||
|     const studentController: StudentController = new StudentController(); |     const studentController: StudentController = new StudentController(); | ||||||
| 
 | 
 | ||||||
|     type Invitation = { |     interface Invitation { | ||||||
|         id: string; |         id: string; | ||||||
|         class: ClassDTO; |         class: ClassDTO; | ||||||
|         sender: TeacherDTO; |         sender: TeacherDTO; | ||||||
|         receiver: TeacherDTO; |         receiver: TeacherDTO; | ||||||
|     }; |     } | ||||||
| 
 | 
 | ||||||
|     const classes: ComputedRef<ClassDTO[]> = computed(() => { |     const classes: ComputedRef<ClassDTO[]> = computed(() => { | ||||||
|         const response = classesResponse.value; |         const result: ClassDTO[] = []; | ||||||
|         let result: ClassDTO[] = []; |  | ||||||
|         if (!classesResponse.value) { |         if (!classesResponse.value) { | ||||||
|             return result; |             return result; | ||||||
|         } else { |         }  | ||||||
|             if (classesResponse.value.classes.length === 0) { |             if (classesResponse.value.classes.length === 0) { | ||||||
|                 return result; |                 return result; | ||||||
|             } |             } | ||||||
|  | @ -35,7 +34,7 @@ | ||||||
|                 return result; |                 return result; | ||||||
|             } |             } | ||||||
|             return classesResponse.value.classes as ClassDTO[]; |             return classesResponse.value.classes as ClassDTO[]; | ||||||
|         } |          | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     const username = ref<string | undefined>(undefined); |     const username = ref<string | undefined>(undefined); | ||||||
|  | @ -47,11 +46,11 @@ | ||||||
|         username.value = userObject?.profile?.preferred_username ?? undefined; |         username.value = userObject?.profile?.preferred_username ?? undefined; | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // get role of user |     // Get role of user | ||||||
|     const role: string = authState.authState.activeRole!; |     const role: string = authState.authState.activeRole!; | ||||||
| 
 | 
 | ||||||
|     // TODO: change to DTO |     // TODO: change to DTO | ||||||
|     const invitations = ref<Array<Invitation>>([]); |     const invitations = ref<Invitation[]>([]); | ||||||
| 
 | 
 | ||||||
|     // For students: code that they give in when sending a class join request |     // For students: code that they give in when sending a class join request | ||||||
|     // For teachers: code that they get when they create a new class |     // For teachers: code that they get when they create a new class | ||||||
|  | @ -60,15 +59,15 @@ | ||||||
|     // 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 | ||||||
|     // These rules are used to display a message to the user if they use a code that has an invalid format |     // These rules are used to display a message to the user if they use a code that has an invalid format | ||||||
|     const codeRules = [ |     const codeRules = [ | ||||||
|         (value: string | undefined) => { |         (value: string | undefined) : string | boolean => { | ||||||
|             if (value !== undefined && validate(value) && version(value) === 4) return true; |             if (value !== undefined && validate(value) && version(value) === 4) return true; | ||||||
|             return t("invalidFormat"); |             return t("invalidFormat"); | ||||||
|         }, |         }, | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     // 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: temp function that does not use the backend |             // TODO: temp function that does not use the backend | ||||||
|             console.log("Code submitted:", code.value); |             console.log("Code submitted:", code.value); | ||||||
|  | @ -80,17 +79,17 @@ | ||||||
|     // For teachers: creating a class will generate a popup with the generated code |     // For teachers: creating a class will generate a popup with the generated code | ||||||
|     const dialog = ref(false); |     const dialog = ref(false); | ||||||
| 
 | 
 | ||||||
|     // list of students in the selected class |     // List of students in the selected class | ||||||
|     const students = ref<Array<StudentDTO>>([]); |     const students = ref<StudentDTO[]>([]); | ||||||
| 
 | 
 | ||||||
|     // selected class itself |     // Selected class itself | ||||||
|     const selectedClass = ref<ClassDTO | null>(null); |     const selectedClass = ref<ClassDTO | null>(null); | ||||||
| 
 | 
 | ||||||
|     // function to display all members of a class |     // Function to display all members of a class | ||||||
|     async function openDialog(c: ClassDTO) { |     async function openDialog(c: ClassDTO) { | ||||||
|         selectedClass.value = c; |         selectedClass.value = c; | ||||||
| 
 | 
 | ||||||
|         // clear previous value |         // Clear previous value | ||||||
|         students.value = []; |         students.value = []; | ||||||
|         dialog.value = true; |         dialog.value = true; | ||||||
| 
 | 
 | ||||||
|  | @ -99,7 +98,7 @@ | ||||||
|                 try { |                 try { | ||||||
|                     const res = await studentController.getByUsername(uid); |                     const res = await studentController.getByUsername(uid); | ||||||
|                     return res.student; |                     return res.student; | ||||||
|                 } catch (e) { |                 } catch (_) { | ||||||
|                     return null; |                     return null; | ||||||
|                 } |                 } | ||||||
|             }), |             }), | ||||||
|  | @ -107,19 +106,19 @@ | ||||||
|         students.value = studentDTOs.filter(Boolean) as StudentDTO[]; |         students.value = studentDTOs.filter(Boolean) as StudentDTO[]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // function to handle a accepted invitation request |     // Function to handle a accepted invitation request | ||||||
|     function acceptRequest() { |     function acceptRequest() { | ||||||
|         //TODO |         //TODO | ||||||
|         console.log("request accepted"); |         console.log("request accepted"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // function to handle a denied invitation request |     // Function to handle a denied invitation request | ||||||
|     function denyRequest() { |     function denyRequest() { | ||||||
|         //TODO |         //TODO | ||||||
|         console.log("request denied"); |         console.log("request denied"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // catch the value a teacher inserts when making a class |     // Catch the value a teacher inserts 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 | ||||||
|  | @ -135,23 +134,23 @@ | ||||||
|         }, |         }, | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|     // function called when a teacher creates a class |     // Function called when a teacher creates a class | ||||||
|     function createClass() { |     function createClass() { | ||||||
|         // check if the class name is valid |         // Check if the class name is valid | ||||||
|         if (className && className.value.length > 0 && /^[a-zA-Z0-9_-]+$/.test(className.value)) { |         if (className.value && className.value.length > 0 && /^[a-zA-Z0-9_-]+$/.test(className.value)) { | ||||||
|             //TODO |             //TODO | ||||||
|             console.log("created class with name: " + className.value); |             console.log("created class with name: " + className.value); | ||||||
| 
 | 
 | ||||||
|             // show the generated code to share with the class |             // Show the generated code to share with the class | ||||||
|             dialog.value = true; |             dialog.value = true; | ||||||
|             code.value = "04c7c759-c41e-4ea9-968a-1e2a987ce0ed"; |             code.value = "04c7c759-c41e-4ea9-968a-1e2a987ce0ed"; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // if the unique code is copied, set this to true so it's being displayed for the user |     // If the unique code is copied, set this to true so it's being displayed for the user | ||||||
|     const copied = ref(false); |     const copied = ref(false); | ||||||
| 
 | 
 | ||||||
|     // copy the generated code to the clipboard |     // Copy the generated code to the clipboard | ||||||
|     function copyToClipboard() { |     function copyToClipboard() { | ||||||
|         navigator.clipboard.writeText(code.value); |         navigator.clipboard.writeText(code.value); | ||||||
|         copied.value = true; |         copied.value = true; | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 laurejablonski
						laurejablonski