import { getSession } from "@auth0/nextjs-auth0"
import { redirect } from "next/navigation"
import { ReactNode } from "react"
import { hasCompletedOnboarding } from "@codeflash-ai/common"

export default async function DashboardLayout({ children }: { children: ReactNode }) {
  const session = await getSession()
  if (!session) return null

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

  return <main>{children}</main>
}
