48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
import { useState } from "react";
|
|
|
|
export default function LoginPage({ onSuccess }) {
|
|
const [password, setPassword] = useState("");
|
|
const [error, setError] = useState("");
|
|
|
|
const handleLogin = () => {
|
|
if (password === "volleyballtgl") {
|
|
sessionStorage.setItem("authenticated", "true");
|
|
onSuccess();
|
|
} else {
|
|
setError("Falsches Passwort");
|
|
}
|
|
};
|
|
|
|
const handleKeyDown = (e) => {
|
|
if (e.key === "Enter") {
|
|
handleLogin();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="h-screen flex flex-col items-center justify-center bg-gray-100 dark:bg-gray-900 px-4">
|
|
<div className="bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 p-6 rounded shadow-md w-full max-w-sm">
|
|
<h1 className="text-2xl font-bold mb-4 text-center">Zugang</h1>
|
|
<input
|
|
type="password"
|
|
value={password}
|
|
onChange={(e) => {
|
|
setPassword(e.target.value);
|
|
setError("");
|
|
}}
|
|
onKeyDown={handleKeyDown}
|
|
placeholder="Passwort eingeben"
|
|
className="w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded mb-3 bg-white dark:bg-gray-700 text-black dark:text-white placeholder-gray-400 dark:placeholder-gray-300"
|
|
/>
|
|
{error && <p className="text-red-500 text-sm mb-2">{error}</p>}
|
|
<button
|
|
onClick={handleLogin}
|
|
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 rounded transition"
|
|
>
|
|
Weiter
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|