"use client" import { useState } from "react" import Link from "next/link" import { usePathname, useRouter } from "next/navigation" import { ArrowLeft, Bell, LogOut, Settings, User } from "lucide-react" import { cn } from "@/lib/utils" import { Avatar, AvatarFallback } from "@/components/ui/avatar" import { Badge } from "@/components/ui/badge" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" function titleFromPath(pathname: string) { const segment = pathname.split("/").filter(Boolean).pop() ?? "dashboard" return segment.charAt(0).toUpperCase() + segment.slice(1) } interface Notification { id: string title: string description: string time: string unread: boolean } const initialNotifications: Notification[] = [ { id: "1", title: "New order received", description: "Order #3210 placed by John Martinez", time: "2m ago", unread: true, }, { id: "2", title: "Low stock alert", description: "SKU-2291 has dropped below its reorder threshold", time: "1h ago", unread: true, }, { id: "3", title: "Payment failed", description: "Order #3207 payment was declined", time: "3h ago", unread: false, }, { id: "4", title: "New customer", description: "Grace Kim just created an account", time: "1d ago", unread: false, }, ] export function Header() { const pathname = usePathname() const router = useRouter() const title = titleFromPath(pathname) const showBackButton = pathname !== "/dashboard" const [notifications, setNotifications] = useState(initialNotifications) const unreadCount = notifications.filter((n) => n.unread).length const markAllAsRead = () => setNotifications((prev) => prev.map((n) => ({ ...n, unread: false }))) return (
{showBackButton && ( )}

{title}

} > {unreadCount > 0 && ( )}

Notifications

{unreadCount > 0 && ( )}
{notifications.length === 0 ? (

You're all caught up.

) : ( notifications.map((notification) => (

{notification.title}

{notification.description}

{notification.time}

)) )}
JM John Martinez

John Martinez

john52martinez@gmail.com

} className="gap-3 px-3 py-2.5 text-base [&_svg:not([class*='size-'])]:size-5" > Profile } className="gap-3 px-3 py-2.5 text-base [&_svg:not([class*='size-'])]:size-5" > Settings } className="gap-3 px-3 py-2.5 text-base [&_svg:not([class*='size-'])]:size-5" > Log out
) }