Merged in feat/SW-1719-strikethrough-rates (pull request #2266)
Feat/SW-1719 strikethrough rates * feat(SW-1719): Strikethrough rate if logged in on regular rate cards * feat(SW-1719): Strikethrough rate if logged in on rate summary * feat(SW-1719): Strikethrough rate if logged in on mobile rate summary * feat(SW-1719): Strikethrough rate if logged in on enter details * feat(SW-1719): Strikethrough rate support for multiple rooms * feat(SW-1719): booking receipt fixes on confirmation page * feat(SW-1719): improve initial total price calculation * feat: harmonize enter details total price to use one and the same function Approved-by: Michael Zetterberg
This commit is contained in:
committed by
Michael Zetterberg
parent
e1ede52014
commit
85acd3453d
@@ -3,6 +3,7 @@ import { sumPackages } from "@/components/HotelReservation/utils"
|
||||
import type { Price } from "@/types/components/hotelReservation/price"
|
||||
import type { Rate } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import { RateTypeEnum } from "@/types/enums/rateType"
|
||||
import type { Packages } from "@/types/requests/packages"
|
||||
import type { RedemptionProduct } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
|
||||
@@ -19,8 +20,10 @@ export function calculateTotalPrice(
|
||||
const roomNr = idx + 1
|
||||
const isMainRoom = roomNr === 1
|
||||
let rate
|
||||
let publicRate
|
||||
if (isUserLoggedIn && isMainRoom && room.product.member) {
|
||||
rate = room.product.member
|
||||
publicRate = room.product.public
|
||||
} else if (room.product.public) {
|
||||
rate = room.product.public
|
||||
}
|
||||
@@ -44,10 +47,16 @@ export function calculateTotalPrice(
|
||||
total.local.price =
|
||||
total.local.price + rate.localPrice.pricePerStay + packagesPrice.local
|
||||
|
||||
if (rate.localPrice.regularPricePerStay) {
|
||||
if (rate.rateType === RateTypeEnum.Regular && publicRate) {
|
||||
total.local.regularPrice =
|
||||
(total.local.regularPrice || 0) +
|
||||
rate.localPrice.regularPricePerStay +
|
||||
publicRate.localPrice.pricePerStay +
|
||||
packagesPrice.local
|
||||
} else {
|
||||
total.local.regularPrice =
|
||||
(total.local.regularPrice || 0) +
|
||||
(rate.localPrice.regularPricePerStay ||
|
||||
rate.localPrice.pricePerStay) +
|
||||
packagesPrice.local
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user