diff --git a/public/assets/icons/logout-icon.svg b/public/assets/icons/logout-icon.svg new file mode 100644 index 0000000..4cb4447 --- /dev/null +++ b/public/assets/icons/logout-icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/public/assets/icons/notification-settings-icon.svg b/public/assets/icons/notification-settings-icon.svg new file mode 100644 index 0000000..78b6485 --- /dev/null +++ b/public/assets/icons/notification-settings-icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/public/assets/icons/settings-icon.svg b/public/assets/icons/settings-icon.svg new file mode 100644 index 0000000..5bb0cb5 --- /dev/null +++ b/public/assets/icons/settings-icon.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/layout/CommonHeader.tsx b/src/components/layout/CommonHeader.tsx index 0312ced..bb62245 100644 --- a/src/components/layout/CommonHeader.tsx +++ b/src/components/layout/CommonHeader.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState } from 'react'; +import { useState, useEffect, useRef } from 'react'; import Link from 'next/link'; import Image from 'next/image'; import { useSession, signOut } from 'next-auth/react'; @@ -14,6 +14,24 @@ const navLinks = [ export function CommonHeader() { const { data: session } = useSession(); const [showProfileMenu, setShowProfileMenu] = useState(false); + const profileMenuRef = useRef(null); + + // Close dropdown when clicking outside + useEffect(() => { + function handleClickOutside(event: MouseEvent) { + if (profileMenuRef.current && !profileMenuRef.current.contains(event.target as Node)) { + setShowProfileMenu(false); + } + } + + if (showProfileMenu) { + document.addEventListener('mousedown', handleClickOutside); + } + + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, [showProfileMenu]); const userName = session?.user?.name; const userEmail = session?.user?.email; @@ -65,53 +83,114 @@ export function CommonHeader() { - {/* Profile Icon with Dropdown */} -
+ {/* Profile Section with Greeting - Entire area clickable */} +
{/* Profile Dropdown Menu */} {showProfileMenu && ( -
-
-

- {userName || 'User'} +

+ {/* Arrow/Triangle at top */} +
+ + {/* User Profile Section */} +
+
+ Profile +
+
+

+ {userName?.split(' ')[0] || 'User'} +

+

+ {userEmail} +

+
+
+ + {/* Account Settings */} + setShowProfileMenu(false)} + > + Settings +
+

+ Account Settings +

+

+ Profile, Security +

+
+ + + {/* Notification Settings */} + setShowProfileMenu(false)} + > + Notifications +

+ Notification Settings

-

{userEmail}

-
-
- setShowProfileMenu(false)} - > - Dashboard - - setShowProfileMenu(false)} - > - Settings - -
-
- -
+ + + {/* Log Out */} +
)}
diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx deleted file mode 100644 index 3bb82b2..0000000 --- a/src/components/layout/Header.tsx +++ /dev/null @@ -1,174 +0,0 @@ -'use client'; - -import Link from 'next/link'; -import Image from 'next/image'; -import { useSession } from 'next-auth/react'; -import { useState } from 'react'; - -export function Header() { - const { data: session } = useSession(); - const [mobileMenuOpen, setMobileMenuOpen] = useState(false); - - // Get first name from session - const firstName = session?.user?.name?.split(' ')[0] || 'User'; - - return ( -
-
-
- {/* Logo */} - - RE-Quest - - - {session ? ( - /* ============ AUTHENTICATED HEADER ============ */ - <> - {/* Navigation - Desktop */} - - - {/* Right Side - Authenticated */} -
- {/* Notification Bell */} - - Notifications - {/* Red notification dot */} - - - - {/* Profile Section */} - - {/* Profile Avatar */} -
- {session.user?.image ? ( - Profile - ) : ( - Profile - )} -
- {/* Greeting Text */} -
- - Hi {firstName} ! - - - Welcome back ! - -
- - - {/* Mobile Menu Button */} - -
- - ) : ( - /* ============ NON-AUTHENTICATED HEADER ============ */ - /* Simple: Just logo + Get Started button */ -
- - Get Started - -
- )} -
- - {/* Mobile Menu Dropdown - Authenticated Only */} - {session && mobileMenuOpen && ( -
- -
- )} -
-
- ); -}