import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import apiClient from '../../api/client'; import { ArrowRight } from 'lucide-react'; interface AuthPageProps { onLoginSuccess: () => void; } export function AuthPage({ onLoginSuccess }: AuthPageProps) { const { t } = useTranslation(); const [isLogin, setIsLogin] = useState(true); const [userName, setUserName] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setLoading(true); try { if (isLogin) { const response = await apiClient.post('/api/v1/auth/login', { user_name: userName, password: password, }); if (response.data.token) { localStorage.setItem('token', response.data.token); onLoginSuccess(); } } else { const response = await apiClient.post('/api/v1/auth/register', { user_name: userName, password: password, }); if (response.data.message === 'success') { setIsLogin(true); setError(t('auth.registerSuccess')); } } } catch (err: any) { console.error(err); setError(err.response?.data?.detail || err.response?.data?.message || t('auth.authFailed')); } finally { setLoading(false); } }; return (
{/* Left: Brand */}

KiloStar

{t('app.tagline')}

Multi-Agent Orchestration
Visual Pipeline Builder
Intelligent Monitoring
{/* Right: Card */}

{isLogin ? t('auth.welcomeBack') : t('auth.createAccount')}

{isLogin ? t('auth.enterCredentials') : t('auth.signUpToStart')}

{error && (
{error}
)}
setUserName(e.target.value)} className="w-full px-3.5 py-3 rounded-[10px] border border-border-primary bg-bg-primary text-sm text-text-primary placeholder:text-[#bbb5ae] outline-none transition-all focus:border-accent focus:shadow-[0_0_0_3px_rgba(156,175,136,0.1)]" placeholder={t('auth.usernamePlaceholder')} required />
setPassword(e.target.value)} className="w-full px-3.5 py-3 rounded-[10px] border border-border-primary bg-bg-primary text-sm text-text-primary placeholder:text-[#bbb5ae] outline-none transition-all focus:border-accent focus:shadow-[0_0_0_3px_rgba(156,175,136,0.1)]" placeholder={t('auth.passwordPlaceholder')} required />
or

{isLogin ? t('auth.noAccount') : t('auth.hasAccount')}{' '}

); }