import { redirect } from "next/navigation"
import { auth } from "@/lib/auth"
import { SettingsClient } from "@/components/settings/settings-client"

/**
 * Server component so the role is known before the first render. Passing isOwner
 * down avoids the flash of an AI Gateway card that useSession() alone would give,
 * and lets the client skip the owner-only key request entirely.
 */
export default async function SettingsPage() {
  const session = await auth()
  if (!session?.user?.id) redirect("/login")

  return <SettingsClient isOwner={session.user.role === "OWNER"} />
}
