1- import React , { useEffect , useRef } from 'react'
1+ import React , { useEffect , useRef } from 'react' ;
22
3- function CoursePagePopup ( { favouriteCourses, addFavourite,
4- removeFavourite, isOpen, onClose, course, prerequisiteTree } ) {
3+ function CoursePagePopup ( {
4+ favouriteCourses,
5+ addFavourite,
6+ removeFavourite,
7+ handleFavouriteClick,
8+ isOpen,
9+ onClose,
10+ course,
11+ prerequisiteTree
12+ } ) {
513 const treeRef = useRef ( null ) ;
14+
615 useEffect ( ( ) => {
716 const handleKeyDown = ( event ) => {
817 if ( event . key === 'Escape' ) {
@@ -19,22 +28,14 @@ function CoursePagePopup({ favouriteCourses, addFavourite,
1928 } ;
2029 } , [ isOpen , onClose ] ) ;
2130
22-
23- const handleFavouriteClick = ( course ) => {
24- if ( favouriteCourses . some ( fav => fav . code === course . code ) ) {
25- removeFavourite ( course ) ;
26- } else {
27- addFavourite ( course ) ;
28- }
29- } ;
30-
3131 const handleTreeClick = ( ) => {
3232 if ( treeRef . current ) {
3333 treeRef . current . focus ( ) ; // gives it focus
3434 }
3535 } ;
3636
3737 if ( ! isOpen || ! course ) return null ; // Don't render if not open or course not selected
38+
3839 return (
3940 < div
4041 className = "fixed backdrop-blur-sm inset-0 bg-transparent flex justify-end z-50"
@@ -58,13 +59,14 @@ function CoursePagePopup({ favouriteCourses, addFavourite,
5859 </ div >
5960 < div >
6061 < button
61- className = "text-yellow-500 bg-yellow-400 cursor-pointer"
62+ className = "text-yellow-100 bg-yellow-400 cursor-pointer"
6263 onClick = { ( e ) => {
6364 e . stopPropagation ( ) ; // prevent popup from opening
64- handleFavouriteClick ( course . code ) ;
65+ // Pass the full course object now instead of course.code:
66+ handleFavouriteClick ( course ) ;
6567 } }
6668 >
67- { favouriteCourses . includes ( course . code )
69+ { favouriteCourses . some ( fav => fav . code === course . code )
6870 ? 'Remove from Favourites'
6971 : 'Add to Favourites' }
7072 </ button >
@@ -78,7 +80,6 @@ function CoursePagePopup({ favouriteCourses, addFavourite,
7880 className = "text-lg leading-8 text-[#2e2e4f] font-semibold tracking-wide prose prose-slate max-w-full"
7981 dangerouslySetInnerHTML = { { __html : course . description } }
8082 />
81-
8283 </ div >
8384
8485 { /* Prerequisite Graph Tree Section */ }
@@ -95,15 +96,16 @@ function CoursePagePopup({ favouriteCourses, addFavourite,
9596 >
9697 { prerequisiteTree }
9798 </ div >
98-
9999 </ div >
100+
100101 { /* Reviews Section */ }
101102 < div >
102103 < h3 className = "text-2xl font-semibold text-[#2e2e4f] mb-0.5" > Reviews</ h3 >
103104 < div className = "mb-4 h-0.5 w-full bg-violet-500" > </ div >
104- < p className = "text-lg text-slate-700 leading-7" > Here would be some reviews of the course...</ p >
105+ < p className = "text-lg text-slate-700 leading-7" >
106+ Here would be some reviews of the course...
107+ </ p >
105108 </ div >
106-
107109 </ div >
108110 </ div >
109111 < button
0 commit comments