Files
gridpilot.gg/apps/website/app/onboarding/page.tsx
2025-12-21 01:45:17 +01:00

41 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'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>
);
}