import { useState, FormEvent } from 'react'; import { Link, Navigate } from 'react-router-dom'; import { useAuth } from '@/hooks/useAuth'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; export default function LoginPage() { const { user, login } = useAuth(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); if (user) return ; const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setError(''); setLoading(true); try { await login(username, password); } catch (err: any) { setError(err.response?.data?.error || 'Ошибка входа'); } finally { setLoading(false); } }; return (
{/* Декоративные пятна */}
{/* Логотип */}
🐾

Котограм

Войдите, чтобы смотреть котов

{/* Форма */}
setUsername(e.target.value)} placeholder="Имя пользователя" required autoFocus autoComplete="username" className="h-12 text-sm rounded-xl bg-[var(--bg)] border-[var(--border)] focus-ring" /> setPassword(e.target.value)} placeholder="Пароль" required autoComplete="current-password" className="h-12 text-sm rounded-xl bg-[var(--bg)] border-[var(--border)] focus-ring" />
{error && (
{error}
)}

Нет аккаунта?{' '} Зарегистрироваться

); }