import { useState, useRef, useEffect } from 'react' import { useLocation } from 'react-router-dom' import { Bell, ChevronDown, LogOut, Shield } from 'lucide-react' import { useAuth } from '../contexts/AuthContext' import { getInitials } from '../utils/api' const pageTitles = { '/': 'Dashboard', '/posts': 'Post Production', '/assets': 'Assets', '/campaigns': 'Campaigns', '/finance': 'Finance', '/projects': 'Projects', '/tasks': 'My Tasks', '/team': 'Team', '/users': 'User Management', } const ROLE_INFO = { superadmin: { label: 'Superadmin', color: 'bg-purple-100 text-purple-700', icon: '👑' }, manager: { label: 'Manager', color: 'bg-blue-100 text-blue-700', icon: '📊' }, contributor: { label: 'Contributor', color: 'bg-green-100 text-green-700', icon: '✏️' }, } export default function Header() { const { user, logout } = useAuth() const [showDropdown, setShowDropdown] = useState(false) const dropdownRef = useRef(null) const location = useLocation() function getPageTitle(pathname) { if (pageTitles[pathname]) return pageTitles[pathname] if (pathname.startsWith('/projects/')) return 'Project Details' if (pathname.startsWith('/campaigns/')) return 'Campaign Details' return 'Page' } const pageTitle = getPageTitle(location.pathname) useEffect(() => { const handleClickOutside = (e) => { if (dropdownRef.current && !dropdownRef.current.contains(e.target)) { setShowDropdown(false) } } document.addEventListener('mousedown', handleClickOutside) return () => document.removeEventListener('mousedown', handleClickOutside) }, []) const roleInfo = ROLE_INFO[user?.role] || ROLE_INFO.contributor return (
{/* Page title */}

{pageTitle}

{/* Right side */}
{/* Notifications */} {/* User menu */}
{showDropdown && (
{/* User info */}

{user?.name}

{user?.email}

{roleInfo.icon} {roleInfo.label}
{/* Menu items */}
{user?.role === 'superadmin' && ( )}
)}
) }