Skip to content

Commit

Permalink
Merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Awesome-E committed Nov 17, 2024
1 parent 47382ef commit 8c57df7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion site/src/component/SearchModule/SearchModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const SearchModule: FC<SearchModuleProps> = ({ index }) => {
if (location.pathname === '/roadmap') {
dispatch(setShowCourseBag(!query));
}
if (query) {
if (query && query !== search.query) {
dispatch(setQuery({ index, query }));
setPendingRequest(null);
}
Expand Down
6 changes: 6 additions & 0 deletions site/src/pages/RoadmapPage/SearchSidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
flex-direction: column;
height: 100%;
overflow: auto;
gap: 8px;
margin-top: 8px;
}

&.mobile {
Expand Down Expand Up @@ -51,6 +53,10 @@
font-weight: 600;
@include clickable(0.9, 0.7);
}

.coursebag-title {
margin: 12px 6px 0;
}
}

.search {
Expand Down
26 changes: 18 additions & 8 deletions site/src/pages/RoadmapPage/SearchSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useCoursebag } from '../../hooks/coursebag';
import { CourseGQLData } from '../../types/types';
import Course from './Course';
import { courseSearchSortable } from '../../helpers/sortable';
import { Spinner } from 'react-bootstrap';

const CloseRoadmapSearchButton = () => {
const isMobile = useIsMobile();
Expand Down Expand Up @@ -46,7 +47,7 @@ const SearchSidebar = () => {
const dispatch = useAppDispatch();

const { coursebag } = useCoursebag();
const results = useAppSelector((state) => state.search.courses.results);
const { results, searchInProgress } = useAppSelector((state) => state.search.courses);
const shownCourses = JSON.parse(JSON.stringify(showCourseBag ? coursebag : results)) as CourseGQLData[];

const closeSearch = () => dispatch(setShowSearch({ show: false }));
Expand All @@ -62,20 +63,29 @@ const SearchSidebar = () => {
dispatch(setActiveCourse(course));
};

const coursebagTitle = coursebag.length ? (
<h3 className="coursebag-title">Saved Courses</h3>
) : (
<p className="coursebag-title">No courses saved. Try searching for something!</p>
);

return (
<>
{isMobile && showSearch && <UIOverlay onClick={closeSearch} zIndex={449} passedRef={overlayRef} />}
<div className={`search-sidebar ${isMobile ? 'mobile' : ''}`} ref={sidebarRef}>
<div className="search-sidebar-search-module">
<SearchModule index="courses" />
</div>
<div className="search-body">
<ReactSortable {...courseSearchSortable} list={shownCourses} onStart={setDraggedItem}>
{shownCourses.map((course, i) => (
<Course {...course} key={i} />
))}
</ReactSortable>
</div>
{showCourseBag && coursebagTitle}
<ReactSortable {...courseSearchSortable} list={shownCourses} onStart={setDraggedItem} className="search-body">
{searchInProgress ? (
<div className="no-results">
<Spinner animation="border" role="status" />
</div>
) : (
shownCourses.map((course, i) => <Course {...course} key={i} />)
)}
</ReactSortable>
<CloseRoadmapSearchButton />
</div>
</>
Expand Down
2 changes: 1 addition & 1 deletion site/src/store/slices/roadmapSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const initialSliceState: RoadmapSliceState = {
showAddCourse: false,
showTransfer: false,
transfers: [],
showCourseBag: false,
showCourseBag: true,
};
/** added for multiple planner */

Expand Down

0 comments on commit 8c57df7

Please sign in to comment.