Skip to content

Commit

Permalink
attempt at making things compile (not quite working)
Browse files Browse the repository at this point in the history
  • Loading branch information
PineND committed Dec 5, 2024
1 parent 01aa953 commit 27a908a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 34 deletions.
3 changes: 2 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
"@radix-ui/react-tooltip": "^1.1.4",
"@repo/theme": "*",
"@repo/shared": "*",
"@repo/theme": "*",
"@shopify/draggable": "^1.1.3",
"@tanstack/react-virtual": "^3.10.9",
"classnames": "^2.5.1",
Expand All @@ -42,6 +42,7 @@
"devDependencies": {
"@repo/eslint-config": "*",
"@repo/typescript-config": "*",
"@types/lodash": "^4.17.13",
"@types/mapbox-gl": "^3.4.1",
"@types/node": "^22.9.1",
"@types/react": "^18.3.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ const isSemester = (value: string): boolean => {
return Object.values(Semester).includes(firstWord as Semester);
};

interface Term {
semester: Semester;
year: number;
value: string;
label: string;
}

export function RatingsContainer() {
const [isModalOpen, setIsModalOpen] = useState(false);
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
Expand Down Expand Up @@ -263,7 +270,7 @@ export function RatingsContainer() {
<ReactSelect
options={[
{ value: "all", label: "Overall Ratings" },
...availableTerms.filter((term) => {
...availableTerms.filter((term: Term) => {
// Filter for past terms
const termPosition = termsData?.find(
(t) =>
Expand Down
72 changes: 40 additions & 32 deletions apps/frontend/src/components/Detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,37 @@ import styles from "./Detail.module.scss";
import MyIcon2 from "./attended.svg";
import MyIcon1 from "./recorded.svg";

interface AttendanceRequirementsProps {
attendanceRequired: boolean | null;
lecturesRecorded: boolean | null;
submissionAmount?: number; // Optional prop with default value
interface Props {
attendanceRequired?: boolean;
lecturesRecorded?: boolean;
submissionAmount?: number;
}

interface ClassInfo {
semester: string;
year: number;
}

interface TermInfo {
semester: Semester;
year: number;
value: string;
label: string;
}

interface UserClass {
subject: string;
courseNumber: string;
semester: Semester;
year: number;
classNumber: string;
}

export default function AttendanceRequirements({
attendanceRequired,
lecturesRecorded,
submissionAmount = 0, // Default value set to 0
}: AttendanceRequirementsProps) {
attendanceRequired = false,
lecturesRecorded = false,
submissionAmount = 0,
}: Props) {
const [isModalOpen, setModalOpen] = useState(false);
const { class: currentClass } = useClass();
const { data: user } = useReadUser();
Expand Down Expand Up @@ -80,32 +100,32 @@ export default function AttendanceRequirements({
};

const availableTerms = React.useMemo(() => {
if (!courseData?.course?.classes) return [];
if (!courseData?.course?.classes) return [] as TermInfo[];

return _.chain(courseData.course.classes)
.map((classInfo) => ({
return _.chain(courseData.course.classes as ClassInfo[])
.map((classInfo: ClassInfo): TermInfo => ({
value: `${classInfo.semester} ${classInfo.year}`,
label: `${classInfo.semester} ${classInfo.year}`,
semester: classInfo.semester as Semester,
year: classInfo.year,
}))
.uniqBy((term) => `${term.semester}-${term.year}`)
.uniqBy((term: TermInfo) => `${term.semester}-${term.year}`)
.orderBy(
[
"year",
(term) => {
'year',
(term: TermInfo) => {
const semesterOrder = {
[Semester.Spring]: 0,
[Semester.Summer]: 1,
[Semester.Fall]: 2,
[Semester.Winter]: 3,
};
return semesterOrder[term.semester as Semester];
return semesterOrder[term.semester];
},
],
["desc", "asc"]
] as const,
['desc', 'asc']
)
.value();
.value() as TermInfo[];
}, [courseData]);
if (submissionAmount < 5) {
return (
Expand All @@ -132,13 +152,7 @@ export default function AttendanceRequirements({
availableTerms={availableTerms}
onSubmit={handleSubmitRatings}
initialUserClass={userRatingsData?.userRatings?.classes?.find(
(c: {
subject: string;
courseNumber: string;
semester: Semester;
year: number;
classNumber: string;
}) =>
(c: UserClass) =>
c.subject === currentClass.subject &&
c.courseNumber === currentClass.courseNumber &&
c.semester === currentClass.semester &&
Expand Down Expand Up @@ -195,13 +209,7 @@ export default function AttendanceRequirements({
availableTerms={availableTerms}
onSubmit={handleSubmitRatings}
initialUserClass={userRatingsData?.userRatings?.classes?.find(
(c: {
subject: string;
courseNumber: string;
semester: Semester;
year: number;
classNumber: string;
}) =>
(c: UserClass) =>
c.subject === currentClass.subject &&
c.courseNumber === currentClass.courseNumber &&
c.semester === currentClass.semester &&
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 27a908a

Please sign in to comment.