import { useState } from "react"; interface TokenGateProps { onTokenValid: (token: string) => void; } export default function TokenGate({ onTokenValid }: TokenGateProps) { const [input, setInput] = useState(""); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); const token = input.trim(); if (!token) return; setLoading(true); setError(null); try { const res = await fetch(`/knowledge-graph.json?token=${encodeURIComponent(token)}`); if (res.ok) { onTokenValid(token); } else if (res.status === 403) { setError("Invalid token. Please check and try again."); } else { setError(`Unexpected response (${res.status}). Is the dashboard server running?`); } } catch (err) { setError( `Could not reach the server: ${err instanceof Error ? err.message : String(err)}` ); } finally { setLoading(false); } }; return (
{/* Heading */}

Access Token Required

Paste the access token from your terminal. Look for the{" "} 🔑 line.

{/* Form */}
{ setInput(e.target.value); if (error) setError(null); }} placeholder="Paste token here..." autoFocus className="w-full px-4 py-3 bg-elevated border border-border-subtle rounded text-text-primary placeholder:text-text-muted/50 font-mono text-sm focus:outline-none focus:border-accent transition-colors" /> {error && (

{error}

)}
); }