feat: translate Voucher everywhere during booking flow

This commit is contained in:
Simon Emanuelsson
2025-06-27 15:03:24 +02:00
committed by Simon.Emanuelsson
parent a0b0ed2544
commit 59f4a27cb1
10 changed files with 71 additions and 32 deletions

View File

@@ -3,13 +3,14 @@
import { useRef } from "react"
import { useIntl } from "react-intl"
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import { createBookingConfirmationStore } from "@/stores/booking-confirmation"
import { BookingConfirmationContext } from "@/contexts/BookingConfirmation"
import { formatPrice } from "@/utils/numberFormatting"
import type { BookingConfirmationStore } from "@/types/contexts/booking-confirmation"
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import type { BookingConfirmationProviderProps } from "@/types/providers/booking-confirmation"
export default function BookingConfirmationProvider({
@@ -62,6 +63,7 @@ export default function BookingConfirmationProvider({
)
} else if (totalBookingVouchers) {
const room = rooms?.[0]
const voucherCurrency = intl.formatMessage({ defaultMessage: "Voucher" })
if (room?.packages) {
const pkgsSum = room.packages.reduce(
(total, pkg) => total + pkg.totalPrice,
@@ -72,7 +74,7 @@ export default function BookingConfirmationProvider({
formattedTotalCost = formatPrice(
intl,
totalBookingVouchers,
CurrencyEnum.Voucher,
voucherCurrency,
pkgsSum,
currency
)
@@ -81,7 +83,7 @@ export default function BookingConfirmationProvider({
formattedTotalCost = formatPrice(
intl,
totalBookingVouchers,
CurrencyEnum.Voucher
voucherCurrency
)
}
}