Skip to content

Commit

Permalink
Fix dept filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbjoralt committed Oct 19, 2023
1 parent bb05fcf commit ae41b28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions frontend/src/components/FilterButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use client";
import { useRouter, useSearchParams } from "next/navigation";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useState } from "react";

export default function FilterButton({ filterName }: { filterName: string }) {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const [isButtonActive, setIsButtonActive] = useState(checkFilterInUrl);

Expand All @@ -21,7 +22,7 @@ export default function FilterButton({ filterName }: { filterName: string }) {
newFilters.splice(filterIndex, 1);
}
const newFilterString = newFilters.join(",").replace(/^,/, "");
router.push(`/bemanning?search=${currentSearch}&filter=${newFilterString}`);
router.push(`${pathname}?search=${currentSearch}&filter=${newFilterString}`);
}

function checkFilterInUrl() {
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/data/fetchWithToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ export async function fetchWithToken<T>(path: string): Promise<T | undefined> {
method: "GET",
headers: headers,
};
const response = await fetch(`${apiBackendUrl}/${path}`, options);
return (await response.json()) as T;
try{
const response = await fetch(`${apiBackendUrl}/${path}`, options);
return (await response.json()) as T;
} catch (e) {
console.log(`${apiBackendUrl}/${path}`)
console.error(e)
}
}

function mockedCall<T>(path: string): Promise<T> {
Expand Down

0 comments on commit ae41b28

Please sign in to comment.