- {/* Logo & Navigation */}
-
-
-
-
-
-
- {/* User Profile & Notifications */}
-
-
-
-
-
-
- JH
-
+interface NavbarProps {
+ userType: "mentor" | "student"; // Determines dashboard type
+ userName: string; // User's name
+}
+
+const Navbar: React.FC
= ({ userType, userName }) => {
+ const [isStudentPopupOpen, setIsStudentPopupOpen] = useState(false);
+ const [isLogoutPopupOpen, setIsLogoutPopupOpen] = useState(false);
+ const logoutPopupRef = useRef(null);
+
+ const openStudentPopup = () => setIsStudentPopupOpen(true);
+ const closeStudentPopup = () => setIsStudentPopupOpen(false);
+ const toggleLogoutPopup = () => setIsLogoutPopupOpen((prev) => !prev);
+
+ const handleLogout = () => {
+ // Clear authentication data
+ localStorage.removeItem("authToken");
+ sessionStorage.removeItem("authToken");
+ document.cookie = "authToken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
+
+ // Redirect to login page
+ window.location.href = "/login";
+ };
+
+ // Close logout popup when clicking outside
+ useEffect(() => {
+ const handleClickOutside = (event: MouseEvent) => {
+ if (
+ logoutPopupRef.current &&
+ event.target instanceof Node &&
+ !logoutPopupRef.current.contains(event.target)
+ ) {
+ setIsLogoutPopupOpen(false);
+ }
+ };
+
+ document.addEventListener("mousedown", handleClickOutside);
+ return () => {
+ document.removeEventListener("mousedown", handleClickOutside);
+ };
+ }, []);
+
+ return (
+
+ {/* Logo & Navigation */}
+
+
+ {/* Show navigation only for mentors */}
+ {userType === "mentor" && (
+
+ )}
+
+
+ {/* User Profile & Notifications */}
+
+
+
+
+
{userName}
+
+ {userType === "mentor" ? "Senior Mentor" : "Student"}
+
+
+
+
+ {userName.charAt(0)}
+
+ {/* Logout Popup */}
+ {isLogoutPopupOpen && (
+
+
+
+
Are you sure you want to logout?
+
+
+
+
+
+ )}
+
+
+ {/* Conditionally render the StudentDetailsPopup */}
+ {isStudentPopupOpen &&
}
-
-
- );
+ );
};
export default Navbar;
From 47995994f366318ce3fc65933f6185a694219544 Mon Sep 17 00:00:00 2001
From: Yasindu Induwara <148317183+YEdirisingha@users.noreply.github.com>
Date: Fri, 11 Apr 2025 08:54:34 +0530
Subject: [PATCH 8/8] Add files via upload
---
server/src/components/ui/tooltip.tsx | 32 ++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 server/src/components/ui/tooltip.tsx
diff --git a/server/src/components/ui/tooltip.tsx b/server/src/components/ui/tooltip.tsx
new file mode 100644
index 0000000..28e1918
--- /dev/null
+++ b/server/src/components/ui/tooltip.tsx
@@ -0,0 +1,32 @@
+"use client"
+
+import * as React from "react"
+import * as TooltipPrimitive from "@radix-ui/react-tooltip"
+
+import { cn } from "@/lib/utils"
+
+const TooltipProvider = TooltipPrimitive.Provider
+
+const Tooltip = TooltipPrimitive.Root
+
+const TooltipTrigger = TooltipPrimitive.Trigger
+
+const TooltipContent = React.forwardRef<
+ React.ElementRef
,
+ React.ComponentPropsWithoutRef
+>(({ className, sideOffset = 4, ...props }, ref) => (
+
+
+
+))
+TooltipContent.displayName = TooltipPrimitive.Content.displayName
+
+export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }