- {instructors.length > 0 ? (
-
- {(expandedState[i]
- ? instructors
- : instructors.slice(0, 1)
- ).map((ins) => (
-
-
-
-
-
+ {Object.entries(instructorGroups)
+ .sort((a, b) => compareTerms(a[0], b[0]))
+ .map(([term, instructors], i) => {
+ const season = term.split(' ')[0].toLowerCase();
+ return (
+
+
+ {instructors.length > 0 ? (
+
+ {(expandedState[i]
+ ? instructors
+ : instructors.slice(0, 1)
+ ).map((ins) => (
+
+
-
-
- ))}
-
- ) : (
-
-
-
- No Instructor Assigned
+
+ ))}
-
- )}
- {instructors.length > 1 && (
-
handleToggle(i)}
- >
- +{instructors.length - 1}
- {variant === 'large' && (
-
- )}
-
- )}
+ ) : (
+
+
+
+ No Instructor Assigned
+
+
+ )}
+ {instructors.length > 1 && (
+
handleToggle(i)}
+ >
+ +{instructors.length - 1}
+ {variant === 'large' && (
+
+ )}
+
+ )}
+
-
- );
- })}
+ );
+ })}
);
};
diff --git a/client/src/lib/utils.ts b/client/src/lib/utils.ts
index ce32f9cd..54825733 100644
--- a/client/src/lib/utils.ts
+++ b/client/src/lib/utils.ts
@@ -4,14 +4,13 @@ import { Course } from '../model/Course';
import { Instructor } from '../model/Instructor';
import type { Schedule } from '../model/Schedule';
-const COURSE_TERM_ORDER = ['Fall', 'Winter', 'Summer'];
-
export const groupCurrentCourseTermInstructors = (course: Course) => {
const currentTerms = getCurrentTerms();
const currentInstructors = course.instructors.filter((i) =>
currentTerms.includes(i.term)
);
+
const termGroups = _.groupBy(currentInstructors, (i: Instructor) => i.term);
for (const term of course.terms) {
@@ -19,12 +18,7 @@ export const groupCurrentCourseTermInstructors = (course: Course) => {
termGroups[term] = [];
}
- const entries = Object.entries(termGroups);
-
- const indexOfTerm = (term: string) =>
- COURSE_TERM_ORDER.indexOf(term.split(' ')[0]);
-
- return entries.sort(([a], [b]) => indexOfTerm(a) - indexOfTerm(b));
+ return termGroups;
};
export const getCurrentTerms = (): [string, string, string] => {
@@ -32,6 +26,9 @@ export const getCurrentTerms = (): [string, string, string] => {
const month = now.getMonth() + 1;
const year = now.getFullYear();
+ if (month >= 5 && month < 8)
+ return [`Summer ${year}`, `Fall ${year}`, `Winter ${year + 1}`];
+
if (month >= 8)
return [`Fall ${year}`, `Winter ${year + 1}`, `Summer ${year + 1}`];