import { redirect } from 'next/navigation';
import { getAuthService } from '@/lib/auth';
import OnboardingWizard from '@/components/onboarding/OnboardingWizard';

export const dynamic = 'force-dynamic';

export default async function OnboardingPage() {
  const authService = getAuthService();
  const session = await authService.getCurrentSession();

  if (!session) {
    redirect('/auth/iracing?returnTo=/onboarding');
  }

  const primaryDriverId = session.user.primaryDriverId ?? '';

  if (primaryDriverId) {
    redirect('/dashboard');
  }

  return (
    <main className="min-h-screen bg-deep-graphite">
      <OnboardingWizard />
    </main>
  );
}