Merged in fix/SW-3021-vouchers (pull request #2719)

fix(SW-3021): add pluralization support for vouchers

* fix(SW-3021): add pluralization support for vouchers


Approved-by: Anton Gunnarsson
This commit is contained in:
Bianca Widstam
2025-08-28 08:27:03 +00:00
parent 997f928f2b
commit 0e00e8eaf1
17 changed files with 160 additions and 131 deletions

View File

@@ -1,7 +1,6 @@
import { cx } from "class-variance-authority"
import { useIntl } from "react-intl"
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
import { Typography } from "@scandic-hotels/design-system/Typography"
@@ -21,14 +20,11 @@ export default function LargeRow({
price,
}: RowProps) {
const intl = useIntl()
const isVoucherRate = price.local.currency === CurrencyEnum.Voucher
const currency = isVoucherRate
? intl.formatMessage({ defaultMessage: "Voucher" })
: price.local.currency
const totalPrice = formatPrice(
intl,
price.local.price,
currency,
price.local.currency,
price.local.additionalPrice,
price.local.additionalPriceCurrency
)

View File

@@ -1,6 +1,7 @@
"use client"
import { useIntl } from "react-intl"
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
import BoldRow from "../Bold"
@@ -35,19 +36,21 @@ export default function VoucherPrice({
return null
}
const voucherCurrency = intl.formatMessage({ defaultMessage: "Voucher" })
const averagePriceTitle = intl.formatMessage({
defaultMessage: "Average price per night",
})
const averagePricePerNight = `${price.numberOfVouchers / nights} ${voucherCurrency}`
const averagePricePerNight = formatPrice(
intl,
price.numberOfVouchers / nights,
CurrencyEnum.Voucher
)
return (
<>
<BoldRow
label={intl.formatMessage({ defaultMessage: "Room charge" })}
value={formatPrice(intl, price.numberOfVouchers, voucherCurrency)}
value={formatPrice(intl, price.numberOfVouchers, CurrencyEnum.Voucher)}
/>
{nights > 1 ? (
<RegularRow label={averagePriceTitle} value={averagePricePerNight} />