Skip to content

Commit be50e04

Browse files
authored
Merge pull request #47 from Cwooper/bug/search-term
Fixed empty term request on first load
2 parents 44508ec + 3289545 commit be50e04

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

frontend/src/components/SearchView.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ export function SearchView() {
6161
const closeCourseDialog = useAppStore((s) => s.closeCourseDialog)
6262

6363
const { data: termsData } = useTerms()
64+
65+
// Sync current term into store on first load so the displayed value matches
66+
// what gets sent to the backend (fixes empty term on initial search)
67+
useEffect(() => {
68+
if (termsData?.current && !searchFilters.term) {
69+
setSearchFilters({ term: termsData.current })
70+
}
71+
}, [termsData?.current, searchFilters.term, setSearchFilters])
72+
6473
const termForSubjects = searchFilters.term || termsData?.current || ""
6574
const { data: subjectsData } = useSubjects(termForSubjects)
6675

0 commit comments

Comments
 (0)