import { useState } from "react"; import { useNavigate } from "react-router-dom"; import { useAuth } from "../auth/AuthContext"; import { Button, TextField } from "../components/ui"; import { AgreementDialog } from "../components/AgreementDialog"; import { IconPerson, IconLock } from "../components/icons"; export function LoginPage() { const { login } = useAuth(); const navigate = useNavigate(); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); const [askReg, setAskReg] = useState(false); const doLogin = async () => { if (!username.trim() || !password) { setError("Заполните логин и пароль"); return; } setBusy(true); setError(""); const err = await login(username.trim(), password); setBusy(false); if (err) { setError(err); } else { navigate("/"); } }; return (