diff --git a/client/public/surprised_bear.svg b/client/public/surprised_bear.svg new file mode 100644 index 00000000..ee1c59a3 --- /dev/null +++ b/client/public/surprised_bear.svg @@ -0,0 +1,69 @@ + diff --git a/client/src/modules/Results/Components/PreviewCard.tsx b/client/src/modules/Results/Components/PreviewCard.tsx index 4b438ac3..fb8dcd7c 100644 --- a/client/src/modules/Results/Components/PreviewCard.tsx +++ b/client/src/modules/Results/Components/PreviewCard.tsx @@ -9,6 +9,8 @@ import ReviewCard from '../../Course/Components/ReviewCard'; import styles from '../Styles/CoursePreview.module.css'; import { Class } from 'common'; +import Bear from '/surprised_bear.svg'; + const Review = ReviewCard; export const PreviewCard = ({ course }: PreviewCardProps) => { @@ -21,12 +23,12 @@ export const PreviewCard = ({ course }: PreviewCardProps) => { const [topReviewLikes, setTopReviewLikes] = useState(0); useEffect(() => { - updateGauges(); + if (course) { + updateGauges(); + } }, [course]); const updateGauges = () => { - if (!course) return; - setId(course._id); setRating(course.classRating ? String(course.classRating) : '-'); setDiff(course.classDifficulty ? String(course.classDifficulty) : '-'); @@ -35,10 +37,8 @@ export const PreviewCard = ({ course }: PreviewCardProps) => { }; const updateTopReview = () => { - if (!id) return; - axios - .post(`/api/courses/get-reviews`, { courseId: id }) + .post(`/api/courses/get-reviews`, { courseId: course._id }) .then((response) => { const reviews = response.data.result; if (reviews && reviews.length > 0) { @@ -62,15 +62,21 @@ export const PreviewCard = ({ course }: PreviewCardProps) => { const offered = lastOfferedSems(course); return ( -