// screen-login.jsx — login / register gate const { useState: useLS } = React; function LoginScreen({ onLogin }) { const [mode, setMode] = useLS('login'); // 'login' | 'register' const [email, setEmail] = useLS('heba@ideamint.io'); const [password, setPassword] = useLS('password123'); const [name, setName] = useLS(''); const [role, setRole] = useLS('Employee'); const [error, setError] = useLS(''); const [loading, setLoading] = useLS(false); async function submit(e) { e.preventDefault(); setError(''); setLoading(true); try { let result; if (mode === 'login') { result = await window.API.login(email, password); } else { result = await window.API.register(name, email, password, role); } localStorage.setItem('ims_token', result.token); onLogin(result.user, result.token); } catch (err) { setError(err.message); } finally { setLoading(false); } } return (
{/* Logo */}
IdeaMint
{mode === 'login' ? 'Welcome back' : 'Create account'}
{mode === 'login' ? 'Sign in to your Ideas Management System' : 'Join the IdeaMint platform'}
{mode === 'register' && ( <> setName(e.target.value)} required style={{ width: '100%', marginBottom: 16, boxSizing: 'border-box' }} /> setRole(e.target.value)} style={{ width: '100%', marginBottom: 16, boxSizing: 'border-box' }} /> )} setEmail(e.target.value)} required style={{ width: '100%', marginBottom: 16, boxSizing: 'border-box' }} /> setPassword(e.target.value)} required style={{ width: '100%', marginBottom: 8, boxSizing: 'border-box' }} /> {error && (
{error}
)} {mode === 'login' && (
Demo: heba@ideamint.io / password123  ·  Admin: admin@ideamint.io
)}
{mode === 'login' ? "Don't have an account? " : 'Already have an account? '}
); } window.LoginScreen = LoginScreen;