feat: move room charge to top in price details modal
This commit is contained in:
committed by
Michael Zetterberg
parent
194a401a56
commit
a99e434d84
@@ -128,6 +128,13 @@ export function calculateVoucherPrice(selectedRateSummary: Rate[]) {
|
||||
|
||||
total.local.price = total.local.price + rate.numberOfVouchers
|
||||
|
||||
const pkgsSum = sumPackages(room.packages)
|
||||
if (pkgsSum.price && pkgsSum.currency) {
|
||||
total.local.additionalPrice =
|
||||
(total.local.additionalPrice || 0) + pkgsSum.price
|
||||
total.local.additionalPriceCurrency = pkgsSum.currency
|
||||
}
|
||||
|
||||
return total
|
||||
},
|
||||
{
|
||||
|
||||
@@ -80,6 +80,9 @@ export default function SelectedRoomPanel() {
|
||||
return null
|
||||
}
|
||||
|
||||
const selectedPackagesCurrency = selectedPackages.find(
|
||||
(pkg) => pkg.localPrice.currency
|
||||
)
|
||||
const selectedPackagesPrice = selectedPackages.reduce(
|
||||
(total, pkg) => total + pkg.localPrice.totalPrice,
|
||||
0
|
||||
@@ -104,11 +107,17 @@ export default function SelectedRoomPanel() {
|
||||
} else if ("corporateCheque" in selectedRate.product) {
|
||||
const { localPrice } = selectedRate.product.corporateCheque
|
||||
selectedProduct = `${localPrice.numberOfCheques} ${CurrencyEnum.CC}`
|
||||
if (localPrice.additionalPricePerStay && localPrice.currency) {
|
||||
selectedProduct = `${selectedProduct} + ${localPrice.additionalPricePerStay} ${localPrice.currency}`
|
||||
if (
|
||||
(localPrice.additionalPricePerStay || selectedPackagesPrice) &&
|
||||
localPrice.currency
|
||||
) {
|
||||
selectedProduct = `${selectedProduct} + ${localPrice.additionalPricePerStay + selectedPackagesPrice} ${localPrice.currency}`
|
||||
}
|
||||
} else if ("voucher" in selectedRate.product) {
|
||||
selectedProduct = `${selectedRate.product.voucher.numberOfVouchers} ${CurrencyEnum.Voucher}`
|
||||
if (selectedPackagesPrice && selectedPackagesCurrency) {
|
||||
selectedProduct = `${selectedProduct} + ${selectedPackagesPrice} ${selectedPackagesCurrency}`
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectedProduct) {
|
||||
|
||||
@@ -115,6 +115,16 @@ export default function Code({
|
||||
if ("voucher" in product) {
|
||||
const { numberOfVouchers, rateCode } = product.voucher
|
||||
const isSelected = isSelectedVoucher(product, selectedRate, roomTypeCode)
|
||||
|
||||
const voucherMsg = intl
|
||||
.formatMessage({
|
||||
defaultMessage: "Voucher",
|
||||
})
|
||||
.toUpperCase()
|
||||
let price = `${numberOfVouchers} ${voucherMsg}`
|
||||
if (pkgsSum.price) {
|
||||
price = `${price} + ${pkgsSum.price}`
|
||||
}
|
||||
return (
|
||||
<CodeRateCard
|
||||
key={product.rate}
|
||||
@@ -125,12 +135,8 @@ export default function Code({
|
||||
paymentTerm={rateTitles[product.rate].paymentTerm}
|
||||
rate={{
|
||||
label: product.rateDefinition?.title,
|
||||
price: numberOfVouchers.toString(),
|
||||
unit: intl
|
||||
.formatMessage({
|
||||
defaultMessage: "Voucher",
|
||||
})
|
||||
.toUpperCase(),
|
||||
price,
|
||||
unit: pkgsSum.currency ?? "",
|
||||
}}
|
||||
rateTitle={rateTitles[product.rate].title}
|
||||
rateTermDetails={rateTermDetails}
|
||||
|
||||
Reference in New Issue
Block a user