feat: move room charge to top in price details modal
This commit is contained in:
committed by
Michael Zetterberg
parent
194a401a56
commit
a99e434d84
@@ -12,6 +12,7 @@ import type { Price } from "@/types/components/hotelReservation/price"
|
||||
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import { StepEnum } from "@/types/enums/step"
|
||||
import type { Package } from "@/types/requests/packages"
|
||||
import type { PersistedState, RoomState } from "@/types/stores/enter-details"
|
||||
import type { SafeUser } from "@/types/user"
|
||||
|
||||
@@ -368,15 +369,22 @@ export function getTotalPrice(roomRates: RoomRate[], isMember: boolean) {
|
||||
return totalPrice
|
||||
}
|
||||
|
||||
export function calculateVoucherPrice(roomRates: RoomRate[]) {
|
||||
export function calculateVoucherPrice(
|
||||
roomRates: RoomRate[],
|
||||
packages: Package[]
|
||||
) {
|
||||
return roomRates.reduce<Price>(
|
||||
(total, room) => {
|
||||
if (!("voucher" in room)) {
|
||||
return total
|
||||
}
|
||||
|
||||
const pkgsSum = sumPackages(packages)
|
||||
|
||||
return {
|
||||
local: {
|
||||
additionalPrice: pkgsSum.price,
|
||||
additionalPriceCurrency: pkgsSum.currency,
|
||||
currency: total.local.currency,
|
||||
price: total.local.price + room.voucher.numberOfVouchers,
|
||||
},
|
||||
|
||||
@@ -85,7 +85,8 @@ export function createDetailsStore(
|
||||
roomOneRoomRate.redemption.localPrice.additionalPricePerStay
|
||||
}
|
||||
} else if (isVoucher) {
|
||||
initialTotalPrice = calculateVoucherPrice(initialRoomRates)
|
||||
const pkgs = initialState.rooms.flatMap((room) => room.roomFeatures || [])
|
||||
initialTotalPrice = calculateVoucherPrice(initialRoomRates, pkgs)
|
||||
} else if (isCorpChq) {
|
||||
initialTotalPrice = calculateCorporateChequePrice(initialRoomRates)
|
||||
} else {
|
||||
|
||||
@@ -26,7 +26,9 @@ export function calculateTotalPrice(
|
||||
if (room.totalPoints) {
|
||||
total.points = total.points + room.totalPoints
|
||||
}
|
||||
if (room.totalPrice) {
|
||||
// room.totalPrice is a negative value when
|
||||
// its a vouchers booking (╯°□°)╯︵ ┻━┻
|
||||
if (room.totalPrice && !room.vouchers) {
|
||||
total.cash = total.cash + room.totalPrice
|
||||
}
|
||||
return total
|
||||
|
||||
Reference in New Issue
Block a user