Skip to content

Commit

Permalink
fix: UNI-278 add else branch in getInitialDisplayCourses to reset sea…
Browse files Browse the repository at this point in the history
…rch bar state (#284)
  • Loading branch information
adrianbalbs authored May 9, 2024
1 parent 7f46ee3 commit ca55f1d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/src/components/CoursesList/CoursesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function CoursesList({
// default courses
try {
const { courses } = (await get(
`/courses?offset=${index}`
`/courses?offset=${index}`,
)) as Courses;
fetchedCourses = courses;
} catch (err) {
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function CoursesList({
const getSearchResults = async () => {
try {
const { courses } = (await get(
`/course/search/${searchTerm}`
`/course/search/${searchTerm}`,
)) as Courses;
searchCoursesRef.current = courses;
} catch (err) {
Expand All @@ -84,6 +84,9 @@ export default function CoursesList({
const getInitialDisplayCourses = () => {
if (searchTerm !== "") {
getSearchResults();
} else {
setDisplayCourses(initialCourses.slice(0, paginationOffset));
setInitialLoading(false);
}
};
const loadOnScroll = () => {
Expand Down Expand Up @@ -119,7 +122,7 @@ export default function CoursesList({
terms={c.terms}
/>
</a>
)
),
)}
{!initialLoading ? (
<p className="text-center opacity-50">No more courses</p>
Expand Down

0 comments on commit ca55f1d

Please sign in to comment.