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 (
Semiconductor Patent Analytics Dashboard