'use client';
import { Loader2 } from 'lucide-react';
import { useRouter } from 'next/navigation';
import OnboardingWizard from '@/components/onboarding/OnboardingWizard';
import { useCurrentDriver } from '@/hooks/useDriverService';
import { useAuth } from '@/lib/auth/AuthContext';
export default function OnboardingPage() {
const router = useRouter();
const { session } = useAuth();
const { data: driver, isLoading } = useCurrentDriver();
// If user is not authenticated, redirect to login
if (!session) {
router.replace('/auth/login?returnTo=/onboarding');
return null;
}
// Show loading while checking driver data
if (isLoading) {
return (
);
}
// If driver profile exists, onboarding is complete – go to dashboard
if (driver) {
router.replace('/dashboard');
return null;
}
return (
);
}