Spaces:
Paused
Paused
login component
Browse files- web/src/components/Login.jsx +12 -8
web/src/components/Login.jsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
import { useState } from 'react';
|
| 2 |
-
import { api } from '../api.js';
|
| 3 |
|
| 4 |
export default function Login({ onLogin }) {
|
| 5 |
-
const [username, setUsername] = useState('');
|
| 6 |
const [password, setPassword] = useState('');
|
| 7 |
const [error, setError] = useState('');
|
| 8 |
const [busy, setBusy] = useState(false);
|
|
@@ -14,7 +13,7 @@ export default function Login({ onLogin }) {
|
|
| 14 |
try {
|
| 15 |
await onLogin(username, password);
|
| 16 |
} catch (err) {
|
| 17 |
-
setError(err.message
|
| 18 |
} finally {
|
| 19 |
setBusy(false);
|
| 20 |
}
|
|
@@ -22,13 +21,18 @@ export default function Login({ onLogin }) {
|
|
| 22 |
|
| 23 |
return (
|
| 24 |
<div className="login-wrap">
|
| 25 |
-
<form className="login" onSubmit={submit}>
|
| 26 |
<h1>Dispatch Console</h1>
|
| 27 |
-
<
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
{error && <p className="error">{error}</p>}
|
| 30 |
-
<button disabled={busy}>{busy ? 'Signing in…' : '
|
| 31 |
-
<p className="muted small">First run creates admin / admin — change it.</p>
|
| 32 |
</form>
|
| 33 |
</div>
|
| 34 |
);
|
|
|
|
| 1 |
import { useState } from 'react';
|
|
|
|
| 2 |
|
| 3 |
export default function Login({ onLogin }) {
|
| 4 |
+
const [username, setUsername] = useState('admin');
|
| 5 |
const [password, setPassword] = useState('');
|
| 6 |
const [error, setError] = useState('');
|
| 7 |
const [busy, setBusy] = useState(false);
|
|
|
|
| 13 |
try {
|
| 14 |
await onLogin(username, password);
|
| 15 |
} catch (err) {
|
| 16 |
+
setError(err.message);
|
| 17 |
} finally {
|
| 18 |
setBusy(false);
|
| 19 |
}
|
|
|
|
| 21 |
|
| 22 |
return (
|
| 23 |
<div className="login-wrap">
|
| 24 |
+
<form className="login-card" onSubmit={submit}>
|
| 25 |
<h1>Dispatch Console</h1>
|
| 26 |
+
<label>
|
| 27 |
+
Username
|
| 28 |
+
<input value={username} onChange={(e) => setUsername(e.target.value)} autoFocus />
|
| 29 |
+
</label>
|
| 30 |
+
<label>
|
| 31 |
+
Password
|
| 32 |
+
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} />
|
| 33 |
+
</label>
|
| 34 |
{error && <p className="error">{error}</p>}
|
| 35 |
+
<button disabled={busy}>{busy ? 'Signing in…' : 'Log in'}</button>
|
|
|
|
| 36 |
</form>
|
| 37 |
</div>
|
| 38 |
);
|