From 98e203efb2c6c3256ffa459075f2952a6f95d806 Mon Sep 17 00:00:00 2001 From: adam-skowronek Date: Tue, 3 Jan 2023 23:01:28 +0100 Subject: [PATCH] Reload on year change --- frontend/src/components/TopBar.tsx | 45 ++++++++++++++++++------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/TopBar.tsx b/frontend/src/components/TopBar.tsx index fcb0951..57091e4 100644 --- a/frontend/src/components/TopBar.tsx +++ b/frontend/src/components/TopBar.tsx @@ -11,8 +11,15 @@ type SelectValue = { label: string } -const TopBar = ({ routes, color }: { routes: { name: string; path: string }[]; color: string}, ) => { - const linkClass = ({ isActive }: { isActive: boolean }) => isActive ? 'underline font-bold' : '' +const TopBar = ({ + routes, + color, +}: { + routes: { name: string; path: string }[] + color: string +}) => { + const linkClass = ({ isActive }: { isActive: boolean }) => + isActive ? 'underline font-bold' : '' const [yearGroupId, setYearGroupId] = useLocalStorageState('yearGroupId', { defaultValue: -1, @@ -21,11 +28,10 @@ const TopBar = ({ routes, color }: { routes: { name: string; path: string }[]; c defaultValue: 'coordinator', }) const [yearGroupOptions, setYearGroupOptions] = useState() - const [name, setName] = useState("") - const onYearChange = (v: any) => { setYearGroupId(v?.value) + window.location.reload() } useQuery('year_groups', () => getYearGroups({ per_page: 100 }), { onSuccess: (data) => { @@ -41,7 +47,7 @@ const TopBar = ({ routes, color }: { routes: { name: string; path: string }[]; c }) return ( -
+

System PRI

{routes.map(({ path, name }) => ( @@ -51,19 +57,22 @@ const TopBar = ({ routes, color }: { routes: { name: string; path: string }[]; c ))}
- {userType == 'coordinator' ? ({ + ...styles, + padding: '0.01rem', + borderRadius: '0.5rem', + }), + }} + value={yearGroupOptions?.find((year) => year.value === yearGroupId)} + /> + ) : null}
Wyloguj