feat: zeropost-tool — Next.js 16 кабинет
- Auth: iron-session, регистрация/логин по email+password - Дашборд со списком каналов - 3-шаговая анкета создания канала (база/стиль/примеры+табу) - Страница канала с генератором постов через polling - Тёмная тема, Tailwind 3.4, accent emerald - Прокси-API к zeropost-engine с x-user-id - Совместимость с Next 16 async cookies/params
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
'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 (
|
||||
<main className="min-h-screen flex items-center justify-center p-4">
|
||||
<div className="w-full max-w-md">
|
||||
<div className="flex items-center gap-2 mb-8 justify-center">
|
||||
<Sparkles className="w-7 h-7 text-accent" />
|
||||
<span className="text-2xl font-bold">ZeroPost</span>
|
||||
</div>
|
||||
|
||||
<div className="card p-8">
|
||||
<h1 className="text-xl font-semibold mb-1">
|
||||
{mode === 'login' ? 'Вход' : 'Регистрация'}
|
||||
</h1>
|
||||
<p className="text-sm text-gray-500 mb-6">
|
||||
ИИ-ассистент для Telegram-каналов
|
||||
</p>
|
||||
|
||||
<form onSubmit={submit} className="space-y-4">
|
||||
<div>
|
||||
<label className="label">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
required
|
||||
value={email}
|
||||
onChange={e => setEmail(e.target.value)}
|
||||
className="input"
|
||||
placeholder="you@example.com"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="label">Пароль</label>
|
||||
<input
|
||||
type="password"
|
||||
required
|
||||
minLength={6}
|
||||
value={password}
|
||||
onChange={e => setPassword(e.target.value)}
|
||||
className="input"
|
||||
placeholder="••••••••"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button disabled={busy} className="btn-primary w-full">
|
||||
{busy ? 'Подождите...' : (mode === 'login' ? 'Войти' : 'Зарегистрироваться')}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<button
|
||||
onClick={() => { setMode(mode === 'login' ? 'register' : 'login'); setError(''); }}
|
||||
className="w-full text-center text-sm text-gray-500 hover:text-gray-300 mt-6"
|
||||
>
|
||||
{mode === 'login' ? 'Нет аккаунта? Зарегистрироваться' : 'Уже есть аккаунт? Войти'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user