diff --git a/site/src/component/SearchHitContainer/SearchHitContainer.tsx b/site/src/component/SearchHitContainer/SearchHitContainer.tsx index d45ed1f6..5ff94efa 100644 --- a/site/src/component/SearchHitContainer/SearchHitContainer.tsx +++ b/site/src/component/SearchHitContainer/SearchHitContainer.tsx @@ -7,12 +7,13 @@ import { SearchIndex, CourseGQLData, ProfessorGQLData } from '../../types/types' import SearchPagination from '../SearchPagination/SearchPagination'; import noResultsImg from '../../asset/no-results-crop.webp'; import { useFirstRender } from '../../hooks/firstRenderer'; +import { validateCourse } from '../../helpers/planner'; // TODO: CourseHitItem and ProfessorHitem should not need index // investigate: see if you can refactor respective components to use course id/ucinetid for keys instead then remove index from props interface SearchHitContainerProps { index: SearchIndex; - CourseHitItem: FC; + CourseHitItem: FC; ProfessorHitItem?: FC; } @@ -22,8 +23,21 @@ const SearchResults = ({ CourseHitItem, ProfessorHitItem, }: Required & { results: CourseGQLData[] | ProfessorGQLData[] }) => { + const roadmap = useAppSelector((state) => state.roadmap); + const allExistingCourses = roadmap?.plans[roadmap.currentPlanIndex].content.yearPlans.flatMap((yearPlan) => + yearPlan.quarters.flatMap((quarter) => + quarter.courses.map((course) => course.department + ' ' + course.courseNumber), + ), + ); if (index === 'courses') { - return (results as CourseGQLData[]).map((course, i) => ); + return (results as CourseGQLData[]).map((course, i) => { + const requiredCourses = Array.from( + validateCourse(new Set(allExistingCourses), course.prerequisiteTree, new Set(), course.corequisites), + ); + return ( + 0 && { requiredCourses })} /> + ); + }); } else { return (results as ProfessorGQLData[]).map((professor, i) => ( diff --git a/site/src/pages/RoadmapPage/Course.tsx b/site/src/pages/RoadmapPage/Course.tsx index 8f8178f9..7bc5142a 100644 --- a/site/src/pages/RoadmapPage/Course.tsx +++ b/site/src/pages/RoadmapPage/Course.tsx @@ -11,6 +11,7 @@ import ThemeContext from '../../style/theme-context'; interface CourseProps extends CourseGQLData { requiredCourses?: string[]; + unmatchedPrerequisites?: string[]; onDelete?: () => void; } @@ -29,7 +30,6 @@ const Course: FC = (props) => { terms, onDelete, } = props; - const CoursePopover = ( @@ -81,7 +81,7 @@ const Course: FC = (props) => { , {minUnits === maxUnits ? minUnits : `${minUnits}-${maxUnits}`} units - + {requiredCourses && (