diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index c4aae9cc..2b7d76a6 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -11,9 +11,9 @@ export default function Navbar({user}: Props) {

eCrop

- +
- + {user.name} {user.name}
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index f5fa705a..62e22121 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -28,7 +28,7 @@ const Nav = ({Icon, label, path, keyPath}: NavProps) => ( path === keyPath && "bg-mti-green text-white", )}> - {label} + {label} ); @@ -59,7 +59,7 @@ export default function Sidebar({path}: Props) { "p-4 px-8 rounded-full flex gap-4 items-center cursor-pointer text-black hover:text-mti-orange transition duration-300 ease-in-out", )}> - Log Out + Log Out ); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index c3990ad3..a0662b2b 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -14,6 +14,9 @@ import useUser from "@/hooks/useUser"; import Sidebar from "@/components/Sidebar"; import Diagnostic from "@/components/Diagnostic"; import {ToastContainer} from "react-toastify"; +import {capitalize} from "lodash"; +import {Module} from "@/interfaces"; +import clsx from "clsx"; export const getServerSideProps = withIronSessionSsr(({req, res}) => { const user = req.session.user; @@ -35,19 +38,17 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => { }, sessionOptions); export default function Home() { - const [showEndExam, setShowEndExam] = useState(false); - const [windowWidth, setWindowWidth] = useState(0); const [showDiagnostics, setShowDiagnostics] = useState(false); - - const {stats, isLoading} = useStats(); const {user} = useUser({redirectTo: "/login"}); - useEffect(() => setShowEndExam(window.innerWidth <= 960), []); - useEffect(() => setWindowWidth(window.innerWidth), []); useEffect(() => { if (user) setShowDiagnostics(user.isFirstLogin); }, [user]); + const calculateAverageLevel = () => { + return Object.keys(user!.levels).reduce((accumulator, current) => user!.levels[current as Module] + accumulator, 0) / 4; + }; + if (user && showDiagnostics) { return ( <> @@ -80,11 +81,32 @@ export default function Home() { {user && ( -
+
-
+
-
+
+
+ {user.name} +
+
+
+

{user.name}

+ {capitalize(user.type)} +
+
+
+ + Level {calculateAverageLevel().toFixed(1)} + +
+
+
+
+
)} diff --git a/src/styles/globals.css b/src/styles/globals.css index 4c17d5d0..16d31c6f 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -53,6 +53,8 @@ html, body { + min-height: 100vh !important; + height: 100%; max-width: 100vw; overflow-x: hidden; } diff --git a/tailwind.config.js b/tailwind.config.js index e3150a4b..45726584 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -8,7 +8,7 @@ module.exports = { orange: "#FF6000", green: "#51C21A", blue: "#007FF8", - gray: "#F9F9F9", + gray: {light: "#F9F9F9", dark: "#E0E0E0"}, }, ielts: { reading: {DEFAULT: "#FF6384", transparent: "rgba(255, 99, 132, 0.5)"},