Skip to content

Commit

Permalink
fix: summer courses will now appear in grade (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustChew authored Apr 15, 2024
2 parents 8a821ae + 1011483 commit f859cf3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/[lang]/(mods-pages)/student/grades/GradesViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ const GradesViewer = ({ grades }: { grades: GradeObject }) => {

// get unique semesters
const semesters = Array.from(new Set(grades.ranking.data.map(grade => grade.year + grade.semester))).toReversed();

// grades might have semesters that are not in ranking
const gradesSemesters = Array.from(new Set(grades.grades.map(grade => grade.year + grade.semester))).toReversed();
const displayGrades = grades.grades.filter(grade => {
if (selectedSemester == "All") return semesters.includes(grade.year + grade.semester);
if (selectedSemester == "All") return true;
return grade.year + grade.semester == selectedSemester;
});

const displayedSemesters = semesters.filter(semester => {
const displayedSemesters = gradesSemesters.filter(semester => {
if (selectedSemester == "All") return true;
return semester == selectedSemester;
});
Expand Down Expand Up @@ -175,7 +176,7 @@ const GradesViewer = ({ grades }: { grades: GradeObject }) => {
</SelectTrigger>
<SelectContent >
<SelectItem value={"All"}>全部課程</SelectItem>
{semesters.map(sem_id => <SelectItem key={sem_id} value={sem_id}>{toPrettySemester(sem_id)}</SelectItem>)}
{gradesSemesters.map(sem_id => <SelectItem key={sem_id} value={sem_id}>{toPrettySemester(sem_id)}</SelectItem>)}
</SelectContent>
</Select>}
{tab == "semester" && <Select value={semesterSort} onValueChange={(e: string) => setSemesterSort(e as "asc" | "desc")}>
Expand Down

0 comments on commit f859cf3

Please sign in to comment.