'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { authApi } from '@/lib/api'; import { useAuthStore } from '@/store/authStore'; export default function LoginPage() { const router = useRouter(); const setUser = useAuthStore((state) => state.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 response = await authApi.login({ username: email, password }); localStorage.setItem('access_token', response.access_token); // Redirect to dashboard router.push('/dashboard'); } catch (err: any) { setError(err.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 (err: any) { setError('Failed to initialize Google login'); } }; return (

POP3 to Gmail Forwarder

Sign in to your account

{error && (

{error}

)}
setEmail(e.target.value)} className="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm" placeholder="Email address" />
setPassword(e.target.value)} className="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm" placeholder="Password" />
Or continue with

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

); }