import { Link, useNavigate, useRouterState } from "@tanstack/react-router" import { SidebarProvider, Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarInset, SidebarTrigger, } from "@/components/ui/sidebar" import { Separator } from "@/components/ui/separator" import { Toaster } from "@/components/ui/sonner" import { Button } from "@/components/ui/button" import { clearToken } from "@/api/auth" import { LayoutDashboard, Database, Box, Layers, Palette, Save, BookOpen, LogOut, } from "lucide-react" const NAV = [ { to: "/", label: "Dashboard", icon: LayoutDashboard }, { to: "/data-sources", label: "Data Sources", icon: Database }, { to: "/widgets", label: "Widgets", icon: Box }, { to: "/layout", label: "Layout", icon: Layers }, { to: "/theme", label: "Theme", icon: Palette }, { to: "/presets", label: "Presets", icon: Save }, { to: "/guide", label: "Guide", icon: BookOpen }, ] as const export function AppShell({ children }: { children: React.ReactNode }) { const { location } = useRouterState() const navigate = useNavigate() function logout() { clearToken() navigate({ to: "/login" }) } return ( K-Frame {NAV.map((item) => { const active = item.to === "/" ? location.pathname === "/" : location.pathname.startsWith(item.to) return ( {item.label} ) })}
{NAV.find((n) => n.to === "/" ? location.pathname === "/" : location.pathname.startsWith(n.to), )?.label ?? ""}
{children}
) }