import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Terminal } from 'lucide-react'; import { api } from '../lib/api.js'; export default function Login() { const navigate = useNavigate(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [busy, setBusy] = useState(false); async function handleSubmit(e) { e.preventDefault(); setBusy(true); setError(''); try { await api.login(username, password); navigate('/admin/dashboard'); } catch (err) { setError(err.message === 'invalid credentials' ? 'Неверный логин или пароль' : 'Не удалось войти, попробуйте ещё раз'); } finally { setBusy(false); } } return (