import { Link, useLocation, useNavigate } from "@tanstack/react-router"; import { useAuth } from "@/lib/auth"; import { Button } from "@/components/ui/button"; import { Briefcase, Users, FileText, Receipt, ShieldCheck, LogOut, LayoutDashboard, Calendar as CalendarIcon, CheckSquare, MessageSquare, Activity, DollarSign, FolderOpen, Files as FilesIcon, Settings as SettingsIcon, ClipboardList, UserPlus, User as UserIcon, Inbox as InboxIcon, CreditCard, Archive as ArchiveIcon, BarChart3, } from "lucide-react"; import { cn } from "@/lib/utils"; import type { ReactNode } from "react"; import { HeaderTimer } from "@/components/timer/header-timer"; import { QuickAddTime, QuickAddExpense } from "@/components/quick-add/quick-add"; import { QuickAddCallLog } from "@/components/quick-add/quick-add-call-log"; import { DateCalculator } from "@/components/date-calculator"; import { NotificationBell } from "@/components/notifications/notification-bell"; import { JusticeIcon } from "@/components/justice-icon"; import { GlobalSearch } from "@/components/global-search"; interface NavItem { to: string; label: string; icon: typeof Briefcase; adminOnly?: boolean; } const NAV: NavItem[] = (() => { const dashboard: NavItem = { to: "/", label: "Dashboard", icon: LayoutDashboard }; const main: NavItem[] = [ { to: "/calendar", label: "Calendar", icon: CalendarIcon }, { to: "/cases", label: "Cases", icon: Briefcase }, { to: "/clients", label: "Clients", icon: Users }, { to: "/collections", label: "Collections", icon: DollarSign }, { to: "/contacts", label: "Contacts", icon: UserPlus }, { to: "/files", label: "Files", icon: FilesIcon }, { to: "/forms", label: "Forms", icon: ClipboardList }, { to: "/inbox", label: "Inbox", icon: InboxIcon }, { to: "/invoices", label: "Invoices", icon: Receipt }, { to: "/messages", label: "Messages", icon: MessageSquare }, { to: "/payments", label: "Payments", icon: CreditCard }, { to: "/documents", label: "Pleadings", icon: FolderOpen }, { to: "/reports", label: "Reports", icon: BarChart3 }, { to: "/status", label: "Status Updates", icon: Activity }, { to: "/tasks", label: "Tasks", icon: CheckSquare }, ].sort((a, b) => a.label.localeCompare(b.label)); const bottom: NavItem[] = [ { to: "/archive", label: "Archive", icon: ArchiveIcon }, { to: "/settings", label: "Settings", icon: SettingsIcon }, { to: "/admin/users", label: "Users", icon: ShieldCheck, adminOnly: true }, ]; return [dashboard, ...main, ...bottom]; })(); void FileText; export function AppShell({ children }: { children: ReactNode }) { const { user, signOut, isAdmin, roles } = useAuth(); const location = useLocation(); const navigate = useNavigate(); const handleSignOut = async () => { await signOut(); navigate({ to: "/login" }); }; return (
{/* Sidebar */} {/* Mobile top bar */}
Counsel
{/* Desktop top toolbar */}
{NAV.filter((n) => !n.adminOnly || isAdmin).map((item) => { const active = item.to === "/" ? location.pathname === "/" : location.pathname.startsWith(item.to); return ( {item.label} ); })}
{children}
); } export function PageHeader({ title, description, actions, }: { title: string; description?: string; actions?: ReactNode; }) { return (

{title}

{description &&

{description}

}
{actions &&
{actions}
}
); } export function PageContainer({ children }: { children: ReactNode }) { return
{children}
; }