diff --git a/src/components/High/Layout.tsx b/src/components/High/Layout.tsx
index b5f86908..f106f4d8 100644
--- a/src/components/High/Layout.tsx
+++ b/src/components/High/Layout.tsx
@@ -37,7 +37,7 @@ export default function Layout({user, children, className, navDisabled = false,
/>
{children}
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index e8c296d4..1368b569 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1,7 +1,7 @@
import clsx from "clsx";
import {IconType} from "react-icons";
import {MdSpaceDashboard} from "react-icons/md";
-import {BsFileEarmarkText, BsClockHistory, BsPencil, BsGraphUp} from "react-icons/bs";
+import {BsFileEarmarkText, BsClockHistory, BsPencil, BsGraphUp, BsChevronBarRight, BsChevronBarLeft} from "react-icons/bs";
import {RiLogoutBoxFill} from "react-icons/ri";
import {SlPencil} from "react-icons/sl";
import {FaAward} from "react-icons/fa";
@@ -10,6 +10,8 @@ import {useRouter} from "next/router";
import axios from "axios";
import FocusLayer from "@/components/FocusLayer";
import {preventNavigation} from "@/utils/navigation.disabled";
+import {useState} from "react";
+import usePreferencesStore from "@/stores/preferencesStore";
interface Props {
path: string;
navDisabled?: boolean;
@@ -24,23 +26,28 @@ interface NavProps {
path: string;
keyPath: string;
disabled?: boolean;
+ isMinimized?: boolean;
}
-const Nav = ({Icon, label, path, keyPath, disabled = false}: NavProps) => (
+const Nav = ({Icon, label, path, keyPath, disabled = false, isMinimized = false}: NavProps) => (
-
-
{label}
+
+ {!isMinimized &&
{label}}
);
export default function Sidebar({path, navDisabled = false, focusMode = false, onFocusLayerMouseEnter, className}: Props) {
const router = useRouter();
+ const [isMinimized, toggleMinimize] = usePreferencesStore((state) => [state.isSidebarMinimized, state.toggleSidebarMinimized]);
+
const logout = async () => {
axios.post("/api/logout").finally(() => {
setTimeout(() => router.reload(), 500);
@@ -50,25 +57,43 @@ export default function Sidebar({path, navDisabled = false, focusMode = false, o
const disableNavigation = preventNavigation(navDisabled, focusMode);
return (
-
+
-
-
-
-
-
+
+
+
+
+
- {} : logout}
- className={clsx(
- "p-4 px-8 rounded-full flex gap-4 items-center cursor-pointer text-black hover:text-mti-rose transition duration-300 ease-in-out",
- "absolute bottom-8",
- )}>
-
-
Log Out
+
+
+ {isMinimized ? : }
+ {!isMinimized && Minimize}
+
+
{} : logout}
+ className={clsx(
+ "p-4 rounded-full flex gap-4 items-center cursor-pointer text-black hover:text-mti-rose transition duration-300 ease-in-out",
+ isMinimized ? "w-fit" : "w-full min-w-[250px] px-8",
+ )}>
+
+ {!isMinimized && Log Out}
+
{focusMode &&
}
diff --git a/src/pages/api/exam/[module]/[id].ts b/src/pages/api/exam/[module]/[id].ts
index c1d5110e..9e8e9cac 100644
--- a/src/pages/api/exam/[module]/[id].ts
+++ b/src/pages/api/exam/[module]/[id].ts
@@ -24,6 +24,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
res.status(200).json({
id: docSnap.id,
...docSnap.data(),
+ module,
});
} else {
res.status(404).json(undefined);
diff --git a/src/stores/preferencesStore.ts b/src/stores/preferencesStore.ts
new file mode 100644
index 00000000..9150be0b
--- /dev/null
+++ b/src/stores/preferencesStore.ts
@@ -0,0 +1,20 @@
+import {Module} from "@/interfaces";
+import {Exam, UserSolution} from "@/interfaces/exam";
+import {create} from "zustand";
+
+export interface PreferencesState {
+ isSidebarMinimized: boolean;
+ toggleSidebarMinimized: () => void;
+}
+
+export const initialState = {
+ isSidebarMinimized: false,
+};
+
+const usePreferencesStore = create
((set) => ({
+ ...initialState,
+ toggleSidebarMinimized: () => set((state) => ({isSidebarMinimized: !state.isSidebarMinimized})),
+ reset: () => set(() => initialState),
+}));
+
+export default usePreferencesStore;