src/components/auth/onboarding-page-content.tsx
Rama main · réplica de lectura del repositorio original.
"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";
import { useAuth } from "@/contexts/AuthContext";
import { ProfileCompletionForm } from "@/components/auth/profile-completion-form";
import { StandaloneShell } from "@/components/layout/standalone-shell";
// Profile completion - shared by both authentication methods (email magic link and
// Google). Only reachable with an in-memory onboarding session set by
// `/auth/verify` or the Google button (see `AuthContext`); there is nothing to
// recover if the page is loaded directly (e.g. a refresh), since the session is
// intentionally never persisted - the visitor is sent back to sign in again.
export function OnboardingPageContent() {
const { onboarding, isAuthenticated, isLoading } = useAuth();
const router = useRouter();
useEffect(() => {
if (isLoading) return;
if (isAuthenticated) {
router.replace("/home");
return;
}
if (!onboarding) {
router.replace("/");
}
}, [onboarding, isAuthenticated, isLoading, router]);
if (!onboarding) {
return null;
}
return (
<StandaloneShell>
<ProfileCompletionForm />
<div className="mt-8 text-center text-sm text-muted-foreground">
<p>
By creating an account, you agree to our{" "}
<Link href="/terms" className="underline hover:text-foreground">
Terms of Service
</Link>{" "}
and{" "}
<Link href="/privacy" className="underline hover:text-foreground">
Privacy Policy
</Link>
</p>
</div>
</StandaloneShell>
);
}