Made it so the side bar is minimized after refresh if it was before
This commit is contained in:
@@ -8,9 +8,11 @@ import "primeicons/primeicons.css";
|
||||
import {useRouter} from "next/router";
|
||||
import {useEffect} from "react";
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import usePreferencesStore from "@/stores/preferencesStore";
|
||||
|
||||
export default function App({Component, pageProps}: AppProps) {
|
||||
const reset = useExamStore((state) => state.reset);
|
||||
const setIsSidebarMinimized = usePreferencesStore((state) => state.setSidebarMinimized);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
@@ -18,5 +20,15 @@ export default function App({Component, pageProps}: AppProps) {
|
||||
if (router.pathname !== "/exercises") reset();
|
||||
}, [router.pathname, reset]);
|
||||
|
||||
useEffect(() => {
|
||||
if (localStorage.getItem("isSidebarMinimized")) {
|
||||
if (localStorage.getItem("isSidebarMinimized") === "true") {
|
||||
setIsSidebarMinimized(true);
|
||||
} else {
|
||||
setIsSidebarMinimized(false);
|
||||
}
|
||||
}
|
||||
}, [setIsSidebarMinimized]);
|
||||
|
||||
return <Component {...pageProps} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user