/* TargiApp — ekran logowania kodem PIN (4 cyfry) */ function LoginScreen() { const store = useStore(); const [pin, setPin] = useState(""); const [err, setErr] = useState(false); function press(d) { if (err) setErr(false); if (pin.length >= 4) return; const next = pin + d; setPin(next); if (next.length === 4) { setTimeout(() => { Promise.resolve(store.login(next)).then((ok) => { if (!ok) { setErr(true); setPin(""); } }); }, 120); } } function back() { setErr(false); setPin((p) => p.slice(0, -1)); } useEffect(() => { function onKey(e) { if (e.key >= "0" && e.key <= "9") press(e.key); else if (e.key === "Backspace") back(); } window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }); return (
EPS
TargiApp
Harmonogram targowy
Zaloguj się swoim kodem PIN
{[0, 1, 2, 3].map((i) => (
))}
{err ? "Nieprawidłowy kod PIN" : ""}
{[1, 2, 3, 4, 5, 6, 7, 8, 9].map((n) => ( ))}
Demo: zaloguj się jako administrator PIN-em 1111
pozostałe kody PIN są w panelu „Użytkownicy".
); } Object.assign(window, { LoginScreen });