import { redirect } from "next/navigation";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth/auth-options";
import { OnboardingWizard } from "@/components/features/auth/OnboardingWizard";
import { loginRedirectUrl } from "@/lib/auth/post-auth-path";

export default async function OnboardingPage() {
  const session = await getServerSession(authOptions);

  if (!session?.user?.id) {
    redirect(loginRedirectUrl("SessionRequired"));
  }

  if (session.user.workspaceId) {
    redirect("/app/dashboard");
  }

  return (
    <div className="flex min-h-screen items-center justify-center bg-bg p-10">
      <div className="w-full max-w-[400px] rounded-lg border border-border bg-card p-8 shadow">
        <OnboardingWizard />
      </div>
    </div>
  );
}
