Skip to content

Commit

Permalink
Swap past enrollment arrows and order (#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas-Hong authored Mar 1, 2024
1 parent baa02f9 commit 5adfc89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function PopupHeader({
width: graphWidth,
}}
>
<Tooltip title="Newer Graph">
<Tooltip title="Older Graph">
{/* In order for a tooltip to work properly with disabled buttons, we need to wrap the button in a span */}
<span>
<IconButton onClick={handleBack} disabled={graphIndex === 0}>
Expand All @@ -56,7 +56,7 @@ function PopupHeader({
<Typography sx={{ fontWeight: 500, fontSize: isMobileScreen ? '0.8rem' : '1rem', textAlign: 'center' }}>
{popupTitle}
</Typography>
<Tooltip title="Older Graph">
<Tooltip title="Newer Graph">
<span>
<IconButton onClick={handleForward} disabled={graphIndex === enrollmentHistory.length - 1}>
<ArrowForward />
Expand Down Expand Up @@ -114,7 +114,9 @@ export function EnrollmentHistoryPopup({ department, courseNumber }: EnrollmentH
deptEnrollmentHistory.find(courseNumber).then((data) => {
if (data) {
setEnrollmentHistory(data);
setGraphIndex(0);
// The graph index is the last past enrollment graph since we want to show
// the most recent quarter's graph
setGraphIndex(data.length - 1);
}
setLoading(false);
});
Expand Down
8 changes: 4 additions & 4 deletions apps/antalmanac/src/lib/enrollmentHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class DepartmentEnrollmentHistory {

/**
* Sorts the given array of enrollment histories so that
* the most recent quarters are in the beginning of the array.
* the oldest quarters are in the beginning of the array
*
* @param enrollmentHistory Array where each element represents the enrollment
* history of a course section during one quarter
Expand All @@ -145,10 +145,10 @@ export class DepartmentEnrollmentHistory {
const aTerm = `${a.year} ${a.quarter}`;
const bTerm = `${b.year} ${b.quarter}`;
// If the term for a appears earlier than the term for b in the list of
// term short names, then a must be the enrollment history for a later quarter
// term short names, then a must be the enrollment history for a more recent quarter
return (
DepartmentEnrollmentHistory.termShortNames.indexOf(aTerm) -
DepartmentEnrollmentHistory.termShortNames.indexOf(bTerm)
DepartmentEnrollmentHistory.termShortNames.indexOf(bTerm) -
DepartmentEnrollmentHistory.termShortNames.indexOf(aTerm)
);
});
}
Expand Down

0 comments on commit 5adfc89

Please sign in to comment.