'use client';
import { KeyRound, LogOut, RefreshCw } from 'lucide-react';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { type ReactNode, useState } from 'react';
import { Container } from '@/components/ui/section';
import { ADMIN_MODULES, setAdminToken, useAdminToken } from '@/lib/admin';
import { cn } from '@/lib/cn';
/** Token gate + module navigation. The token never leaves localStorage except as the `X-CA-Admin-Token` header. */
export function AdminShell({ children, title, onRefresh, refreshing }: { children: ReactNode; title: string; onRefresh?: () => void; refreshing?: boolean }) {
const token = useAdminToken();
const pathname = usePathname();
const [draft, setDraft] = useState('');
if (token === undefined) return Admin Enter the admin token (`CA_ADMIN_TOKEN`). It is stored in this browser only and sent as X-CA-Admin-Token to same-origin API calls.Operator console
{title}
{onRefresh && (
)}
{error} {/401|403/.test(error) ? ' — the token was rejected. Sign out and enter it again.' : ''}
); } export function AdminTable({ head, children, className }: { head: ReactNode; children: ReactNode; className?: string }) { return ({i.label}
{i.value}
{i.hint &&{i.hint}
}