From 9ed3672cb6450f808b430f0b4f7f2b0b853b9662 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Fri, 26 May 2023 19:46:50 +0100 Subject: [PATCH] Started the redesign of the dashboard --- package.json | 1 + src/components/Navbar.tsx | 83 +++++++------------------------------- src/components/Sidebar.tsx | 66 ++++++++++++++++++++++++++++++ src/pages/exam/index.tsx | 5 +-- src/pages/history.tsx | 1 - src/pages/index.tsx | 32 +++------------ tailwind.config.js | 6 +++ yarn.lock | 5 +++ 8 files changed, 99 insertions(+), 100 deletions(-) create mode 100644 src/components/Sidebar.tsx diff --git a/package.json b/package.json index ac6ba615..a31d3cc6 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "react-chartjs-2": "^5.2.0", "react-dom": "18.2.0", "react-firebase-hooks": "^5.1.1", + "react-icons": "^4.8.0", "react-lineto": "^3.3.0", "react-media-recorder": "^1.6.6", "react-player": "^2.12.0", diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 263954e0..c4aae9cc 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,77 +1,22 @@ -import {Type} from "@/interfaces/user"; -import axios from "axios"; -import Link from "next/link"; -import {useRouter} from "next/router"; -import {Button} from "primereact/button"; -import {Menubar} from "primereact/menubar"; -import {MenuItem} from "primereact/menuitem"; +import {User} from "@/interfaces/user"; +import {Avatar} from "primereact/avatar"; interface Props { - profilePicture: string; - userType: Type; - timer?: number; - showExamEnd?: boolean; + user: User; } /* eslint-disable @next/next/no-img-element */ -export default function Navbar({profilePicture, userType, timer, showExamEnd = false}: Props) { - const router = useRouter(); - - const logout = async () => { - axios.post("/api/logout").finally(() => { - router.push("/login"); - }); - }; - - const items: MenuItem[] = [ - { - label: "Home", - icon: "pi pi-fw pi-home", - url: "/", - }, - { - label: "Account", - icon: "pi pi-fw pi-user", - url: "/profile", - }, - { - label: "Exam", - icon: "pi pi-fw pi-plus-circle", - url: "/exam", - }, - { - label: "Users", - icon: "pi pi-fw pi-users", - items: [ - ...(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"}, - ], - }, - { - label: "Logout", - icon: "pi pi-fw pi-power-off", - command: logout, - }, - ]; - - const endTimer = timer && ( - - {Math.floor(timer / 60) < 10 ? "0" : ""} - {Math.floor(timer / 60)}:{timer % 60 < 10 ? "0" : ""} - {timer % 60} - - ); - - const endNewExam = ( - -