'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { Sparkles } from 'lucide-react'; export default function LoginPage() { const router = useRouter(); const [mode, setMode] = useState('login'); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [busy, setBusy] = useState(false); async function submit(e) { e.preventDefault(); setBusy(true); setError(''); const res = await fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, password, mode }), }); const data = await res.json(); setBusy(false); if (!res.ok) { setError(data.error || 'Ошибка'); return; } router.push('/'); } return (
ZeroPost

{mode === 'login' ? 'Вход' : 'Регистрация'}

ИИ-ассистент для Telegram-каналов

setEmail(e.target.value)} className="input" placeholder="you@example.com" />
setPassword(e.target.value)} className="input" placeholder="••••••••" />
{error && (
{error}
)}
); }