Skip to content

Commit

Permalink
fix: make very bad ugly fix less bad
Browse files Browse the repository at this point in the history
  • Loading branch information
skoriop committed Jul 30, 2024
1 parent de744bd commit da69b6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions frontend/src/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const fetchSearchDetails = async (
};

const searchQueryOptions = (deps: Record<string, any>) => {
console.log(deps);
for (const key of Object.keys(deps)) {
if (deps[key] === undefined) delete deps[key];
}
Expand Down Expand Up @@ -152,7 +151,7 @@ function SearchResults() {
</h1>
<div className="flex flex-col items-center">
<h2 className="text-muted-foreground font-bold">
Page {(deps.page as number ?? 0) + 1}
Page {((deps.page as number) ?? 0) + 1}
</h2>
<Pagination className="w-fit mx-0 text-2xl text-foreground">
<PaginationContent>
Expand Down
16 changes: 11 additions & 5 deletions frontend/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | undefined>();
const [year, setYear] = useState<string | undefined>();
const [semester, setSemester] = useState<string | undefined>();
const location = useLocation();

const handleSearch = async (
query: string | undefined,
Expand All @@ -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 (
<div className="flex items-center w-full max-w-md gap-2 md:ml-10">
Expand Down

0 comments on commit da69b6c

Please sign in to comment.