import { Suspense } from 'react'
import { redirect } from 'next/navigation'
import { isSetupRequired } from '@/lib/setup'
import { LoginForm, LoginFormSkeleton } from './login-form'

// Prevent static generation - requires database check at runtime
export const dynamic = 'force-dynamic'

export default async function LoginPage() {
  // Check if initial setup is required
  const setupRequired = await isSetupRequired()
  if (setupRequired) {
    redirect('/setup')
  }

  return (
    <div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
      <Suspense fallback={<LoginFormSkeleton />}>
        <LoginForm />
      </Suspense>
    </div>
  )
}
