41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
'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 (
|
||
<main className="min-h-screen bg-deep-graphite flex items-center justify-center">
|
||
<Loader2 className="w-8 h-8 text-primary-blue animate-spin" />
|
||
</main>
|
||
);
|
||
}
|
||
|
||
// If driver profile exists, onboarding is complete – go to dashboard
|
||
if (driver) {
|
||
router.replace('/dashboard');
|
||
return null;
|
||
}
|
||
|
||
return (
|
||
<main className="min-h-screen bg-deep-graphite">
|
||
<OnboardingWizard />
|
||
</main>
|
||
);
|
||
} |