'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 (
Track. Lift. Dominate.
Demo: admin@example.com / password