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:
@@ -232,7 +232,6 @@ export function SelectRateProvider({
|
||||
roomConfiguration: roomAvailability[ix]?.[0],
|
||||
})),
|
||||
useMemberPrices: isUserLoggedIn,
|
||||
intl,
|
||||
})
|
||||
|
||||
const getPriceForRoom = useCallback(
|
||||
@@ -252,10 +251,9 @@ export function SelectRateProvider({
|
||||
{ rate, roomConfiguration: roomAvailability[roomIndex]?.[0] },
|
||||
],
|
||||
useMemberPrices: isUserLoggedIn,
|
||||
intl,
|
||||
})
|
||||
},
|
||||
[selectedRates, roomAvailability, isUserLoggedIn, intl]
|
||||
[selectedRates, roomAvailability, isUserLoggedIn]
|
||||
)
|
||||
|
||||
const setActiveRoomIndex = useCallback(
|
||||
|
||||
@@ -2,20 +2,11 @@ import { describe, expect, it } from "vitest"
|
||||
|
||||
import { getTotalPrice } from "./getTotalPrice"
|
||||
|
||||
import type { IntlShape } from "react-intl"
|
||||
|
||||
const mockIntl = {
|
||||
formatMessage: ({ defaultMessage }: { defaultMessage: string }) => {
|
||||
return defaultMessage
|
||||
},
|
||||
} as IntlShape
|
||||
|
||||
describe("getTotalPrice", () => {
|
||||
it("should return null when no rates are selected", () => {
|
||||
const result = getTotalPrice({
|
||||
selectedRates: [],
|
||||
useMemberPrices: false,
|
||||
intl: mockIntl,
|
||||
})
|
||||
|
||||
expect(result).toEqual({
|
||||
|
||||
@@ -3,7 +3,6 @@ import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
||||
import { sumPackages } from "@/components/HotelReservation/utils"
|
||||
|
||||
import type { RedemptionProduct } from "@scandic-hotels/trpc/types/roomAvailability"
|
||||
import type { IntlShape } from "react-intl"
|
||||
|
||||
import type {
|
||||
AvailabilityWithRoomInfo,
|
||||
@@ -32,11 +31,9 @@ type SelectedRate = {
|
||||
export function getTotalPrice({
|
||||
selectedRates,
|
||||
useMemberPrices,
|
||||
intl,
|
||||
}: {
|
||||
selectedRates: Array<SelectedRate | null>
|
||||
useMemberPrices: boolean
|
||||
intl: IntlShape
|
||||
}): Price | null {
|
||||
const mainRoom = selectedRates[0]
|
||||
const mainRoomRate = mainRoom?.rate
|
||||
@@ -63,10 +60,6 @@ export function getTotalPrice({
|
||||
}
|
||||
if ("voucher" in mainRoomRate) {
|
||||
const voucherPrice = calculateVoucherPrice(summaryArray)
|
||||
// TODO: This is a workaround, should be handled where we print the price.
|
||||
voucherPrice.local.currency = intl.formatMessage({
|
||||
defaultMessage: "Voucher",
|
||||
}) as CurrencyEnum
|
||||
return voucherPrice
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user