import { MembershipLevelEnum } from "@/constants/membershipLevels"

import { getMembershipLevelObject } from "@/utils/membershipLevel"
import { getMembership } from "@/utils/user"

import PointsContainer from "./Container"
import { NextLevelPointsColumn, YourPointsColumn } from "./PointsColumn"

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

export default async function Points({ user, lang }: UserProps & LangParams) {
  const membership = getMembership(user.memberships)
  const nextLevel = getMembershipLevelObject(
    membership?.nextLevel as MembershipLevelEnum,
    lang
  )

  return (
    <PointsContainer>
      <YourPointsColumn points={membership?.currentPoints} />
      {nextLevel && (
        <NextLevelPointsColumn
          points={membership?.pointsRequiredToNextlevel}
          subtitleParam={nextLevel.name}
        />
      )}
    </PointsContainer>
  )
}
