Merged in fix/refactor-currency-display (pull request #3434)
fix(SW-3616): Handle EuroBonus point type everywhere * Add tests to formatPrice * formatPrice * More work replacing config with api points type * More work replacing config with api points type * More fixing with currency * maybe actually fixed it * Fix MyStay * Clean up * Fix comments * Merge branch 'master' into fix/refactor-currency-display * Fix calculateTotalPrice for EB points + SF points + cash Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -12,7 +12,6 @@ import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter"
|
||||
import { AvailabilityEnum } from "@scandic-hotels/trpc/enums/selectHotel"
|
||||
import { selectRateRoomsAvailabilityInputSchema } from "@scandic-hotels/trpc/routers/hotels/availability/selectRate/rooms/schema"
|
||||
|
||||
import { useGetPointsCurrency } from "../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||
import { useIsLoggedIn } from "../../../hooks/useIsLoggedIn"
|
||||
import useLang from "../../../hooks/useLang"
|
||||
import { BookingCodeFilterEnum } from "../../../stores/bookingCode-filter"
|
||||
@@ -63,7 +62,6 @@ export function SelectRateProvider({
|
||||
const updateBooking = useUpdateBooking()
|
||||
const isUserLoggedIn = useIsLoggedIn()
|
||||
const intl = useIntl()
|
||||
const pointsCurrency = useGetPointsCurrency()
|
||||
|
||||
const [activeRoomIndex, setInternalActiveRoomIndex] = useQueryState<number>(
|
||||
"activeRoomIndex",
|
||||
@@ -228,7 +226,6 @@ export function SelectRateProvider({
|
||||
roomConfiguration: roomAvailability[ix]?.[0],
|
||||
})),
|
||||
isMember: isUserLoggedIn,
|
||||
pointsCurrency,
|
||||
})
|
||||
|
||||
const getPriceForRoom = useCallback(
|
||||
@@ -249,10 +246,9 @@ export function SelectRateProvider({
|
||||
],
|
||||
isMember: isUserLoggedIn && roomIndex === 0,
|
||||
addAdditionalCost: false,
|
||||
pointsCurrency,
|
||||
})
|
||||
},
|
||||
[selectedRates, roomAvailability, isUserLoggedIn, pointsCurrency]
|
||||
[selectedRates, roomAvailability, isUserLoggedIn]
|
||||
)
|
||||
|
||||
const setActiveRoomIndex = useCallback(
|
||||
|
||||
@@ -17,12 +17,10 @@ export function getTotalPrice({
|
||||
selectedRates,
|
||||
isMember,
|
||||
addAdditionalCost = true,
|
||||
pointsCurrency,
|
||||
}: {
|
||||
selectedRates: Array<SelectedRate | null>
|
||||
isMember: boolean
|
||||
addAdditionalCost?: boolean
|
||||
pointsCurrency?: CurrencyEnum
|
||||
}): Price | null {
|
||||
const mainRoom = selectedRates[0]
|
||||
const mainRoomRate = mainRoom?.rate
|
||||
@@ -47,8 +45,7 @@ export function getTotalPrice({
|
||||
mainRoom.roomConfiguration?.selectedPackages.filter(
|
||||
(pkg) => "localPrice" in pkg
|
||||
) ?? null,
|
||||
addAdditionalCost,
|
||||
pointsCurrency
|
||||
addAdditionalCost
|
||||
)
|
||||
}
|
||||
if ("voucher" in mainRoomRate) {
|
||||
@@ -159,8 +156,7 @@ function calculateTotalPrice(
|
||||
function calculateRedemptionTotalPrice(
|
||||
redemption: RedemptionProduct["redemption"],
|
||||
packages: RoomPackage[] | null,
|
||||
addAdditonalCost: boolean,
|
||||
pointsCurrency?: CurrencyEnum
|
||||
addAdditonalCost: boolean
|
||||
) {
|
||||
const pkgsSum = addAdditonalCost
|
||||
? sumPackages(packages)
|
||||
@@ -183,8 +179,9 @@ function calculateRedemptionTotalPrice(
|
||||
local: {
|
||||
additionalPrice,
|
||||
additionalPriceCurrency,
|
||||
currency: pointsCurrency ?? CurrencyEnum.POINTS,
|
||||
currency: CurrencyEnum.POINTS,
|
||||
price: redemption.localPrice.pointsPerStay,
|
||||
pointsType: redemption.localPrice.pointsType,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user