From 398ac3fa0c4a30accf380d26299134c083838763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ben=20B=C3=B6ckmann?= Date: Fri, 5 Apr 2024 00:50:33 +0200 Subject: [PATCH] style: added settings page; waiting for functionality --- src/app/dashboard/layout.tsx | 37 ++++++++- src/app/dashboard/page.tsx | 10 ++- src/app/dashboard/settings/page.tsx | 116 +++++++++++++++++++++++++++- 3 files changed, 158 insertions(+), 5 deletions(-) diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx index 3098a60..9737747 100644 --- a/src/app/dashboard/layout.tsx +++ b/src/app/dashboard/layout.tsx @@ -6,10 +6,13 @@ import React, { useEffect, useState } from "react"; import type { User } from "@/types"; import { getAccessToken, getUser } from "@/lib/actions"; import Link from "next/link"; +import { usePathname } from "next/navigation"; +import { cn } from "@/lib/utils"; export default function DashboardLayout({ children }: { children: React.ReactNode }) { const [user, setUser] = useState(); const [isAdmin, setIsAdmin] = useState(user?.role === "ADMIN"); + const [active, setActive] = useState<"dashboard" | "bookings" | "settings">("dashboard"); useEffect(() => { const fetchUser = async () => { @@ -27,6 +30,19 @@ export default function DashboardLayout({ children }: { children: React.ReactNod useEffect(() => { setIsAdmin(user?.role === "ADMIN"); }, [user]); + + const pathname = usePathname(); + + useEffect(() => { + // Derive the active state based on the current pathname + if (pathname.includes("/dashboard/bookings")) { + setActive("bookings"); + } else if (pathname.includes("/dashboard/settings")) { + setActive("settings"); + } else { + setActive("dashboard"); + } + }, [pathname]); return (