import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { motion } from 'framer-motion'; import { useAuthStore } from '../../store/authStore'; import { api } from '../lib/apiClient'; import styles from './LoginPage.module.css'; /** * LoginPage * Clean, branded login. Email + password → JWT → AuthStore → /command. * No "register" link. No "forgot password" noise. Single intent. */ export function LoginPage() { const navigate = useNavigate(); const { setSession } = useAuthStore(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!email || !password) return; setLoading(true); setError(''); try { const { access_token, user } = await api.post<{ access_token: string; user: any }>( '/auth/login', { email, password } ); setSession(user, access_token); navigate('/command', { replace: true }); } catch (err: any) { setError('Invalid credentials. Please try again.'); } finally { setLoading(false); } }; return (
Sign in to your workspace.