import { Lang } from "@/constants/languages"
import {
  MembershipLevelEnum,
  membershipLevels,
} from "@/constants/membershipLevels"

import levelsData from "@/components/Loyalty/Blocks/DynamicContent/LoyaltyLevels/data"

export function getMembershipLevelObject(
  membershipLevel: MembershipLevelEnum,
  lang: Lang,
  level: "currentLevel" | "nextLevel" = "currentLevel"
) {
  let levelNumber = membershipLevels[membershipLevel]
  if (level === "nextLevel") {
    levelNumber += 1
  }

  return levelsData[lang].levels.find((level) => level.level === levelNumber)
}
