/* Login — email + password, with password reset by email */ function AuthShell({ children, foot }) { React.useEffect(() => { if (window.lucide) window.lucide.createIcons(); }); return (
{children}
); } const Err = ({ children }) => children ?
{children}
: null; function LoginPage() { const isReset = /[?&]reset=1/.test(location.search); const [mode, setMode] = React.useState(isReset ? 'setpw' : 'login'); const [email, setEmail] = React.useState(''); const [pw, setPw] = React.useState(''); const [pw2, setPw2] = React.useState(''); const [show, setShow] = React.useState(false); const [err, setErr] = React.useState(''); const [busy, setBusy] = React.useState(false); const [role, setRole] = React.useState('epc'); const isEmail = v => /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(v.trim()); const enter = () => { try { localStorage.setItem('lt_role', role); localStorage.setItem('lt_signed_in', '1'); } catch (e) {} window.location.href = 'dashboard.html'; }; const signIn = async () => { const v = email.trim(); if (!isEmail(v)) { setErr('Enter a valid email address.'); return; } if (!pw) { setErr('Enter your password.'); return; } setErr(''); setBusy(true); try { const u = await LTAuth.signIn(v, pw); try { localStorage.setItem('lt_verified', LTAuth.verified(u) ? '1' : '0'); } catch (e) {} /* staff accounts land in the admin panel, not the client dashboard */ const staff = await LTAuth.staffRole(); if (staff) { try { localStorage.setItem('lt_admin_mode', 'live'); } catch (e) {} window.location.href = 'admin/panel.html'; return; } enter(); } catch (e) { const m = e.message || ''; setErr(/not confirmed|confirm/i.test(m) ? 'This account is not confirmed yet. Open the verification link we emailed you, then sign in.' : (/invalid/i.test(m) ? 'Email or password is incorrect.' : (m || 'Could not sign in.'))); setBusy(false); } }; const sendReset = async () => { const v = email.trim(); if (!isEmail(v)) { setErr('Enter the email address on your account.'); return; } setErr(''); setBusy(true); try { await LTAuth.sendReset(v); setMode('resetsent'); } catch (e) { setErr(e.message || 'Could not send the reset email.'); } setBusy(false); }; const savePw = async () => { if (pw.length < 8) { setErr('Use at least eight characters.'); return; } if (pw !== pw2) { setErr('The two passwords do not match.'); return; } setErr(''); setBusy(true); try { await LTAuth.setPassword(pw); enter(); } catch (e) { setErr(e.message || 'Could not set the password. Request a fresh reset link.'); setBusy(false); } }; const pwField = (label, val, setVal, ph) => (
{ setVal(e.target.value); setErr(''); }} onKeyDown={e => e.key === 'Enter' && (mode === 'login' ? signIn() : savePw())} style={{ paddingRight: 62 }} />
); return ( No account yet? Register your business}> {mode === 'login' && ( Business log in

Sign in to your account

Use the email address and password you set when you registered.

{ setEmail(e.target.value); setErr(''); }} placeholder="you@company.com" onKeyDown={e => e.key === 'Enter' && signIn()} />
{pwField('Password', pw, setPw, 'Your password')}
{err} { e.preventDefault(); setErr(''); setMode('forgot'); }}>Forgot your password?
Exploring the platform? { e.preventDefault(); enter(); }}>Open the dashboard with demo data.

Labour Tech staff? Sign in to the admin panel.

)} {mode === 'forgot' && ( Password reset

Reset your password

We email a link to the address on your account. It opens this page and lets you set a new password.

{ setEmail(e.target.value); setErr(''); }} placeholder="you@company.com" onKeyDown={e => e.key === 'Enter' && sendReset()} />
{err} { e.preventDefault(); setErr(''); setMode('login'); }}>Back to log in

No longer have access to that address? { e.preventDefault(); setMode('recover'); }}>Recover the account with your GST record.

)} {mode === 'resetsent' && (
Email sent

Check {email}.

Open the link in that email to set a new password. It expires in one hour. Check spam if it has not arrived in a few minutes.

{ e.preventDefault(); setMode('login'); }}>Back to log in
)} {mode === 'setpw' && ( Password reset

Set a new password

At least eight characters. You will use this with your email address from now on.

{pwField('New password', pw, setPw, 'At least 8 characters')} {pwField('Confirm password', pw2, setPw2, 'Type it again')} {err} Back to log in
)} {mode === 'recover' && ( Account recovery

Can't access your registered address?

Tell us your business details and we will verify you against your GST or PAN record, then move the account to a new address.

{ e.preventDefault(); setMode('login'); }}>Back to log in
)} {mode === 'sent' && (
Request received

We will call you within one working day.

Our team verifies the request against your GST or PAN record before moving the account. Keep the certificate handy.

Back to the website
)}
); } LTMount('login', );