import React, { useState } from 'react'; import { AuthService } from '../services/api'; const features = [ { icon: 'β‘', title: 'Automated Workflows', desc: 'Build and run multi-step API test flows without writing boilerplate.', }, { icon: 'π', title: 'Smart Diff & Validation', desc: 'Instantly compare responses and catch regressions before they ship.', }, { icon: 'π', title: 'Spec-driven Testing', desc: 'Import OpenAPI specs and generate tests from your existing contracts.', }, { icon: 'π€', title: 'AI Assistant', desc: 'Ask questions about your APIs and get context-aware suggestions.', }, ]; export default function LoginPage({ onLogin }) { const [mode, setMode] = useState('login'); // 'login' | 'register' const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [confirm, setConfirm] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const switchMode = (m) => { setMode(m); setError(''); setPassword(''); setConfirm(''); }; const handleSubmit = async (e) => { e.preventDefault(); setError(''); if (mode === 'register' && password !== confirm) { setError('Passwords do not match.'); return; } setLoading(true); try { if (mode === 'register') { await AuthService.register(username.trim(), password); } else { await AuthService.login(username.trim(), password); } onLogin(); } catch (err) { setError(err.message || (mode === 'register' ? 'Registration failed.' : 'Invalid username or password.')); } finally { setLoading(false); } }; const inputStyle = { width: '100%', boxSizing: 'border-box', padding: '10px 13px', background: 'var(--bg-3)', border: '1px solid var(--line-2)', borderRadius: 8, color: 'var(--fg-0)', fontSize: 14, fontFamily: 'var(--font-mono)', outline: 'none', transition: 'border-color 0.15s', }; return (
A unified workspace for designing, running, and validating API tests β powered by AI and driven by your specs.
{/* Feature list */}