Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions my-app/src/presenters/SearchbarPresenter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ const SearchbarPresenter = observer(({ model }) => {
model.removeFavourite(course);
}

function removeAllFavourites(){
model.setFavourite([]);
}

return (
<SearchbarView
model={model}
searchCourses={searchCourses}
favouriteCourses = {model.favourites}
removeFavourite={removeFavourite}
removeAllFavourites={removeAllFavourites}
/>
);
});
Expand Down
36 changes: 20 additions & 16 deletions my-app/src/views/Components/FavouriteDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@ function FavouritesDropdown(props) {
return (
<div className="absolute mt-2 w-48 bg-white border border-solid border-black rounded-lg z-50 overflow-y-auto">
{props.favouriteCourses.length > 0 ? (
props.favouriteCourses.map(course => (
<div
key={course.code}
className="p-2 flex justify-between items-center w-full border border-solid border-black">
<p
className="text-black">
{course.name}
</p>
<button
className="text-red-500 cursor-pointer"
onClick={() => props.removeFavourite(course)}>
X
</button>
</div>
))
) : (

props.favouriteCourses.map(course => (
<div
key={course.code}
className="p-2 flex justify-between items-center w-full border border-solid border-black">
<p
className="text-black">
{course.name}
</p>
<button
className="text-red-500 cursor-pointer"
onClick={() => props.removeFavourite(course)}>
X
</button>
</div>
))


) : (
<div className="p-2 text-[#000061]">
No favourites
</div>
)}
{props.favouriteCourses.length > 0 ? <button onClick={props.removeAllFavourites}>Clear Favourites</button> : ""}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions my-app/src/views/SearchbarView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function SearchbarView(props) {
courses={props.courses}
favouriteCourses={props.favouriteCourses}
removeFavourite={props.removeFavourite}
removeAllFavourites={props.removeAllFavourites}
/>
)}
</div>
Expand Down