diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index 57966dfb3..9e66d383d 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -141,7 +141,7 @@ export default function App() { }; //this function is to get the user logged in when the page is refreshed - const { setUserData, getAuthentication, login, setAutoLogin, logout } = + const { setUserData, getAuthentication, login, setAutoLogin, logout, setIsAdmin } = useContext(AuthContext); useEffect(() => { @@ -161,6 +161,8 @@ export default function App() { .then((user) => { setUserData(user); setLoading(false); + const isSuperUser = user.is_superuser; + setIsAdmin(isSuperUser); }) .catch((error) => {}); } diff --git a/src/frontend/src/components/headerComponent/index.tsx b/src/frontend/src/components/headerComponent/index.tsx index 6b50313c4..860469eb3 100644 --- a/src/frontend/src/components/headerComponent/index.tsx +++ b/src/frontend/src/components/headerComponent/index.tsx @@ -1,4 +1,4 @@ -import { useContext, useEffect, useState } from "react"; +import { useContext } from "react"; import { FaDiscord, FaGithub, FaTwitter } from "react-icons/fa"; import { Link, useLocation, useNavigate } from "react-router-dom"; import AlertDropdown from "../../alerts/alertDropDown"; @@ -7,7 +7,6 @@ import { alertContext } from "../../contexts/alertContext"; import { AuthContext } from "../../contexts/authContext"; import { darkContext } from "../../contexts/darkContext"; import { TabsContext } from "../../contexts/tabsContext"; -import { getRepoStars } from "../../controllers/API"; import IconComponent from "../genericIconComponent"; import { Button } from "../ui/button"; import { Separator } from "../ui/separator"; @@ -43,22 +42,35 @@ export default function Header(): JSX.Element { )} {autoLogin === false && ( - + + )} + + {location.pathname === "/admin" && ( + { + navigate("/"); + }} + className="text-sm font-medium text-muted-foreground transition-colors hover:text-primary cursor-pointer" + > + Home + )} {isAdmin && !autoLogin && location.pathname !== "/admin" && ( - + )}
- Here's a list of all users! + Navigate through this section to efficiently oversee all application users. From here, you can seamlessly manage user accounts.