/** * @file Navbar.tsx * @description Client component providing responsive navigation for desktop and mobile views with active route indicators and trash count. */ "use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { LayoutDashboard, FileText, Trash2, FilePenLine } from "lucide-react"; import useSWR from "swr"; const fetcher = (url: string) => fetch(url).then((res) => res.json()); /** * Array of navigation items containing their name, route path, and corresponding icon. */ const navItems = [ { name: "Summary", href: "/summary", icon: FileText }, { name: "Dashboard", href: "/dashboard", icon: LayoutDashboard }, { name: "Add Task", href: "/tasks", icon: FilePenLine }, { name: "Trash", href: "/trash", icon: Trash2 }, ]; /** * Renders the responsive navigation bar featuring desktop sidebar layout * and mobile bottom bar layout with active state styling and cached trash counter. * * @returns {JSX.Element} The rendered navigation component. */ export default function Navbar() { const pathname = usePathname(); const { data } = useSWR("/api/trash/count", fetcher, { revalidateOnFocus: false, revalidateIfStale: false, }); const trashCount = data?.count || 0; // Shared function to render navigation links const renderNavLinks = (isMobile = false) => navItems.map((item) => { const Icon = item.icon; const isTrash = item.href === "/trash"; const isActive = pathname === item.href || (item.href !== "/" && pathname.startsWith(item.href)); return (