fix: linter
This commit is contained in:
		
							parent
							
								
									2180425323
								
							
						
					
					
						commit
						f1ef976ac5
					
				
					 4 changed files with 50 additions and 79 deletions
				
			
		|  | @ -1,49 +1,30 @@ | |||
| <script setup lang="ts"> | ||||
|     import { ref, computed } from "vue"; | ||||
|     import { ref, watch } from "vue"; | ||||
|     import { deadlineRules } from "@/utils/assignment-rules.ts"; | ||||
| 
 | ||||
|     const date = ref(""); | ||||
|     const time = ref("23:59"); | ||||
|     const emit = defineEmits(["update:deadline"]); | ||||
|     const emit = defineEmits<(e: "update:deadline", value: Date) => void>(); | ||||
| 
 | ||||
|     const formattedDeadline = computed(() => { | ||||
|         if (!date.value || !time.value) return ""; | ||||
|         return `${date.value} ${time.value}`; | ||||
|     }); | ||||
|     const datetime = ref(""); | ||||
| 
 | ||||
|     function updateDeadline(): void { | ||||
|         if (date.value && time.value) { | ||||
|             emit("update:deadline", formattedDeadline.value); | ||||
|     // Watch the datetime value and emit the update | ||||
|     watch(datetime, (val) => { | ||||
|         const newDate = new Date(val); | ||||
|         if (!isNaN(newDate.getTime())) { | ||||
|             emit("update:deadline", newDate); | ||||
|         } | ||||
|     } | ||||
|     }); | ||||
| </script> | ||||
| 
 | ||||
| <template> | ||||
|     <div> | ||||
|         <v-card-text> | ||||
|             <v-text-field | ||||
|                 v-model="date" | ||||
|                 label="Select Deadline Date" | ||||
|                 type="date" | ||||
|                 variant="outlined" | ||||
|                 density="compact" | ||||
|                 :rules="deadlineRules" | ||||
|                 required | ||||
|                 @update:modelValue="updateDeadline" | ||||
|             ></v-text-field> | ||||
|         </v-card-text> | ||||
| 
 | ||||
|         <v-card-text> | ||||
|             <v-text-field | ||||
|                 v-model="time" | ||||
|                 label="Select Deadline Time" | ||||
|                 type="time" | ||||
|                 variant="outlined" | ||||
|                 density="compact" | ||||
|                 @update:modelValue="updateDeadline" | ||||
|             ></v-text-field> | ||||
|         </v-card-text> | ||||
|     </div> | ||||
|     <v-card-text> | ||||
|         <v-text-field | ||||
|             v-model="datetime" | ||||
|             type="datetime-local" | ||||
|             label="Select Deadline" | ||||
|             variant="outlined" | ||||
|             density="compact" | ||||
|             :rules="deadlineRules" | ||||
|             required | ||||
|         /> | ||||
|     </v-card-text> | ||||
| </template> | ||||
| 
 | ||||
| <style scoped></style> | ||||
|  |  | |||
|  | @ -58,7 +58,7 @@ export const deadlineRules = [ | |||
|             return "Invalid date or time."; | ||||
|         } | ||||
| 
 | ||||
|         if (selectedDateTime < now) { | ||||
|         if (selectedDateTime <= now) { | ||||
|             return "The deadline must be in the future."; | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -29,30 +29,29 @@ | |||
| 
 | ||||
|     const classController = new ClassController(); | ||||
| 
 | ||||
|     const assignments = asyncComputed(async () => { | ||||
|         const classes = classesQueryResults?.data?.value?.classes; | ||||
|         if (!classes) return []; | ||||
|     const assignments = asyncComputed( | ||||
|         async () => { | ||||
|             const classes = classesQueryResults?.data?.value?.classes; | ||||
|             if (!classes) return []; | ||||
| 
 | ||||
|         const result = await Promise.all( | ||||
|             (classes as ClassDTO[]).map(async (cls) => { | ||||
|                 const { assignments } = await classController.getAssignments(cls.id); | ||||
|                 return assignments.map((a) => ({ | ||||
|                     id: a.id, | ||||
|                     class: cls, | ||||
|                     title: a.title, | ||||
|                     description: a.description, | ||||
|                     learningPath: a.learningPath, | ||||
|                     language: a.language, | ||||
|                     deadline: a.deadline, | ||||
|                     groups: a.groups, | ||||
|                 })); | ||||
|             }), | ||||
|         ); | ||||
|             const result = await Promise.all( | ||||
|                 (classes as ClassDTO[]).map(async (cls) => { | ||||
|                     const { assignments } = await classController.getAssignments(cls.id); | ||||
|                     return assignments.map((a) => ({ | ||||
|                         id: a.id, | ||||
|                         class: cls, | ||||
|                         title: a.title, | ||||
|                         description: a.description, | ||||
|                         learningPath: a.learningPath, | ||||
|                         language: a.language, | ||||
|                         deadline: a.deadline, | ||||
|                         groups: a.groups, | ||||
|                     })); | ||||
|                 }), | ||||
|             ); | ||||
| 
 | ||||
|         // Order the assignments by deadline | ||||
|         return result | ||||
|             .flat() | ||||
|             .sort((a, b) => { | ||||
|             // Order the assignments by deadline | ||||
|             return result.flat().sort((a, b) => { | ||||
|                 const now = Date.now(); | ||||
|                 const aTime = new Date(a.deadline).getTime(); | ||||
|                 const bTime = new Date(b.deadline).getTime(); | ||||
|  | @ -65,8 +64,10 @@ | |||
| 
 | ||||
|                 return aTime - bTime; | ||||
|             }); | ||||
|     }, [], {evaluating: true}); | ||||
| 
 | ||||
|         }, | ||||
|         [], | ||||
|         { evaluating: true }, | ||||
|     ); | ||||
| 
 | ||||
|     async function goToCreateAssignment(): Promise<void> { | ||||
|         await router.push("/assignment/create"); | ||||
|  | @ -88,11 +89,6 @@ | |||
|         mutate({ cid: clsId, an: num }); | ||||
|     } | ||||
| 
 | ||||
|     function isPastDeadline(deadline?: string | Date): boolean { | ||||
|         if (!deadline) return false; | ||||
|         return new Date(deadline).getTime() < Date.now(); | ||||
|     } | ||||
| 
 | ||||
|     function formatDate(date?: string | Date): string { | ||||
|         if (!date) return "–"; | ||||
|         const d = new Date(date); | ||||
|  | @ -122,9 +118,6 @@ | |||
|         return "deadline-upcoming"; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     onMounted(async () => { | ||||
|         const user = await auth.loadUser(); | ||||
|         username.value = user?.profile?.preferred_username ?? ""; | ||||
|  | @ -167,8 +160,6 @@ | |||
|                                 {{ t("deadline") }}: | ||||
|                                 <span>{{ formatDate(assignment.deadline) }}</span> | ||||
|                             </div> | ||||
| 
 | ||||
| 
 | ||||
|                         </div> | ||||
| 
 | ||||
|                         <div class="spacer"></div> | ||||
|  | @ -200,7 +191,6 @@ | |||
|                     </div> | ||||
|                 </v-col> | ||||
|             </v-row> | ||||
| 
 | ||||
|         </v-container> | ||||
|     </div> | ||||
| </template> | ||||
|  | @ -237,7 +227,9 @@ | |||
|         border-radius: 16px; | ||||
|         box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); | ||||
|         background-color: white; | ||||
|         transition: transform 0.2s, box-shadow 0.2s; | ||||
|         transition: | ||||
|             transform 0.2s, | ||||
|             box-shadow 0.2s; | ||||
|     } | ||||
|     .assignment-card:hover { | ||||
|         transform: translateY(-2px); | ||||
|  | @ -295,6 +287,4 @@ | |||
|         color: #777; | ||||
|         padding: 3rem 0; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| </style> | ||||
|  |  | |||
		Reference in a new issue
	
	 Joyelle Ndagijimana
						Joyelle Ndagijimana