/* 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 (