"use client"; import { useEffect } from "react"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useAuth } from "@/components/AuthProvider"; import { PageHeader } from "@/components/ui/PageHeader"; const TABS = [ { href: "/settings/organization", label: "Organization" }, { href: "/settings/members", label: "Members" }, { href: "/settings/nodes", label: "Node Ownership" }, { href: "/settings/api-keys", label: "API Keys" }, { href: "/settings/billing", label: "Billing" }, ]; export default function SettingsLayout({ children }: { children: React.ReactNode }) { // SAAS_PLAN.md B7: this used to gate on isAdmin (platform admin) alone, // which meant a paying customer who is their own org's owner couldn't // reach their own billing/members/node-ownership settings — "admin" here // conflated "platform operator" with "org owner". isAdmin still passes // (support/debugging access to any org's settings), but org_role === // "owner" is now sufficient on its own. const { isAdmin, isOrgOwner, loading } = useAuth(); const canAccess = isAdmin || isOrgOwner; const pathname = usePathname(); const router = useRouter(); useEffect(() => { if (!loading && !canAccess) router.replace("/"); }, [loading, canAccess, router]); if (loading || !canAccess) return null; return (
{TABS.map((t) => ( {t.label} ))}
{children}
); }