fix: deadline nullable maken om errors te vermijden
This commit is contained in:
parent
24c8a395d6
commit
db55a9bea4
2 changed files with 5 additions and 7 deletions
|
@ -26,7 +26,7 @@ export class Assignment {
|
||||||
@Property({ type: 'string' })
|
@Property({ type: 'string' })
|
||||||
learningPathHruid!: string;
|
learningPathHruid!: string;
|
||||||
|
|
||||||
@Property({ type: 'datetime' })
|
@Property({ type: 'datetime', nullable: true })
|
||||||
deadline?: Date;
|
deadline?: Date;
|
||||||
|
|
||||||
@Enum({
|
@Enum({
|
||||||
|
|
|
@ -109,15 +109,13 @@
|
||||||
|
|
||||||
function getDeadlineClass(deadline?: string | Date): string {
|
function getDeadlineClass(deadline?: string | Date): string {
|
||||||
if (!deadline) return "";
|
if (!deadline) return "";
|
||||||
|
|
||||||
const date = new Date(deadline);
|
const date = new Date(deadline);
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const isToday =
|
const in24Hours = new Date(now.getTime() + 24 * 60 * 60 * 1000);
|
||||||
date.getDate() === now.getDate() &&
|
|
||||||
date.getMonth() === now.getMonth() &&
|
|
||||||
date.getFullYear() === now.getFullYear();
|
|
||||||
|
|
||||||
if (date.getTime() < now.getTime()) return "deadline-passed";
|
if (date.getTime() < now.getTime()) return "deadline-passed";
|
||||||
if (isToday) return "deadline-today";
|
if (date.getTime() <= in24Hours.getTime()) return "deadline-in24hours";
|
||||||
return "deadline-upcoming";
|
return "deadline-upcoming";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +257,7 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assignment-deadline.deadline-today {
|
.assignment-deadline.deadline-in24hours {
|
||||||
color: #f57c00;
|
color: #f57c00;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue