Feat/SW-165 correct labels * feat(SW-165): sort friend transactions and return additional properties * feat(SW-165): Added points being calculated label * feat(SW-165): added transactionDate for transactions without checkinDate * feat(SW-165): Updated description copy for various reward types * feat(SW-165): filter out expired transactions * feat(SW-165): removed Mobile table and unified them into Table instead * feat(SW-165): Added bookingUrl to friend transactions * fix(SW-165): style fixes * fix(SW-165): fix issues from merge * fix(SW-165): remove comment * fix(SW-165): fixed booking urls not being set and smaller fixes * fix(SW-165): added comment regarding 'BALFWD' Approved-by: Michael Zetterberg Approved-by: Christel Westerberg
41 lines
984 B
TypeScript
41 lines
984 B
TypeScript
import { useIntl } from "react-intl"
|
|
|
|
import { Lang } from "@/constants/languages"
|
|
|
|
import { awardPointsVariants } from "./awardPointsVariants"
|
|
|
|
import type { AwardPointsVariantProps } from "@/types/components/myPages/myPage/earnAndBurn"
|
|
|
|
export default function AwardPoints({
|
|
awardPoints,
|
|
isCalculated,
|
|
}: {
|
|
awardPoints: number
|
|
isCalculated: boolean
|
|
}) {
|
|
let variant: AwardPointsVariantProps["variant"] = undefined
|
|
const intl = useIntl()
|
|
|
|
if (isCalculated) {
|
|
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}>
|
|
{isCalculated
|
|
? formatter.format(awardPoints)
|
|
: intl.formatMessage({ id: "Points being calculated" })}
|
|
</td>
|
|
)
|
|
}
|