"use client" import { useState } from "react" import Link from "next/link" import { usePathname } from "next/navigation" import { Button } from "@/components/ui/button" import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet" import { Home, Settings, Users, Calendar, BarChart3, Vote, LogOut, Menu, ChevronDown } from "lucide-react" import { useAuth } from "@/hooks/use-auth" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" interface DashboardHeaderProps { title?: string showStats?: boolean stats?: { totalEvents: number activeEvents: number } } export function DashboardHeader({ title = "E-Voting Platform", showStats = false, stats }: DashboardHeaderProps) { const { user, isSuperAdmin, logout } = useAuth() const pathname = usePathname() const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false) const navigationItems = [ { name: "Home", href: "/", icon: Home, show: true }, { name: "Admin Dashboard", href: "/admin", icon: Settings, show: isSuperAdmin }, { name: "Events", href: "/admin/events", icon: Calendar, show: isSuperAdmin }, { name: "Members", href: "/admin/members", icon: Users, show: isSuperAdmin }, { name: "Results", href: "/results", icon: BarChart3, show: isSuperAdmin } ] const isActive = (href: string) => { if (href === "/") { return pathname === "/" } return pathname.startsWith(href) } const NavItems = ({ mobile = false }) => ( <> {navigationItems .filter(item => item.show) .map((item) => { const Icon = item.icon const active = isActive(item.href) return ( mobile && setIsMobileMenuOpen(false)} > {item.name} ) })} ) return (
{/* Left side - Logo and Navigation */}
{/* Logo */} METI - New & Renewable Energy
{title}
{/* Desktop Navigation */}
{/* Right side - Stats, User Menu, Mobile Menu */}
{/* Stats (Desktop) */} {showStats && stats && (
{stats.totalEvents} Events
{stats.activeEvents} Active
)} {/* User Menu */}
{user?.name?.[0] || user?.username?.[0] || "U"}
{user?.name || user?.username} {user?.email}
{isSuperAdmin && ( <> Admin Dashboard )} Logout
{/* Mobile Menu */}
{/* Header */}
METI
E-Voting Platform
METI
{/* Stats (Mobile) */} {showStats && stats && (
{stats.totalEvents}
Events
{stats.activeEvents}
Active
)} {/* Navigation */} {/* User Info */}
{user?.name?.[0] || user?.username?.[0] || "U"}
{user?.name || user?.username}
{isSuperAdmin ? "Super Admin" : "Member"}
) }