feat: creats frontend for the project

This commit is contained in:
vakabunga
2026-03-02 00:33:09 +03:00
parent 4d67636633
commit cd56e2bf9d
37 changed files with 3762 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
import { useState, type FormEvent } from 'react';
import { useAuth } from '../context/AuthContext';
export function LoginPage() {
const { login, error } = useAuth();
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [submitting, setSubmitting] = useState(false);
const handleSubmit = async (e: FormEvent) => {
e.preventDefault();
setSubmitting(true);
try {
await login(username, password);
} catch {
// error state managed by AuthContext
} finally {
setSubmitting(false);
}
};
return (
<div className="login-page">
<div className="login-card">
<div className="login-header">
<span className="login-icon"></span>
<h1>Семейный бюджет</h1>
<p>Войдите для продолжения</p>
</div>
<form onSubmit={handleSubmit} className="login-form">
{error && <div className="alert alert-error">{error}</div>}
<div className="form-group">
<label htmlFor="login">Логин</label>
<input
id="login"
type="text"
value={username}
onChange={(e) => setUsername(e.target.value)}
autoComplete="username"
required
autoFocus
/>
</div>
<div className="form-group">
<label htmlFor="password">Пароль</label>
<input
id="password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
autoComplete="current-password"
required
/>
</div>
<button
type="submit"
className="btn btn-primary btn-block"
disabled={submitting}
>
{submitting ? 'Вход...' : 'Войти'}
</button>
</form>
</div>
</div>
);
}