import { useState } from 'react'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import { useAuth } from '../context/AuthContext'; import { LogIn, Mail, Lock, AlertCircle } from 'lucide-react'; export function Login() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const { login } = useAuth(); const navigate = useNavigate(); const location = useLocation(); const from = (location.state as { from?: { pathname: string } })?.from?.pathname || '/analysis'; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setIsLoading(true); try { await login(email, password); navigate(from, { replace: true }); } catch (err) { setError(err instanceof Error ? err.message : 'Invalid email or password'); } finally { setIsLoading(false); } }; return (
{/* Brand */}

SPARC

Semiconductor Patent Analytics Dashboard

{/* Login Card */}

Sign in to your account

{error && (
{error}
)}
setEmail(e.target.value)} required className="w-full bg-bg-dark/80 border border-primary/30 rounded-xl pl-10 pr-4 py-3 text-text-primary placeholder-text-secondary/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-all" placeholder="you@example.com" />
setPassword(e.target.value)} required className="w-full bg-bg-dark/80 border border-primary/30 rounded-xl pl-10 pr-4 py-3 text-text-primary placeholder-text-secondary/50 focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-all" placeholder="Enter your password" />
Don't have an account? Sign up
); }