import { getMembershipLevelSafely } from "@/lib/trpc/memoizedRequests"
import { serverClient } from "@/lib/trpc/server"

import SectionWrapper from "../SectionWrapper"
import OverviewTableClient from "./Client"

import type { OverviewTableProps } from "@/types/components/blocks/dynamicContent"

export default async function OverviewTable({
  dynamic_content,
}: OverviewTableProps) {
  const caller = await serverClient()
  const [levels, membershipLevel] = await Promise.all([
    caller.contentstack.rewards.all(),
    getMembershipLevelSafely(),
  ])

  return (
    <SectionWrapper dynamic_content={dynamic_content}>
      <OverviewTableClient
        levels={levels}
        activeMembership={membershipLevel?.membershipLevel ?? null}
      />
    </SectionWrapper>
  )
}
