import { getSession } from "@auth0/nextjs-auth0"
import { redirect } from "next/navigation"
import { hasCompletedOnboarding } from "@codeflash-ai/common"
import { APP_ROUTES } from "@/lib/types"

export default async function RootPage() {
  const session = await getSession()
  if (!session) return null

  const completedOnboarding = await hasCompletedOnboarding(session.user.sub)
  if (!completedOnboarding) {
    redirect("/onboarding")
  }

  redirect(APP_ROUTES.API_KEYS)
}
