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:
@@ -8,7 +8,6 @@ import type {
|
||||
Product,
|
||||
RedemptionProduct,
|
||||
} from "@scandic-hotels/trpc/types/roomAvailability"
|
||||
import type { IntlShape } from "react-intl"
|
||||
|
||||
import type { Price } from "@/types/components/hotelReservation/price"
|
||||
import type { Rate } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
@@ -214,8 +213,7 @@ export function calculateCorporateChequePrice(selectedRateSummary: Rate[]) {
|
||||
export function getTotalPrice(
|
||||
mainRoomProduct: Rate | null,
|
||||
rateSummary: Array<Rate | null>,
|
||||
isUserLoggedIn: boolean,
|
||||
intl: IntlShape
|
||||
isUserLoggedIn: boolean
|
||||
): Price | null {
|
||||
const summaryArray = rateSummary.filter((rate): rate is Rate => rate !== null)
|
||||
|
||||
@@ -235,9 +233,6 @@ export function getTotalPrice(
|
||||
}
|
||||
if ("voucher" in product) {
|
||||
const voucherPrice = calculateVoucherPrice(summaryArray)
|
||||
voucherPrice.local.currency = intl.formatMessage({
|
||||
defaultMessage: "Voucher",
|
||||
}) as CurrencyEnum
|
||||
return voucherPrice
|
||||
}
|
||||
|
||||
|
||||
@@ -338,15 +338,25 @@ function VoucherCode({
|
||||
|
||||
const rateTermDetails = getRateTermDetails(codeProduct)
|
||||
|
||||
const voucherMsg = intl
|
||||
.formatMessage({
|
||||
defaultMessage: "Voucher",
|
||||
})
|
||||
.toUpperCase()
|
||||
let price = `${numberOfVouchers} ${voucherMsg}`
|
||||
if (packagesSum.price) {
|
||||
price = `${price} + ${packagesSum.price}`
|
||||
}
|
||||
const voucherMsg = intl.formatMessage(
|
||||
{
|
||||
defaultMessage:
|
||||
"{numberOfVouchers, plural, one {Voucher} other {Vouchers}}",
|
||||
},
|
||||
{
|
||||
numberOfVouchers: numberOfVouchers,
|
||||
}
|
||||
)
|
||||
|
||||
const { price, currency } = packagesSum.price
|
||||
? {
|
||||
price: `${numberOfVouchers} ${voucherMsg} + ${packagesSum.price}`,
|
||||
currency: packagesSum.currency ?? "",
|
||||
}
|
||||
: {
|
||||
price: `${numberOfVouchers} ${voucherMsg}`,
|
||||
currency: "",
|
||||
}
|
||||
return (
|
||||
<CodeRateCard
|
||||
key={codeProduct.rate}
|
||||
@@ -358,7 +368,7 @@ function VoucherCode({
|
||||
rate={{
|
||||
label: codeProduct.rateDefinition?.title,
|
||||
price,
|
||||
unit: packagesSum.currency ?? "",
|
||||
unit: currency,
|
||||
}}
|
||||
rateTitle={rateTitles[codeProduct.rate].title}
|
||||
rateTermDetails={rateTermDetails}
|
||||
|
||||
Reference in New Issue
Block a user