-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Anne-onboarding1
- (#798, #760)
- feat/cicd-actions-consts
- (#760)
- feat/schedules
- (#762, #760)
- gql
- (#760)
- gql-about
- (#776, #760)
- gql-courses-pins
- (#774, #760)
- gql-grades
- (#779, #760)
- migrations/schedules-enrollment
- (#760)
- origin/feat/staff-dashboard-oauth-infra
- (#780, #760)
- rachel
- (#799, #760)
- rachel2
- (#800, #760)
- suggested-classes
- (#760)
Showing
14 changed files
with
225 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useMemo } from "react"; | ||
|
||
import { ArrowRight } from "iconoir-react"; | ||
|
||
import AverageGrade from "@/components/AverageGrade"; | ||
import Capacity from "@/components/Capacity"; | ||
import Units from "@/components/Units"; | ||
import { useReadClass } from "@/hooks/api"; | ||
import { Semester } from "@/lib/api"; | ||
|
||
import ClassDrawer from "../../ClassDrawer"; | ||
import styles from "./Class.module.scss"; | ||
|
||
interface ClassProps { | ||
year: number; | ||
semester: Semester; | ||
subject: string; | ||
courseNumber: string; | ||
number: string; | ||
} | ||
|
||
export default function Class({ | ||
year, | ||
semester, | ||
subject, | ||
courseNumber, | ||
number, | ||
}: ClassProps) { | ||
const { data, loading } = useReadClass( | ||
year as number, | ||
semester as Semester, | ||
subject as string, | ||
courseNumber as string, | ||
number as string | ||
); | ||
|
||
const _class = useMemo(() => data, [data]); | ||
|
||
return loading || !_class ? ( | ||
<></> | ||
) : ( | ||
<ClassDrawer | ||
year={year} | ||
semester={semester} | ||
subject={subject} | ||
courseNumber={courseNumber} | ||
number={number} | ||
> | ||
<div className={styles.root}> | ||
<div className={styles.text}> | ||
<p className={styles.heading}> | ||
{_class.subject} {_class.courseNumber} #{_class.number} | ||
</p> | ||
<p className={styles.description}> | ||
{_class.title ?? _class.course.title} | ||
</p> | ||
<div className={styles.row}> | ||
<AverageGrade gradeDistribution={_class.gradeDistribution} /> | ||
<Capacity | ||
enrollCount={_class.primarySection.enrollCount} | ||
enrollMax={_class.primarySection.enrollMax} | ||
waitlistCount={_class.primarySection.waitlistCount} | ||
waitlistMax={_class.primarySection.waitlistMax} | ||
/> | ||
<Units unitsMin={_class.unitsMin} unitsMax={_class.unitsMax} /> | ||
</div> | ||
</div> | ||
<div className={styles.column}> | ||
<div className={styles.icon}> | ||
<ArrowRight /> | ||
</div> | ||
</div> | ||
</div> | ||
</ClassDrawer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Semester } from "./api"; | ||
|
||
interface RecentClassData { | ||
subject: string; | ||
year: number; | ||
semester: Semester; | ||
courseNumber: string; | ||
number: string; | ||
} | ||
|
||
const RECENT_CLASSES_KEY = "recent-classes"; | ||
|
||
const RECENT_CLASSES_MAX_LENGTH = 10; | ||
|
||
export function addRecentClass({ | ||
subject, | ||
year, | ||
semester, | ||
courseNumber, | ||
number, | ||
}: RecentClassData) { | ||
let recentClasses = getRecentClasses(); | ||
|
||
recentClasses = recentClasses.filter( | ||
(recentClass) => | ||
!( | ||
subject == recentClass.subject && | ||
year == recentClass.year && | ||
semester == recentClass.semester && | ||
courseNumber == recentClass.courseNumber && | ||
number == recentClass.number | ||
) | ||
); | ||
|
||
recentClasses.unshift({ | ||
subject: subject, | ||
year: year, | ||
semester: semester, | ||
courseNumber: courseNumber, | ||
number: number, | ||
}); | ||
|
||
recentClasses = recentClasses.slice(0, RECENT_CLASSES_MAX_LENGTH); | ||
|
||
const item = JSON.stringify(recentClasses); | ||
localStorage.setItem(RECENT_CLASSES_KEY, item); | ||
} | ||
|
||
export function getRecentClasses() { | ||
try { | ||
const item = localStorage.getItem(RECENT_CLASSES_KEY); | ||
if (!item) return []; | ||
|
||
return JSON.parse(item) as RecentClassData[]; | ||
} catch { | ||
return []; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters