diff --git a/src/app/components/Header/index.tsx b/src/app/components/Header/index.tsx
index 100bc3b..14f61fa 100644
--- a/src/app/components/Header/index.tsx
+++ b/src/app/components/Header/index.tsx
@@ -1,6 +1,6 @@
-"use client";
import {
Avatar,
+ Button,
Dropdown,
DropdownItem,
DropdownMenu,
@@ -8,9 +8,13 @@ import {
Navbar,
NavbarBrand,
NavbarContent,
+ NavbarItem,
} from "@nextui-org/react";
import { useSession } from "next-auth/react";
import { ThemeSwitcher } from "../ThemeSwitcher/ThemeSwitcher";
+import { axiosInstance } from "@/app/lib/axios";
+import { useEffect, useState } from "react";
+import { useRouter } from "next/navigation";
const getInitials = (name: string) => {
if (!name) return "";
@@ -28,14 +32,36 @@ const getInitials = (name: string) => {
export const Header = () => {
const { data: session } = useSession();
+ const router = useRouter();
+
+ const [userProfile, setUserProfile] = useState<{
+ id: string;
+ username: string;
+ role: "ADMIN" | "STUDENT";
+ }>();
const initials = session?.user?.name ? getInitials(session.user.name) : "";
+ const fetchUserProfile = async () => {
+ return await axiosInstance<{
+ id: string;
+ username: string;
+ role: "ADMIN" | "STUDENT";
+ }>("/@me");
+ }
+
+ useEffect(() => {
+ fetchUserProfile().then(r => {
+ setUserProfile(r.data);
+ });
+ }, []);
+
return (
Toogether
+
@@ -65,7 +91,20 @@ export const Header = () => {
-
+
+
+
+ {
+ userProfile?.role === "ADMIN" ? (
+
+
+
+ ) : null
+ }
);
diff --git a/src/app/components/ThemeSwitcher/ThemeSwitcher.tsx b/src/app/components/ThemeSwitcher/ThemeSwitcher.tsx
index e418097..bc8efe1 100644
--- a/src/app/components/ThemeSwitcher/ThemeSwitcher.tsx
+++ b/src/app/components/ThemeSwitcher/ThemeSwitcher.tsx
@@ -1,24 +1,13 @@
"use client";
+import { Button } from "@nextui-org/react";
import { useTheme } from "next-themes";
-import { useEffect, useState } from "react";
export const ThemeSwitcher = () => {
- const [mounted, setMounted] = useState(false);
const { theme, setTheme } = useTheme();
- useEffect(() => {
- setMounted(true);
- }, []);
-
- if (!mounted) return null;
-
return (
-
+
);
};