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

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

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

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

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