"use client"; import { CheckCircle2, CircleAlert, RefreshCw } from "lucide-react"; import { Spinner } from "@/components/ui/spinner"; import { cn } from "@/lib/utils"; import type { NavItem } from "../../types/layout.types"; import { SidebarButton } from "./SidebarButton"; interface NavSectionProps { items: NavItem[]; onItemClick?: (item: NavItem) => void; isCollapsed?: boolean; } function getStatusInfo(status: NavItem["statusIndicator"]) { switch (status) { case "processing": return { tooltip: "New or updated documents are still being prepared for search.", }; case "background_sync": return { pillLabel: "Background sync", tooltip: "Periodic sync is checking for updates in the background. Existing documents stay searchable while this runs.", }; case "success": return { tooltip: "All document updates are fully synced.", }; case "error": return { pillLabel: "Needs attention", tooltip: "Some documents failed to sync. Open Documents or Inbox for details.", }; default: return {}; } } function StatusPill({ status }: { status: NavItem["statusIndicator"] }) { const { pillLabel } = getStatusInfo(status); if (!pillLabel) { return null; } return ( {pillLabel} ); } function StatusBadge({ status }: { status: NavItem["statusIndicator"] }) { if (status === "processing") { return ( ); } if (status === "background_sync") { return ( ); } if (status === "success") { return ( ); } if (status === "error") { return ( ); } return null; } function StatusIcon({ status, FallbackIcon, className, }: { status: NavItem["statusIndicator"]; FallbackIcon: NavItem["icon"]; className?: string; }) { if (status === "processing") { return ; } if (status === "background_sync") { return ( ); } if (status === "success") { return ( ); } if (status === "error") { return ( ); } return ; } function CollapsedOverlay({ item }: { item: NavItem }) { const indicator = item.statusIndicator; if (indicator && indicator !== "idle") { return ; } if (item.badge) { return ( {item.badge} ); } return null; } export function NavSection({ items, onItemClick, isCollapsed = false }: NavSectionProps) { return (
{items.map((item) => { const joyrideAttr = item.title === "Inbox" || item.title.toLowerCase().includes("inbox") ? { "data-joyride": "inbox-sidebar" as const } : {}; const { tooltip } = getStatusInfo(item.statusIndicator); return ( onItemClick?.(item)} isCollapsed={isCollapsed} isActive={item.isActive} badge={item.badge} collapsedOverlay={} expandedIconNode={ } trailingContent={} tooltipContent={tooltip} buttonProps={joyrideAttr} /> ); })}
); }