Created a simple permissions system for users

This commit is contained in:
Tiago Ribeiro
2023-05-17 16:32:52 +01:00
parent 4b5c99c654
commit f579b244bf
7 changed files with 12 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
import {Type} from "@/interfaces/user";
import axios from "axios";
import Link from "next/link";
import {useRouter} from "next/router";
@@ -7,12 +8,13 @@ import {MenuItem} from "primereact/menuitem";
interface Props {
profilePicture: string;
userType: Type;
timer?: number;
showExamEnd?: boolean;
}
/* eslint-disable @next/next/no-img-element */
export default function Navbar({profilePicture, timer, showExamEnd = false}: Props) {
export default function Navbar({profilePicture, userType, timer, showExamEnd = false}: Props) {
const router = useRouter();
const logout = async () => {
@@ -41,7 +43,7 @@ export default function Navbar({profilePicture, timer, showExamEnd = false}: Pro
label: "Users",
icon: "pi pi-fw pi-users",
items: [
{label: "List", icon: "pi pi-fw pi-users", url: "/users"},
...(userType === "student" ? [] : [{label: "List", icon: "pi pi-fw pi-users", url: "/users"}]),
{label: "Stats", icon: "pi pi-fw pi-chart-pie", url: "/stats"},
{label: "History", icon: "pi pi-fw pi-history", url: "/history"},
],