feat: move room charge to top in price details modal
This commit is contained in:
committed by
Michael Zetterberg
parent
194a401a56
commit
a99e434d84
@@ -53,13 +53,62 @@ export default function PriceDetails() {
|
||||
total.local.price = total.local.price + room.totalPrice
|
||||
}
|
||||
|
||||
if (
|
||||
(room.cheques || room.roomPoints || room.vouchers) &&
|
||||
room.roomPrice
|
||||
) {
|
||||
// Corporate Cheque
|
||||
if (room.cheques) {
|
||||
if (room.roomPrice) {
|
||||
total.local.additionalPrice =
|
||||
(total.local.additionalPrice || 0) + room.totalPrice
|
||||
total.local.additionalPriceCurrency = currency
|
||||
} else {
|
||||
const pkgsSum = room.packages.reduce(
|
||||
(total, pkg) => total + pkg.totalPrice,
|
||||
0
|
||||
)
|
||||
total.local.additionalPrice =
|
||||
(total.local.additionalPrice || 0) + pkgsSum
|
||||
const pkgsCurrency = room.packages.find(
|
||||
(pkg) => pkg.currency
|
||||
)?.currency
|
||||
if (!total.local.additionalPriceCurrency) {
|
||||
total.local.additionalPriceCurrency = pkgsCurrency ?? currency
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Redemption
|
||||
if (room.roomPoints) {
|
||||
if (room.roomPrice) {
|
||||
total.local.additionalPrice =
|
||||
(total.local.additionalPrice || 0) + room.totalPrice
|
||||
total.local.additionalPriceCurrency = currency
|
||||
} else {
|
||||
const pkgsSum = room.packages.reduce(
|
||||
(total, pkg) => total + pkg.totalPrice,
|
||||
0
|
||||
)
|
||||
total.local.additionalPrice =
|
||||
(total.local.additionalPrice || 0) + pkgsSum
|
||||
const pkgsCurrency = room.packages.find(
|
||||
(pkg) => pkg.currency
|
||||
)?.currency
|
||||
if (!total.local.additionalPriceCurrency) {
|
||||
total.local.additionalPriceCurrency = pkgsCurrency ?? currency
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Voucher
|
||||
if (room.vouchers && room.packages) {
|
||||
const pkgsSum = room.packages.reduce(
|
||||
(total, pkg) => total + pkg.totalPrice,
|
||||
0
|
||||
)
|
||||
total.local.additionalPrice =
|
||||
(total.local.additionalPrice || 0) + room.totalPrice
|
||||
total.local.additionalPriceCurrency = currency
|
||||
(total.local.additionalPrice || 0) + pkgsSum
|
||||
const pkgsCurrency = room.packages.find((pkg) => pkg.currency)?.currency
|
||||
if (!total.local.additionalPriceCurrency) {
|
||||
total.local.additionalPriceCurrency = pkgsCurrency ?? currency
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
|
||||
@@ -17,20 +17,16 @@ export function mapToPrice(rooms: (Room | null)[], nights: number) {
|
||||
if (room.cheques) {
|
||||
price = {
|
||||
corporateCheque: {
|
||||
additionalPricePerStay: room.totalPrice
|
||||
? room.totalPrice
|
||||
: undefined,
|
||||
currency: room.totalPrice ? room.currencyCode : undefined,
|
||||
additionalPricePerStay: room.roomPrice ? room.roomPrice : undefined,
|
||||
currency: room.roomPrice ? room.currencyCode : undefined,
|
||||
numberOfCheques: room.cheques,
|
||||
},
|
||||
}
|
||||
} else if (room.roomPoints) {
|
||||
price = {
|
||||
redemption: {
|
||||
additionalPricePerStay: room.totalPrice
|
||||
? room.totalPrice
|
||||
: undefined,
|
||||
currency: room.totalPrice ? room.currencyCode : undefined,
|
||||
additionalPricePerStay: room.roomPrice ? room.roomPrice : undefined,
|
||||
currency: room.roomPrice ? room.currencyCode : undefined,
|
||||
pointsPerNight: room.roomPoints / nights,
|
||||
pointsPerStay: room.roomPoints,
|
||||
},
|
||||
@@ -46,7 +42,7 @@ export function mapToPrice(rooms: (Room | null)[], nights: number) {
|
||||
regular: {
|
||||
currency: room.currencyCode,
|
||||
pricePerNight: room.roomPrice / nights,
|
||||
pricePerStay: room.totalPrice,
|
||||
pricePerStay: room.roomPrice,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function mapRoomState(
|
||||
intl,
|
||||
booking.roomPoints,
|
||||
CurrencyEnum.POINTS,
|
||||
booking.totalPrice,
|
||||
booking.roomPrice,
|
||||
booking.currencyCode
|
||||
)
|
||||
} else if (booking.cheques) {
|
||||
@@ -37,7 +37,7 @@ export function mapRoomState(
|
||||
intl,
|
||||
booking.cheques,
|
||||
CurrencyEnum.CC,
|
||||
booking.totalPrice,
|
||||
booking.roomPrice,
|
||||
booking.currencyCode
|
||||
)
|
||||
} else if (booking.vouchers) {
|
||||
|
||||
Reference in New Issue
Block a user