// app/login/page.tsx 'use client'; import Link from 'next/link'; import React, { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import ComponentsAuthLoginForm from '@/components/auth/components-auth-login-form'; export default function LoginPage() { const router = useRouter(); const [ready, setReady] = useState(false); // gate to avoid UI flash useEffect(() => { let cancelled = false; (async () => { try { const res = await fetch('/api/auth/me', { method: 'GET', cache: 'no-store', credentials: 'include', // safe even if same-origin }); if (!cancelled && res.ok) { router.replace('/adminDashboard'); return; } } catch { // ignore errors; just show the form } if (!cancelled) setReady(true); })(); return () => { cancelled = true; }; }, [router]); if (!ready) return null; // or a small spinner if you prefer return (
Enter your email and password to access your account.
{/* Login form */}