'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { loginAction } from './actions'; 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 result = await loginAction(email, password); if (result.error) { setError(result.error); setLoading(false); return; } if (result.success) { router.push('/main/dashboard'); } } catch (err) { setError('An unexpected error occurred'); setLoading(false); } }; return (

Workout Planner

Track. Lift. Dominate.

setEmail(e.target.value)} required className="w-full px-4 py-2.5 rounded border border-zinc-700 bg-zinc-800 text-white placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-0 focus:border-white transition-all" disabled={loading} />
setPassword(e.target.value)} required className="w-full px-4 py-2.5 rounded border border-zinc-700 bg-zinc-800 text-white placeholder:text-zinc-500 focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-0 focus:border-white transition-all" disabled={loading} />
{error && (
{error}
)}

Demo: admin@example.com / password

); }