Skip to content

Commit

Permalink
Correct display of "not offered next academic year" tooltip (#51)
Browse files Browse the repository at this point in the history
Replace the hardcoded "not offered 2021-2022" message with one based on
the current academic term.

Fixes #44.
  • Loading branch information
SamZhang3 authored Sep 16, 2023
1 parent 38a5a1f commit 5dfc22a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/ActivityDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function TypeSpan(props: { flag?: string; title: string }) {
}

/** Header for class description; contains flags and related classes. */
function ClassTypes(props: { cls: Class }) {
const { cls } = props;
function ClassTypes(props: { cls: Class, state: State }) {
const { cls, state } = props;
const { flags, totalUnits, units } = cls;

/**
Expand All @@ -58,9 +58,13 @@ function ClassTypes(props: { cls: Class }) {
.map(([flag, title]) => (
<TypeSpan key={flag} flag={flag} title={title} />
));

const currentYear = parseInt(state.term.fullRealYear);
const nextAcademicYearStart = state.term.semester === "f" ? currentYear + 1 : currentYear;
const nextAcademicYearEnd = nextAcademicYearStart + 1;

const types1 = makeFlags([
["nonext", "Not offered 2021-2022"],
["nonext", `Not offered ${nextAcademicYearStart}-${nextAcademicYearEnd}`],
["under", "Undergrad"],
["grad", "Graduate"],
]);
Expand Down Expand Up @@ -179,7 +183,7 @@ function ClassDescription(props: { cls: Class; state: State }) {
{cls.number}: {cls.name}
</Heading>
<Flex direction="column" gap={0.5}>
<ClassTypes cls={cls} />
<ClassTypes cls={cls} state={state} />
<ClassRelated cls={cls} state={state} />
<ClassEval cls={cls} />
</Flex>
Expand Down

0 comments on commit 5dfc22a

Please sign in to comment.