import { redirect } from 'next/navigation';
import { hasAnyUser } from '@/src/lib/db/user';
import SetupForm from '@/src/components/SetupForm';

export const dynamic = 'force-dynamic';

export default async function SetupPage() {
  try {
    const hasUser = await hasAnyUser();

    if (hasUser) {
      redirect('/login');
    }
  } catch (error) {
    console.warn('Failed to determine user setup status on /setup:', error);
  }

  return <SetupForm />;
}
