import { createFileRoute, Link, useLocation } from "@tanstack/react-router"; import { ProtectedLayout } from "@/components/protected-layout"; import { PageContainer, PageHeader } from "@/components/app-shell"; import { Outlet } from "@tanstack/react-router"; import { useAuth } from "@/lib/auth"; import { cn } from "@/lib/utils"; export const Route = createFileRoute("/settings")({ component: SettingsLayout, }); const TABS = [ { to: "/settings/profile", label: "My profile", anyone: true }, { to: "/settings", label: "Company", exact: true }, { to: "/settings/fees", label: "Fee schedule" }, { to: "/settings/custom-fields", label: "Custom case fields" }, { to: "/settings/workflow", label: "Collections workflow" }, { to: "/settings/workflows", label: "Task workflows" }, { to: "/settings/smtp", label: "Email (SMTP)" }, { to: "/settings/imap", label: "Email (IMAP)" }, { to: "/settings/import", label: "CSV import" }, ]; function SettingsLayout() { const location = useLocation(); const { isAdmin } = useAuth(); const visibleTabs = TABS.filter((t) => t.anyone || isAdmin); return (
{visibleTabs.map((t) => { const active = t.exact ? location.pathname === t.to : location.pathname.startsWith(t.to); return ( {t.label} ); })}
); }