diff --git a/backend/src/interfaces/assignment.ts b/backend/src/interfaces/assignment.ts index ffd98951..2dc158d2 100644 --- a/backend/src/interfaces/assignment.ts +++ b/backend/src/interfaces/assignment.ts @@ -20,7 +20,7 @@ export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO { description: assignment.description, learningPath: assignment.learningPathHruid, language: assignment.learningPathLanguage, - deadline: assignment.deadline, + deadline: assignment.deadline ?? new Date(), groups: assignment.groups.map((group) => mapToGroupDTO(group, assignment.within)), }; } diff --git a/frontend/src/components/assignments/DeadlineSelector.vue b/frontend/src/components/assignments/DeadlineSelector.vue index 9295eec0..304c544c 100644 --- a/frontend/src/components/assignments/DeadlineSelector.vue +++ b/frontend/src/components/assignments/DeadlineSelector.vue @@ -1,49 +1,30 @@ - - diff --git a/frontend/src/utils/assignment-rules.ts b/frontend/src/utils/assignment-rules.ts index a0ad9281..b0d29cee 100644 --- a/frontend/src/utils/assignment-rules.ts +++ b/frontend/src/utils/assignment-rules.ts @@ -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."; } diff --git a/frontend/src/views/assignments/UserAssignments.vue b/frontend/src/views/assignments/UserAssignments.vue index 70e94eb0..84131d52 100644 --- a/frontend/src/views/assignments/UserAssignments.vue +++ b/frontend/src/views/assignments/UserAssignments.vue @@ -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 { 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") }}: {{ formatDate(assignment.deadline) }} - -
@@ -200,7 +191,6 @@ - @@ -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; } - -