import { useState } from 'react'; import { Link, useNavigate, useSearchParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { login, initiateGoogleLogin } from '../services/authService'; import { useAuthStore } from '../store/useAuthStore'; import { useLocalizedHref } from '../i18n/useLocalizedNavigate'; import { useSEO } from '../utils/useSEO'; import { trackLogin } from '../utils/analytics'; export const LoginPage: React.FC = () => { const { t } = useTranslation(); const localize = useLocalizedHref(); useSEO({ title: 'Sign In — Velxio', description: 'Sign in to your Velxio account to save projects and access your Arduino simulations.', url: 'https://velxio.dev/login', noindex: true, }); const navigate = useNavigate(); const [searchParams] = useSearchParams(); const setUser = useAuthStore((s) => s.setUser); 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(); setError(''); setLoading(true); try { const user = await login(email, password); trackLogin('email'); setUser(user); navigate(searchParams.get('redirect') || localize('/')); } catch (err: any) { setError(err?.response?.data?.detail || t('auth.login.failed')); } finally { setLoading(false); } }; return (

{t('auth.login.title')}

{t('auth.login.subtitle')}

{error &&
{error}
}
setEmail(e.target.value)} required className="ap-input" autoFocus />
setPassword(e.target.value)} required className="ap-input" />
{t('auth.login.or')}

{t('auth.login.noAccount')}{' '} {t('header.auth.signUp')}

); };