import { DashboardErrorBoundary } from "@/components/dashboard/DashboardErrorBoundary"
import { getMembersPageInitData } from "./data"
import { MembersClient } from "./members-client"

export default async function OrganizationMembersPage() {
  const initData = await getMembersPageInitData()

  // No session — auth middleware will redirect
  if (!initData) {
    return null
  }

  return (
    <DashboardErrorBoundary>
      <MembersClient
        initialUserId={initData.userId}
        initialOrgId={initData.orgId}
        initialMembers={initData.members as any}
        initialUserRole={initData.currentUserRole}
      />
    </DashboardErrorBoundary>
  )
}
