import { useState } from 'react' import { useNavigate, useLocation } from 'react-router-dom' import { Hotel } from 'lucide-react' export function Login() { const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const [loading, setLoading] = useState(false) const navigate = useNavigate() const location = useLocation() const from = (location.state as { from?: string })?.from || '/' async function submit(e: React.FormEvent) { e.preventDefault() setLoading(true) setError('') try { const res = await fetch('/api/auth/login', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, password }), }) if (res.ok) navigate(from, { replace: true }) else setError('Invalid email or password') } catch { setError('Connection error — please try again') } finally { setLoading(false) } } return (

MANAGE

{import.meta.env.VITE_HOTEL_NAME}

setEmail(e.target.value)} placeholder="Email address" required autoComplete="email" style={input} /> setPassword(e.target.value)} placeholder="Password" required autoComplete="current-password" style={input} /> {error &&

{error}

}

New employee?{' '} Register with your Workforce email

) } const input: React.CSSProperties = { background: 'var(--navy-dark)', border: '1px solid var(--surface-2)', borderRadius: '8px', color: 'var(--text)', padding: '0.7rem 0.875rem', fontSize: '1rem', width: '100%', outline: 'none', }