Fix sort date (move dates with no end date to the back
This commit is contained in:
parent
45a70f6b75
commit
ee33d999d1
|
|
@ -201,7 +201,18 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
|||
allCourseSessions.value?.forEach((cs) => {
|
||||
allDueDatesReturn.push(...cs.due_dates);
|
||||
});
|
||||
allDueDatesReturn.sort((a, b) => dayjs(a.end).diff(dayjs(b.end)));
|
||||
|
||||
allDueDatesReturn.sort((a, b) => {
|
||||
const dateA = dayjs(a.end);
|
||||
const dateB = dayjs(b.end);
|
||||
|
||||
if (!dateA.isValid() && !dateB.isValid()) return 0; // If both are invalid, they are equal
|
||||
if (!dateA.isValid()) return 1; // If dateA is invalid, it goes after dateB
|
||||
if (!dateB.isValid()) return -1; // If dateB is invalid, it goes after dateA
|
||||
|
||||
return dateA.diff(dateB); // Otherwise, sort by the end date
|
||||
});
|
||||
|
||||
return allDueDatesReturn;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue