import { useState } from "react"; import { Lock, Eye, EyeOff, Terminal } from "lucide-react"; interface LoginScreenProps { onAuth: (token: string) => void; } export function LoginScreen({ onAuth }: LoginScreenProps) { const [token, setToken] = useState(""); const [error, setError] = useState(""); const [showToken, setShowToken] = useState(false); const [connecting, setConnecting] = useState(false); const [connected, setConnected] = useState(false); const [logLines, setLogLines] = useState([]); const hackerLog = (lines: string[], onDone: () => void) => { lines.forEach((line, i) => { setTimeout(() => { setLogLines((prev) => [...prev, line]); if (i === lines.length - 1) setTimeout(onDone, 400); }, i * 180); }); }; const submit = async (e: React.FormEvent) => { e.preventDefault(); if (connecting) return; setConnecting(true); setError(""); setLogLines([]); hackerLog([ "$ flowteon connect --auth", "> Establishing secure connection...", "> Validating AUTH_TOKEN...", ], async () => { try { const res = await fetch("/api/health", { headers: { Authorization: `Bearer ${token}` }, }); if (res.ok) { hackerLog([ "> Token accepted", "> Loading Docker socket...", "> Connection established!", ], () => { localStorage.setItem("df:token", token); setConnected(true); setTimeout(() => onAuth(token), 800); }); } else { hackerLog(["> ERROR: Invalid token", "> Connection refused"], () => { setError("Token invalido"); setConnecting(false); }); } } catch { hackerLog(["> ERROR: Connection failed"], () => { setError("No se pudo conectar"); setConnecting(false); }); } }); }; return (
{/* Logo + Title */} Flowteon

Flowteon

AlteonX
{/* Form */}
{ setToken(e.target.value); setError(""); }} placeholder="AUTH_TOKEN" className="w-full bg-slate-900 border border-slate-700 rounded-lg pl-9 pr-10 py-2.5 text-sm text-white font-mono placeholder:text-slate-600 focus:outline-none focus:border-cyan-500 transition-colors" autoFocus disabled={connecting} />
{error && {error}}
{/* Terminal log */} {logLines.length > 0 && (
{logLines.map((line, i) => (
{line} {i === logLines.length - 1 && !connected && ( )}
))}
)}
); }