import { Lang } from "@/constants/languages"

import { awardPointsVariants } from "./awardPointsVariants"

import type {
  AwardPointsProps,
  AwardPointsVariantProps,
} from "@/types/components/myPages/myPage/earnAndBurn"

export default function AwardPoints({ awardPoints }: AwardPointsProps) {
  let variant: AwardPointsVariantProps["variant"] = undefined
  if (awardPoints > 0) {
    variant = "addition"
  } else if (awardPoints < 0) {
    variant = "negation"
    awardPoints = Math.abs(awardPoints)
  }

  const classNames = awardPointsVariants({
    variant,
  })

  // sv hardcoded to force space on thousands
  const formatter = new Intl.NumberFormat(Lang.sv)
  return <td className={classNames}>{formatter.format(awardPoints)} pts</td>
}
