diff --git a/frontend/src/SearchResults.tsx b/frontend/src/SearchResults.tsx index 9fdc41b..55d95e8 100644 --- a/frontend/src/SearchResults.tsx +++ b/frontend/src/SearchResults.tsx @@ -41,7 +41,6 @@ const fetchSearchDetails = async ( }; const searchQueryOptions = (deps: Record) => { - console.log(deps); for (const key of Object.keys(deps)) { if (deps[key] === undefined) delete deps[key]; } @@ -152,7 +151,7 @@ function SearchResults() {

- Page {(deps.page as number ?? 0) + 1} + Page {((deps.page as number) ?? 0) + 1}

diff --git a/frontend/src/components/SearchBar.tsx b/frontend/src/components/SearchBar.tsx index 14ce0ff..f14b648 100644 --- a/frontend/src/components/SearchBar.tsx +++ b/frontend/src/components/SearchBar.tsx @@ -12,12 +12,14 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Input } from "@/components/ui/input"; +import { useLocation } from "@tanstack/react-router"; import { ChevronDown, Search } from "lucide-react"; const SearchBar = () => { const [query, setQuery] = useState(); const [year, setYear] = useState(); const [semester, setSemester] = useState(); + const location = useLocation(); const handleSearch = async ( query: string | undefined, @@ -30,11 +32,15 @@ const SearchBar = () => { if (searchString.endsWith("&") || searchString.endsWith("?")) searchString = searchString.substring(0, searchString.length - 1); - router.navigate({ to: "/" }); - setTimeout( - () => router.navigate({ to: `/search${searchString}`, replace: true }), - 100, - ); + if (location.pathname === "/search") { + router.navigate({ to: "/" }); + setTimeout( + () => router.navigate({ to: `/search${searchString}`, replace: true }), + 100, + ); + } else { + router.navigate({ to: `/search${searchString}` }); + } }; return (