diff --git a/site/src/component/PrereqTree/PrereqTree.tsx b/site/src/component/PrereqTree/PrereqTree.tsx index d0d1ad8f..28ce2f10 100644 --- a/site/src/component/PrereqTree/PrereqTree.tsx +++ b/site/src/component/PrereqTree/PrereqTree.tsx @@ -4,6 +4,7 @@ import { Grid, Popup } from 'semantic-ui-react'; import type { Prerequisite, PrerequisiteTree } from 'peterportal-api-next-types'; import { CourseGQLData, CourseLookup } from '../../types/types'; +import { Link } from 'react-router-dom'; interface NodeProps { node: string; @@ -26,14 +27,14 @@ const Node: FC = (props) => { {props.label} - + ) : ( ) diff --git a/site/src/component/Review/SubReview.tsx b/site/src/component/Review/SubReview.tsx index 0cb985f2..4bcb9e6a 100644 --- a/site/src/component/Review/SubReview.tsx +++ b/site/src/component/Review/SubReview.tsx @@ -95,12 +95,12 @@ const SubReview: FC = ({ review, course, professor, colors, colo

{professor && ( - {professor.courses[review.courseID].department + ' ' + professor.courses[review.courseID].courseNumber} + {professor.courses[review.courseID]?.department + ' ' + professor.courses[review.courseID]?.courseNumber} )} {course && ( - {Object.values(course.instructors)?.find(({ ucinetid }) => ucinetid === review.professorID)?.name} + {course.instructors[review.professorID]?.name} )} {!course && !professor && ( diff --git a/site/src/component/SearchPopup/SearchPopup.tsx b/site/src/component/SearchPopup/SearchPopup.tsx index ac1a6bae..403fac09 100644 --- a/site/src/component/SearchPopup/SearchPopup.tsx +++ b/site/src/component/SearchPopup/SearchPopup.tsx @@ -8,6 +8,7 @@ import searching from '../../asset/searching.webp'; import { useAppSelector } from '../../store/hooks'; import { selectCourse, selectProfessor } from '../../store/slices/popupSlice'; import { CourseGQLData, ProfessorGQLData, SearchType, ScoreData } from '../../types/types'; +import { Link } from 'react-router-dom'; interface InfoData { title: string; @@ -75,11 +76,11 @@ const SearchPopupContent: FC = (props) => {

{props.name} - + - +

{props.title}
@@ -110,7 +111,9 @@ const SearchPopupContent: FC = (props) => { {score.score == -1 ? '?' : score.score} / 5.0 - {score.name} + + {score.name} + ))} diff --git a/site/src/pages/CoursePage/index.tsx b/site/src/pages/CoursePage/index.tsx index d6ff0567..bcda4c3a 100644 --- a/site/src/pages/CoursePage/index.tsx +++ b/site/src/pages/CoursePage/index.tsx @@ -24,18 +24,17 @@ const CoursePage: FC = () => { const [error, setError] = useState(''); useEffect(() => { - // make a gql query if directly landed on this page - if (id !== undefined && (courseGQLData == null || courseGQLData.id != id)) { + if (id !== undefined) { searchAPIResult('course', id).then((course) => { - console.log('COURSE', course); if (course) { dispatch(setCourse(course as CourseGQLData)); + setError(''); } else { setError(`Course ${id} does not exist!`); } }); } - }, []); + }, [dispatch, id]); // if course does not exists if (error) { @@ -65,7 +64,7 @@ const CoursePage: FC = () => {

🌲 Prerequisite Tree

- +
@@ -73,7 +72,7 @@ const CoursePage: FC = () => {

🗓️ Schedule of Classes

- +
@@ -89,7 +88,7 @@ const CoursePage: FC = () => {

💬 Reviews

- + diff --git a/site/src/pages/ProfessorPage/index.tsx b/site/src/pages/ProfessorPage/index.tsx index 46e8aa7c..f2b612cc 100644 --- a/site/src/pages/ProfessorPage/index.tsx +++ b/site/src/pages/ProfessorPage/index.tsx @@ -22,17 +22,17 @@ const ProfessorPage: FC = () => { const [error, setError] = useState(''); useEffect(() => { - // make a gql query if directly landed on this page - if (id !== undefined && (professorGQLData == null || professorGQLData.ucinetid != id)) { + if (id !== undefined) { searchAPIResult('professor', id).then((professor) => { if (professor) { dispatch(setProfessor(professor as ProfessorGQLData)); + setError(''); } else { setError(`Professor ${id} does not exist!`); } }); } - }, []); + }, [dispatch, id]); // if professor does not exists if (error) { diff --git a/site/src/pages/RoadmapPage/Course.tsx b/site/src/pages/RoadmapPage/Course.tsx index 0ecb7abf..76ed3a71 100644 --- a/site/src/pages/RoadmapPage/Course.tsx +++ b/site/src/pages/RoadmapPage/Course.tsx @@ -66,15 +66,13 @@ const Course: FC = (props) => { ); - const courseRoute = () => { - return '/course/' + props.department.replace(/\s+/g, '') + props.courseNumber.replace(/\s+/g, ''); - }; + const courseRoute = '/course/' + props.department.replace(/\s+/g, '') + props.courseNumber.replace(/\s+/g, ''); return (
- + {department + ' ' + courseNumber} diff --git a/site/src/pages/SearchPage/ProfessorHitItem.tsx b/site/src/pages/SearchPage/ProfessorHitItem.tsx index f5a03930..5434fbbe 100644 --- a/site/src/pages/SearchPage/ProfessorHitItem.tsx +++ b/site/src/pages/SearchPage/ProfessorHitItem.tsx @@ -1,6 +1,6 @@ import { FC } from 'react'; import './HitItem.scss'; -import { useNavigate } from 'react-router-dom'; +import { Link, useNavigate } from 'react-router-dom'; import { useAppDispatch, useAppSelector } from '../../store/hooks'; import { setProfessor } from '../../store/slices/popupSlice'; @@ -65,7 +65,7 @@ const ProfessorHitItem: FC = (props: ProfessorHitItemProp return ( {index ? ', ' : ''} - {item} + {item} ); })}