sort the flattened course schedule (#93)
first by dayIndex, then startIndex, then endIndex.
This commit is contained in:
@@ -19,7 +19,7 @@ interface CalendarGridPoint {
|
|||||||
* Return type of useFlattenedCourseSchedule
|
* Return type of useFlattenedCourseSchedule
|
||||||
*/
|
*/
|
||||||
export interface CalendarGridCourse {
|
export interface CalendarGridCourse {
|
||||||
calendarGridPoint?: CalendarGridPoint;
|
calendarGridPoint: CalendarGridPoint;
|
||||||
componentProps: CalendarCourseCellProps;
|
componentProps: CalendarCourseCellProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +33,8 @@ export function useFlattenedCourseSchedule(): CalendarGridCourse[] {
|
|||||||
const [activeSchedule] = useSchedules();
|
const [activeSchedule] = useSchedules();
|
||||||
const { courses } = activeSchedule;
|
const { courses } = activeSchedule;
|
||||||
|
|
||||||
return courses.flatMap(course => {
|
return courses
|
||||||
|
.flatMap(course => {
|
||||||
const {
|
const {
|
||||||
status,
|
status,
|
||||||
department,
|
department,
|
||||||
@@ -46,6 +47,11 @@ export function useFlattenedCourseSchedule(): CalendarGridCourse[] {
|
|||||||
// asynch, online course
|
// asynch, online course
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
calendarGridPoint: {
|
||||||
|
dayIndex: 0,
|
||||||
|
startIndex: 0,
|
||||||
|
endIndex: 0,
|
||||||
|
},
|
||||||
componentProps: {
|
componentProps: {
|
||||||
courseDeptAndInstr,
|
courseDeptAndInstr,
|
||||||
status,
|
status,
|
||||||
@@ -83,5 +89,14 @@ export function useFlattenedCourseSchedule(): CalendarGridCourse[] {
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.sort((a: CalendarGridCourse, b: CalendarGridCourse) => {
|
||||||
|
if (a.calendarGridPoint.dayIndex !== b.calendarGridPoint.dayIndex) {
|
||||||
|
return a.calendarGridPoint.dayIndex - b.calendarGridPoint.dayIndex;
|
||||||
|
}
|
||||||
|
if (a.calendarGridPoint.startIndex !== b.calendarGridPoint.startIndex) {
|
||||||
|
return a.calendarGridPoint.startIndex - b.calendarGridPoint.startIndex;
|
||||||
|
}
|
||||||
|
return a.calendarGridPoint.endIndex - b.calendarGridPoint.endIndex;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user