fix: deadline nullable maken om errors te vermijden

This commit is contained in:
Joyelle Ndagijimana 2025-05-13 09:09:46 +02:00
parent 24c8a395d6
commit db55a9bea4
2 changed files with 5 additions and 7 deletions

View file

@ -26,7 +26,7 @@ export class Assignment {
@Property({ type: 'string' })
learningPathHruid!: string;
@Property({ type: 'datetime' })
@Property({ type: 'datetime', nullable: true })
deadline?: Date;
@Enum({

View file

@ -109,15 +109,13 @@
function getDeadlineClass(deadline?: string | Date): string {
if (!deadline) return "";
const date = new Date(deadline);
const now = new Date();
const isToday =
date.getDate() === now.getDate() &&
date.getMonth() === now.getMonth() &&
date.getFullYear() === now.getFullYear();
const in24Hours = new Date(now.getTime() + 24 * 60 * 60 * 1000);
if (date.getTime() < now.getTime()) return "deadline-passed";
if (isToday) return "deadline-today";
if (date.getTime() <= in24Hours.getTime()) return "deadline-in24hours";
return "deadline-upcoming";
}
@ -259,7 +257,7 @@
font-weight: bold;
}
.assignment-deadline.deadline-today {
.assignment-deadline.deadline-in24hours {
color: #f57c00;
font-weight: bold;
}