import Body from "@/components/TempDesignSystem/Text/Body"
import { getIntl } from "@/i18n"
import { getMembership } from "@/utils/user"

import type { UserProps } from "@/types/components/myPages/user"

export default async function ExpiringPoints({ user }: UserProps) {
  const { formatMessage } = await getIntl()
  const membership = getMembership(user.memberships)
  // TODO - add correct points when available from API
  if (!membership /* || !membership.expiringPoints*/) {
    //  TODO: handle this case?
    return null
  }

  return (
    <section>
      <Body color="white" textTransform="bold" textAlign="center">
        {membership.currentPoints} {formatMessage({ id: "points expiring by" })}{" "}
        {membership.expirationDate}
      </Body>
    </section>
  )
}
