/* global React, L, MZ */ const { useState, useEffect, useRef } = React; function LoginModal({ onClose, onLoggedIn, onToast }) { const [mode, setMode] = useState('signin'); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [handle, setHandle] = useState(''); const [name, setName] = useState(''); const [rodo, setRodo] = useState(false); const [busy, setBusy] = useState(false); const [err, setErr] = useState(null); const submit = async (e) => { e.preventDefault(); setErr(null); setBusy(true); try { if (mode === 'signin') { await MZ.signIn({ email, password }); } else { if (!rodo) throw new Error('Musisz zaakceptować regulamin i politykę prywatności'); if (!/^[a-z0-9_]{3,20}$/.test(handle)) throw new Error('Nazwa: małe litery, cyfry, podkreślniki, 3–20 znaków'); if (password.length < 8) throw new Error('Hasło musi mieć min. 8 znaków'); await MZ.signUp({ email, password, handle, name }); onToast('Konto utworzone — jesteś zalogowany.'); } onLoggedIn(); } catch (e2) { setErr(e2.message || 'Błąd'); } setBusy(false); }; return (