Compare commits
2 Commits
7c139791f4
...
f5b4340daa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5b4340daa | ||
| c196ffc265 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
target/
|
target/
|
||||||
cache/
|
cache/
|
||||||
|
tokens.bin
|
||||||
|
.auth_key
|
||||||
52
frontend/pnpm-lock.yaml
generated
52
frontend/pnpm-lock.yaml
generated
@ -16,13 +16,13 @@ importers:
|
|||||||
version: 2.10.1
|
version: 2.10.1
|
||||||
react:
|
react:
|
||||||
specifier: ^19.2.1
|
specifier: ^19.2.1
|
||||||
version: 19.2.1
|
version: 19.2.3
|
||||||
react-dom:
|
react-dom:
|
||||||
specifier: ^19.2.1
|
specifier: ^19.2.1
|
||||||
version: 19.2.1(react@19.2.1)
|
version: 19.2.3(react@19.2.3)
|
||||||
react-router-dom:
|
react-router-dom:
|
||||||
specifier: ^7.10.1
|
specifier: ^7.10.1
|
||||||
version: 7.10.1(react-dom@19.2.1(react@19.2.1))(react@19.2.1)
|
version: 7.10.1(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@eslint/js':
|
'@eslint/js':
|
||||||
specifier: ^9.39.1
|
specifier: ^9.39.1
|
||||||
@ -32,10 +32,10 @@ importers:
|
|||||||
version: 24.10.1
|
version: 24.10.1
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ^19.2.7
|
specifier: ^19.2.7
|
||||||
version: 19.2.7
|
version: 19.2.8
|
||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
specifier: ^19.2.3
|
specifier: ^19.2.3
|
||||||
version: 19.2.3(@types/react@19.2.7)
|
version: 19.2.3(@types/react@19.2.8)
|
||||||
'@vitejs/plugin-react':
|
'@vitejs/plugin-react':
|
||||||
specifier: ^5.1.2
|
specifier: ^5.1.2
|
||||||
version: 5.1.2(rolldown-vite@7.2.5(@types/node@24.10.1))
|
version: 5.1.2(rolldown-vite@7.2.5(@types/node@24.10.1))
|
||||||
@ -359,8 +359,8 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@types/react': ^19.2.0
|
'@types/react': ^19.2.0
|
||||||
|
|
||||||
'@types/react@19.2.7':
|
'@types/react@19.2.8':
|
||||||
resolution: {integrity: sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==}
|
resolution: {integrity: sha512-3MbSL37jEchWZz2p2mjntRZtPt837ij10ApxKfgmXCTuHWagYg7iA5bqPw6C8BMPfwidlvfPI/fxOc42HLhcyg==}
|
||||||
|
|
||||||
'@typescript-eslint/eslint-plugin@8.48.1':
|
'@typescript-eslint/eslint-plugin@8.48.1':
|
||||||
resolution: {integrity: sha512-X63hI1bxl5ohelzr0LY5coufyl0LJNthld+abwxpCoo6Gq+hSqhKwci7MUWkXo67mzgUK6YFByhmaHmUcuBJmA==}
|
resolution: {integrity: sha512-X63hI1bxl5ohelzr0LY5coufyl0LJNthld+abwxpCoo6Gq+hSqhKwci7MUWkXo67mzgUK6YFByhmaHmUcuBJmA==}
|
||||||
@ -425,7 +425,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-EcA07pHJouywpzsoTUqNh5NwGayl2PPVEJKUSinGGSxFGYn+shYbqMGBg6FXDqgXum9Ou/ecb+411ssw8HImJQ==}
|
resolution: {integrity: sha512-EcA07pHJouywpzsoTUqNh5NwGayl2PPVEJKUSinGGSxFGYn+shYbqMGBg6FXDqgXum9Ou/ecb+411ssw8HImJQ==}
|
||||||
engines: {node: ^20.19.0 || >=22.12.0}
|
engines: {node: ^20.19.0 || >=22.12.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vite: ^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0
|
vite: npm:rolldown-vite@7.2.5
|
||||||
|
|
||||||
acorn-jsx@5.3.2:
|
acorn-jsx@5.3.2:
|
||||||
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
|
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
|
||||||
@ -863,10 +863,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
react-dom@19.2.1:
|
react-dom@19.2.3:
|
||||||
resolution: {integrity: sha512-ibrK8llX2a4eOskq1mXKu/TGZj9qzomO+sNfO98M6d9zIPOEhlBkMkBUBLd1vgS0gQsLDBzA+8jJBVXDnfHmJg==}
|
resolution: {integrity: sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
react: ^19.2.1
|
react: ^19.2.3
|
||||||
|
|
||||||
react-refresh@0.18.0:
|
react-refresh@0.18.0:
|
||||||
resolution: {integrity: sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==}
|
resolution: {integrity: sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==}
|
||||||
@ -889,8 +889,8 @@ packages:
|
|||||||
react-dom:
|
react-dom:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
react@19.2.1:
|
react@19.2.3:
|
||||||
resolution: {integrity: sha512-DGrYcCWK7tvYMnWh79yrPHt+vdx9tY+1gPZa7nJQtO/p8bLTDaHp4dzwEhQB7pZ4Xe3ok4XKuEPrVuc+wlpkmw==}
|
resolution: {integrity: sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
resolve-from@4.0.0:
|
resolve-from@4.0.0:
|
||||||
@ -1354,11 +1354,11 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 7.16.0
|
undici-types: 7.16.0
|
||||||
|
|
||||||
'@types/react-dom@19.2.3(@types/react@19.2.7)':
|
'@types/react-dom@19.2.3(@types/react@19.2.8)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/react': 19.2.7
|
'@types/react': 19.2.8
|
||||||
|
|
||||||
'@types/react@19.2.7':
|
'@types/react@19.2.8':
|
||||||
dependencies:
|
dependencies:
|
||||||
csstype: 3.2.3
|
csstype: 3.2.3
|
||||||
|
|
||||||
@ -1845,28 +1845,28 @@ snapshots:
|
|||||||
|
|
||||||
punycode@2.3.1: {}
|
punycode@2.3.1: {}
|
||||||
|
|
||||||
react-dom@19.2.1(react@19.2.1):
|
react-dom@19.2.3(react@19.2.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.2.1
|
react: 19.2.3
|
||||||
scheduler: 0.27.0
|
scheduler: 0.27.0
|
||||||
|
|
||||||
react-refresh@0.18.0: {}
|
react-refresh@0.18.0: {}
|
||||||
|
|
||||||
react-router-dom@7.10.1(react-dom@19.2.1(react@19.2.1))(react@19.2.1):
|
react-router-dom@7.10.1(react-dom@19.2.3(react@19.2.3))(react@19.2.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
react: 19.2.1
|
react: 19.2.3
|
||||||
react-dom: 19.2.1(react@19.2.1)
|
react-dom: 19.2.3(react@19.2.3)
|
||||||
react-router: 7.10.1(react-dom@19.2.1(react@19.2.1))(react@19.2.1)
|
react-router: 7.10.1(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
||||||
|
|
||||||
react-router@7.10.1(react-dom@19.2.1(react@19.2.1))(react@19.2.1):
|
react-router@7.10.1(react-dom@19.2.3(react@19.2.3))(react@19.2.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
cookie: 1.1.1
|
cookie: 1.1.1
|
||||||
react: 19.2.1
|
react: 19.2.3
|
||||||
set-cookie-parser: 2.7.2
|
set-cookie-parser: 2.7.2
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
react-dom: 19.2.1(react@19.2.1)
|
react-dom: 19.2.3(react@19.2.3)
|
||||||
|
|
||||||
react@19.2.1: {}
|
react@19.2.3: {}
|
||||||
|
|
||||||
resolve-from@4.0.0: {}
|
resolve-from@4.0.0: {}
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,15 @@ function App() {
|
|||||||
_setTheme(ev.data as string);
|
_setTheme(ev.data as string);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addToast = useCallback((message: string, type: ToastType = "info") => {
|
||||||
|
const id = Date.now();
|
||||||
|
setToasts((prev) => [...prev, { id, message, type }]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const removeToast = (id: number) => {
|
||||||
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (theme !== "default" && theme !== "sakura") {
|
if (theme !== "default" && theme !== "sakura") {
|
||||||
document.body.classList.remove("sakura-theme");
|
document.body.classList.remove("sakura-theme");
|
||||||
@ -73,15 +82,6 @@ function App() {
|
|||||||
return () => window.removeEventListener("unauthorized", handleUnauthorized);
|
return () => window.removeEventListener("unauthorized", handleUnauthorized);
|
||||||
}, [addToast]);
|
}, [addToast]);
|
||||||
|
|
||||||
const addToast = useCallback((message: string, type: ToastType = "info") => {
|
|
||||||
const id = Date.now();
|
|
||||||
setToasts((prev) => [...prev, { id, message, type }]);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const removeToast = (id: number) => {
|
|
||||||
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchPeople = () => {
|
const fetchPeople = () => {
|
||||||
if (!token) return;
|
if (!token) return;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useState } from "react";
|
import { useState, useRef, useEffect } from "react";
|
||||||
import { LoginRequest, LoginResponse } from "../items";
|
import { LoginRequest, LoginResponse } from "../items";
|
||||||
|
|
||||||
interface LoginProps {
|
interface LoginProps {
|
||||||
@ -6,11 +6,18 @@ interface LoginProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Login({ onLogin }: LoginProps) {
|
export function Login({ onLogin }: LoginProps) {
|
||||||
|
const usernameInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [username, setUsername] = useState("");
|
const [username, setUsername] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
const [fieldErrors, setFieldErrors] = useState<{ username?: string, password?: string }>({});
|
const [fieldErrors, setFieldErrors] = useState<{ username?: string, password?: string }>({});
|
||||||
|
const [isSuccess, setIsSuccess] = useState(false);
|
||||||
|
const [shakeCard, setShakeCard] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
usernameInputRef.current?.focus();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const validateForm = () => {
|
const validateForm = () => {
|
||||||
const errors: { username?: string, password?: string } = {};
|
const errors: { username?: string, password?: string } = {};
|
||||||
@ -24,7 +31,11 @@ export function Login({ onLogin }: LoginProps) {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setError("");
|
setError("");
|
||||||
|
|
||||||
if (!validateForm()) return;
|
if (!validateForm()) {
|
||||||
|
setShakeCard(true);
|
||||||
|
setTimeout(() => setShakeCard(false), 500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
|
|
||||||
@ -44,110 +55,364 @@ export function Login({ onLogin }: LoginProps) {
|
|||||||
const response = LoginResponse.decode(new Uint8Array(buffer));
|
const response = LoginResponse.decode(new Uint8Array(buffer));
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
setIsSuccess(true);
|
||||||
onLogin(response.token);
|
onLogin(response.token);
|
||||||
} else {
|
} else {
|
||||||
setError(response.message || "Login failed");
|
setError(response.message || "Login failed");
|
||||||
|
setShakeCard(true);
|
||||||
|
setTimeout(() => setShakeCard(false), 500);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Login error:", err);
|
console.error("Login error:", err);
|
||||||
setError("An unexpected error occurred. Please try again.");
|
setError("An unexpected error occurred. Please try again.");
|
||||||
|
setShakeCard(true);
|
||||||
|
setTimeout(() => setShakeCard(false), 500);
|
||||||
} finally {
|
} finally {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
handleSubmit(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card" style={{ maxWidth: "400px", margin: "4rem auto" }}>
|
<div
|
||||||
<h2 style={{ textAlign: "center", marginBottom: "2rem" }}>🎮 Login</h2>
|
className="card login-card"
|
||||||
<form onSubmit={handleSubmit} className="form-group">
|
style={{
|
||||||
<div className="form-group">
|
maxWidth: "420px",
|
||||||
<label>Username</label>
|
margin: "6rem auto",
|
||||||
<input
|
padding: "2.5rem",
|
||||||
type="text"
|
background: "linear-gradient(135deg, var(--secondary-bg) 0%, var(--secondary-alt-bg) 100%)",
|
||||||
value={username}
|
position: "relative"
|
||||||
onChange={(e) => {
|
}}
|
||||||
setUsername(e.target.value);
|
>
|
||||||
if (fieldErrors.username) setFieldErrors({ ...fieldErrors, username: undefined });
|
{isSubmitting && (
|
||||||
}}
|
|
||||||
placeholder="Enter your username"
|
|
||||||
style={{
|
|
||||||
borderColor: fieldErrors.username ? "#f44336" : undefined,
|
|
||||||
borderWidth: fieldErrors.username ? "2px" : undefined
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{fieldErrors.username && (
|
|
||||||
<span style={{ color: "#f44336", fontSize: "0.85rem", marginTop: "0.25rem", display: "block" }}>
|
|
||||||
{fieldErrors.username}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="form-group">
|
|
||||||
<label>Password</label>
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
value={password}
|
|
||||||
onChange={(e) => {
|
|
||||||
setPassword(e.target.value);
|
|
||||||
if (fieldErrors.password) setFieldErrors({ ...fieldErrors, password: undefined });
|
|
||||||
}}
|
|
||||||
placeholder="Enter your password"
|
|
||||||
style={{
|
|
||||||
borderColor: fieldErrors.password ? "#f44336" : undefined,
|
|
||||||
borderWidth: fieldErrors.password ? "2px" : undefined
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{fieldErrors.password && (
|
|
||||||
<span style={{ color: "#f44336", fontSize: "0.85rem", marginTop: "0.25rem", display: "block" }}>
|
|
||||||
{fieldErrors.password}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
style={{ marginTop: "1rem", width: "100%", opacity: isSubmitting ? 0.7 : 1, cursor: isSubmitting ? "not-allowed" : "pointer" }}
|
|
||||||
disabled={isSubmitting}
|
|
||||||
>
|
|
||||||
{isSubmitting ? (
|
|
||||||
<>
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
width: "14px",
|
|
||||||
height: "14px",
|
|
||||||
border: "2px solid rgba(255,255,255,0.3)",
|
|
||||||
borderTopColor: "white",
|
|
||||||
borderRadius: "50%",
|
|
||||||
animation: "spin 0.8s linear infinite",
|
|
||||||
display: "inline-block",
|
|
||||||
marginRight: "0.5rem"
|
|
||||||
}}
|
|
||||||
></span>
|
|
||||||
Logging in...
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
"Login"
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{error && (
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "rgba(244, 67, 54, 0.1)",
|
position: "absolute",
|
||||||
border: "1px solid rgba(244, 67, 54, 0.3)",
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
||||||
|
borderRadius: "16px",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
zIndex: 10,
|
||||||
|
backdropFilter: "blur(2px)"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: "48px",
|
||||||
|
height: "48px",
|
||||||
|
border: "4px solid rgba(255, 255, 255, 0.2)",
|
||||||
|
borderTopColor: "white",
|
||||||
|
borderRadius: "50%",
|
||||||
|
animation: "spin 0.8s linear infinite"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isSuccess && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: "50%",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%, -50%)",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "1rem",
|
||||||
|
animation: "fadeInScale 0.5s ease forwards",
|
||||||
|
zIndex: 10
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: "64px",
|
||||||
|
height: "64px",
|
||||||
|
borderRadius: "50%",
|
||||||
|
backgroundColor: "#4caf50",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
fontSize: "2rem",
|
||||||
|
color: "white",
|
||||||
|
boxShadow: "0 0 20px rgba(76, 175, 80, 0.5)"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
✓
|
||||||
|
</div>
|
||||||
|
<span style={{ color: "#4caf50", fontWeight: 600, fontSize: "1.1rem" }}>
|
||||||
|
Success!
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<h2
|
||||||
|
style={{
|
||||||
|
textAlign: "center",
|
||||||
|
marginBottom: "0.5rem",
|
||||||
|
fontSize: "2rem",
|
||||||
|
fontWeight: 700
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
🎮 Login
|
||||||
|
</h2>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
textAlign: "center",
|
||||||
|
color: "var(--text-muted)",
|
||||||
|
marginBottom: "2rem",
|
||||||
|
fontSize: "0.95rem"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Welcome back! Please sign in to continue.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form onSubmit={handleSubmit} className="form-group">
|
||||||
|
<div className="form-group" style={{ marginBottom: "1.5rem" }}>
|
||||||
|
<label
|
||||||
|
style={{
|
||||||
|
display: "block",
|
||||||
|
marginBottom: "0.5rem",
|
||||||
|
fontWeight: 500,
|
||||||
|
color: "var(--text-color)",
|
||||||
|
fontSize: "0.95rem"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Username
|
||||||
|
</label>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "relative",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
left: "0.75rem",
|
||||||
|
color: "var(--text-muted)",
|
||||||
|
pointerEvents: "none",
|
||||||
|
fontSize: "1.1rem"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
👤
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
ref={usernameInputRef}
|
||||||
|
type="text"
|
||||||
|
value={username}
|
||||||
|
onChange={(e) => {
|
||||||
|
setUsername(e.target.value);
|
||||||
|
if (fieldErrors.username) setFieldErrors({ ...fieldErrors, username: undefined });
|
||||||
|
}}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
|
placeholder="Enter your username"
|
||||||
|
aria-label="Username"
|
||||||
|
aria-invalid={!!fieldErrors.username}
|
||||||
|
aria-describedby={fieldErrors.username ? "username-error" : undefined}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
paddingLeft: "2.75rem",
|
||||||
|
paddingRight: "0.75rem",
|
||||||
|
paddingTop: "0.75rem",
|
||||||
|
paddingBottom: "0.75rem",
|
||||||
|
borderColor: fieldErrors.username ? "#f44336" : undefined,
|
||||||
|
borderWidth: fieldErrors.username ? "2px" : "1px",
|
||||||
|
fontSize: "1rem"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{fieldErrors.username && (
|
||||||
|
<span
|
||||||
|
id="username-error"
|
||||||
|
role="alert"
|
||||||
|
style={{
|
||||||
|
color: "#ff6b6b",
|
||||||
|
fontSize: "0.85rem",
|
||||||
|
marginTop: "0.5rem",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "0.25rem"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
⚠️ {fieldErrors.username}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-group" style={{ marginBottom: "2rem" }}>
|
||||||
|
<label
|
||||||
|
style={{
|
||||||
|
display: "block",
|
||||||
|
marginBottom: "0.5rem",
|
||||||
|
fontWeight: 500,
|
||||||
|
color: "var(--text-color)",
|
||||||
|
fontSize: "0.95rem"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Password
|
||||||
|
</label>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "relative",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
left: "0.75rem",
|
||||||
|
color: "var(--text-muted)",
|
||||||
|
pointerEvents: "none",
|
||||||
|
fontSize: "1.1rem"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
🔒
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
value={password}
|
||||||
|
onChange={(e) => {
|
||||||
|
setPassword(e.target.value);
|
||||||
|
if (fieldErrors.password) setFieldErrors({ ...fieldErrors, password: undefined });
|
||||||
|
}}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
|
placeholder="Enter your password"
|
||||||
|
aria-label="Password"
|
||||||
|
aria-invalid={!!fieldErrors.password}
|
||||||
|
aria-describedby={fieldErrors.password ? "password-error" : undefined}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
paddingLeft: "2.75rem",
|
||||||
|
paddingRight: "0.75rem",
|
||||||
|
paddingTop: "0.75rem",
|
||||||
|
paddingBottom: "0.75rem",
|
||||||
|
borderColor: fieldErrors.password ? "#f44336" : undefined,
|
||||||
|
borderWidth: fieldErrors.password ? "2px" : "1px",
|
||||||
|
fontSize: "1rem"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{fieldErrors.password && (
|
||||||
|
<span
|
||||||
|
id="password-error"
|
||||||
|
role="alert"
|
||||||
|
style={{
|
||||||
|
color: "#ff6b6b",
|
||||||
|
fontSize: "0.85rem",
|
||||||
|
marginTop: "0.5rem",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "0.25rem"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
⚠️ {fieldErrors.password}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
style={{
|
||||||
|
marginTop: "0.5rem",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0.875rem",
|
||||||
|
fontSize: "1rem",
|
||||||
|
fontWeight: 600,
|
||||||
|
opacity: isSubmitting ? 0.7 : 1,
|
||||||
|
cursor: isSubmitting ? "not-allowed" : "pointer",
|
||||||
|
background: "linear-gradient(135deg, var(--accent-color) 0%, var(--secondary-accent) 100%)",
|
||||||
|
border: "none",
|
||||||
|
transition: "transform 0.1s, box-shadow 0.2s"
|
||||||
|
}}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
onMouseEnter={(e) => {
|
||||||
|
if (!isSubmitting) {
|
||||||
|
e.currentTarget.style.transform = "translateY(-1px)";
|
||||||
|
e.currentTarget.style.boxShadow = "0 4px 12px rgba(9, 109, 192, 0.4)";
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onMouseLeave={(e) => {
|
||||||
|
if (!isSubmitting) {
|
||||||
|
e.currentTarget.style.transform = "translateY(0)";
|
||||||
|
e.currentTarget.style.boxShadow = "none";
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onMouseDown={(e) => {
|
||||||
|
if (!isSubmitting) {
|
||||||
|
e.currentTarget.style.transform = "translateY(0)";
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<div
|
||||||
|
role="alert"
|
||||||
|
style={{
|
||||||
|
backgroundColor: "rgba(244, 67, 54, 0.15)",
|
||||||
|
border: "1px solid rgba(244, 67, 54, 0.4)",
|
||||||
color: "#ff6b6b",
|
color: "#ff6b6b",
|
||||||
padding: "1rem",
|
padding: "0.875rem 1rem",
|
||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
marginTop: "1rem",
|
marginTop: "1.5rem",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
fontSize: "0.9rem"
|
fontSize: "0.9rem",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
gap: "0.5rem"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
⚠️ {error}
|
⚠️ {error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<style>{`
|
<style>{`
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
to { transform: rotate(360deg); }
|
to { transform: rotate(360deg); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes fadeInScale {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translate(-50%, -40%) scale(0.8);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translate(-50%, -50%) scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card {
|
||||||
|
animation: ${shakeCard ? "shake 0.5s ease" : "none"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes shake {
|
||||||
|
0%, 100% {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
20%, 60% {
|
||||||
|
transform: translateX(-8px);
|
||||||
|
}
|
||||||
|
40%, 80% {
|
||||||
|
transform: translateX(8px);
|
||||||
|
}
|
||||||
|
}
|
||||||
`}</style>
|
`}</style>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user