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

import SurprisesNotification from "./SurprisesNotification"

export default async function Surprises() {
  const user = await getProfile()

  if (!user || "error" in user) {
    return null
  }

  const surprises = await serverClient().contentstack.rewards.surprises()

  if (!surprises) {
    return null
  }

  return (
    <SurprisesNotification
      surprises={surprises}
      membershipNumber={user.membership?.membershipNumber}
    />
  )
}
