Skip to content

Commit

Permalink
almost working
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcarvajal committed Feb 19, 2025
1 parent 52c5688 commit 18d1381
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions packages/frontend/components/AddCourseModal/AddCourseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const AddCourseModal: React.FC<AddCourseModalProps> = ({
};

const [courseCoreqsMap, setCourseCoreqsMap] = useState(
new Map<any, ScheduleCourse2<null>[]>()
new Map<any, ScheduleCourse2<null>>()
);
useEffect(() => {
if (!courses || courses.length === 0 || isCourseSearchLoading) {
Expand All @@ -135,17 +135,17 @@ export const AddCourseModal: React.FC<AddCourseModalProps> = ({
const fetchCoreqsForAllCourses = async () => {
if (!courses || courses.length === 0) return;
if (courses) {
const newCourseCoreqsMap = new Map<any, ScheduleCourse2<null>[]>();
const newCourseCoreqsMap = new Map<any, ScheduleCourse2<null>>();

for (const course of courses) {
const coreqs = (
await getRequiredCourseCoreqs(course, catalogYear)
).filter(
(coreq) => !isCourseAlreadyAdded(coreq) && course.numCreditsMax >= 4
(coreq) => !isCourseAlreadyAdded(coreq) && course.numCreditsMax >= 3 // this is hardcoded and for some reason its 3?
);

if (coreqs.length === 1) {
newCourseCoreqsMap.set(getCourseDisplayString(course), coreqs);
newCourseCoreqsMap.set(getCourseDisplayString(course), coreqs[0]);
console.log(
`Fetching coreqs for course ${getCourseDisplayString(course)}`
);
Expand Down Expand Up @@ -285,7 +285,28 @@ export const AddCourseModal: React.FC<AddCourseModalProps> = ({
/>
{courseCoreqsMap.has(
getCourseDisplayString(course)
) && <Text color="red">hi</Text>}
) && (
<SearchResult
key={getCourseDisplayString(course) + "coreq"}
year={catalogYear}
season={season}
course={
courseCoreqsMap.get(

Check warning on line 294 in packages/frontend/components/AddCourseModal/AddCourseModal.tsx

View workflow job for this annotation

GitHub Actions / Run linting for all packages

Forbidden non-null assertion
getCourseDisplayString(course)
)!
}
addSelectedCourse={addSelectedCourse}
isResultAlreadyAdded={isCourseAlreadyAdded(
course
)}
isResultAlreadySelected={isCourseAlreadySelected(
course
)}
isSelectingAnotherCourse={isLoadingSelectCourse}
selectedNUPaths={selectedNUPaths}
coreq={false}
/>
)}
</>
)
)}
Expand Down

0 comments on commit 18d1381

Please sign in to comment.