import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" import { PointType } from "@scandic-hotels/common/constants/pointType" import { logger } from "@scandic-hotels/common/logger" import { IntlShape } from "react-intl" export function getCurrencyText( intl: IntlShape, currency: string, price: number, pointsType?: PointType | null ) { if (currency !== CurrencyEnum.POINTS) return currency if (!pointsType) return currency switch (pointsType) { case PointType.SCANDIC: { return intl.formatMessage( { id: "price.numberOfScandicPoints", defaultMessage: "{numberOfScandicPoints, plural, one {Point} other {Points}}", }, { numberOfScandicPoints: price, } ) } case PointType.EUROBONUS: { return intl.formatMessage( { id: "price.numberOfEuroBonusPoints", defaultMessage: "{numberOfEuroBonusPoints, plural, one {EB Point} other {EB Points}}", }, { numberOfEuroBonusPoints: price, } ) } default: { const _exhaustiveCheck: never = pointsType void _exhaustiveCheck logger.warn(`Unknown point type provided: ${pointsType}`) return currency } } }