'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { authApi } from '@/lib/api'; import { BrandMark } from '@/components/BrandMark'; export default function LoginPage() { const router = useRouter(); 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 response = await authApi.login({ username: email, password }); localStorage.setItem('access_token', response.access_token); // Redirect to dashboard router.push('/dashboard'); } catch (err: unknown) { const error = err as { response?: { data?: { detail?: string } } }; setError(error.response?.data?.detail || 'Login failed. Please try again.'); } finally { setLoading(false); } }; const handleGoogleLogin = async () => { try { const redirectUri = `${window.location.origin}/auth/callback`; const authUrl = await authApi.getGoogleAuthUrl(redirectUri); window.location.href = authUrl; } catch { setError('Failed to initialize Google login'); } }; return (

Sign in

Continue to your mailbox delivery dashboard.

{error && (

{error}

)}
setEmail(e.target.value)} className="ic-focus mt-1 relative block w-full rounded-md border border-[#b8c8df] px-3 py-2.5 text-slate-950 placeholder-slate-400 focus:border-[#0b63f6] sm:text-sm" placeholder="Email address" />
setPassword(e.target.value)} className="ic-focus mt-1 relative block w-full rounded-md border border-[#b8c8df] px-3 py-2.5 text-slate-950 placeholder-slate-400 focus:border-[#0b63f6] sm:text-sm" placeholder="Password" />
Or continue with

Don't have an account?{' '} Sign up

Privacy Policy Terms Impressum Datenschutz
); }