SPB Git

Repository Public MIT

layout.tsx 1.7 KB 36 lines tsx

1import Link from "next/link";2import { getCtx } from "@/lib/session";3import { isPlatformAdmin } from "@/server/auth";4import { signOut } from "../login/actions";56export const metadata = { title: { default: "Dashboard", template: "%s · Dashboard · Skills" }, robots: { index: false } };78export default async function DashboardLayout({ children }: { children: React.ReactNode }) {9  const ctx = await getCtx();10  const user = ctx.principal.kind === "session" ? ctx.principal.user : null;11  const links = [["/dashboard", "Overview"], ["/dashboard/artifacts", "Artifacts"], ["/dashboard/tokens", "API tokens"], ["/dashboard/audit", "Audit log"], ...(isPlatformAdmin(user) ? [["/dashboard/reports", "Moderation"]] : []), ["/dashboard/account", "Account"]];12  return (13    <div className="container-page grid gap-8 pb-10 pt-10 lg:grid-cols-[13rem_minmax(0,1fr)]">14      <aside>15        {user && (16          <div className="mb-5">17            <p className="truncate text-sm font-medium">{user.display_name}</p>18            <p className="truncate font-mono text-[11px] text-faint">{user.email} · {user.platform_role}</p>19          </div>20        )}21        <nav aria-label="Dashboard" className="flex gap-1 overflow-x-auto lg:flex-col">22          {links.map(([href, label]) => (23            <Link key={href} href={href!} className="whitespace-nowrap rounded-md px-3 py-2 text-sm text-muted hover:bg-graphite hover:text-text">{label}</Link>24          ))}25        </nav>26        {user && (27          <form action={signOut} className="mt-4">28            <button type="submit" className="rounded-md px-3 py-2 text-sm text-muted hover:text-text">Sign out</button>29          </form>30        )}31      </aside>32      <div className="min-w-0">{children}</div>33    </div>34  );35}36
Files main
Menu

Theme