Merged in fix/remove-old-select-rate (pull request #2647)

Fix/remove old select rate

* remove old select-rate

* Fix imports

* renamed SelectRate2 -> SelectRate
This commit is contained in:
Joakim Jäderberg
2025-08-13 13:43:48 +00:00
parent 51f53a717d
commit e3067331c6
127 changed files with 1859 additions and 8448 deletions

View File

@@ -4,7 +4,10 @@ import { RateTypeEnum } from "@scandic-hotels/trpc/enums/rateType"
import { sumPackages } from "@/components/HotelReservation/utils"
import type { Packages } from "@scandic-hotels/trpc/types/packages"
import type { RedemptionProduct } from "@scandic-hotels/trpc/types/roomAvailability"
import type {
Product,
RedemptionProduct,
} from "@scandic-hotels/trpc/types/roomAvailability"
import type { IntlShape } from "react-intl"
import type { Price } from "@/types/components/hotelReservation/price"
@@ -23,10 +26,8 @@ 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
}
@@ -50,16 +51,10 @@ export function calculateTotalPrice(
total.local.price =
total.local.price + rate.localPrice.pricePerStay + packagesPrice.local
if (rate.rateType === RateTypeEnum.Regular && publicRate) {
if (rate.localPrice.regularPricePerStay) {
total.local.regularPrice =
(total.local.regularPrice || 0) +
publicRate.localPrice.pricePerStay +
packagesPrice.local
} else {
total.local.regularPrice =
(total.local.regularPrice || 0) +
(rate.localPrice.regularPricePerStay ||
rate.localPrice.pricePerStay) +
rate.localPrice.regularPricePerStay +
packagesPrice.local
}
@@ -248,3 +243,23 @@ export function getTotalPrice(
return calculateTotalPrice(summaryArray, isUserLoggedIn)
}
export function isBookingCodeRate(product: Product | undefined | null) {
if (!product) return false
if (
"corporateCheque" in product ||
"redemption" in product ||
"voucher" in product
) {
return true
} else {
if (product.public) {
return product.public.rateType !== RateTypeEnum.Regular
}
if (product.member) {
return product.member.rateType !== RateTypeEnum.Regular
}
return false
}
}