feat: move room charge to top in price details modal
This commit is contained in:
committed by
Michael Zetterberg
parent
194a401a56
commit
a99e434d84
@@ -1,5 +1,7 @@
|
||||
import { dt } from "@/lib/dt"
|
||||
|
||||
import { sumPackages } from "../../utils"
|
||||
|
||||
import { PriceTypeEnum } from "@/types/components/hotelReservation/myStay/myStay"
|
||||
import type { Price } from "@/types/components/hotelReservation/price"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
@@ -10,7 +12,7 @@ export function mapToPrice(room: Room) {
|
||||
case PriceTypeEnum.cheque:
|
||||
return {
|
||||
corporateCheque: {
|
||||
additionalPricePerStay: room.totalPrice,
|
||||
additionalPricePerStay: room.roomPrice.perStay.local.price,
|
||||
currency: room.roomPrice.perStay.local.currency,
|
||||
numberOfCheques: room.cheques,
|
||||
},
|
||||
@@ -20,7 +22,7 @@ export function mapToPrice(room: Room) {
|
||||
regular: {
|
||||
currency: room.currencyCode,
|
||||
pricePerNight: room.roomPrice.perNight.local.price,
|
||||
pricePerStay: room.totalPrice,
|
||||
pricePerStay: room.roomPrice.perStay.local.price,
|
||||
},
|
||||
}
|
||||
case PriceTypeEnum.points:
|
||||
@@ -29,7 +31,7 @@ export function mapToPrice(room: Room) {
|
||||
.diff(dt(room.checkInDate).startOf("day"), "days")
|
||||
return {
|
||||
redemption: {
|
||||
additionalPricePerStay: room.totalPrice,
|
||||
additionalPricePerStay: room.roomPrice.perStay.local.price,
|
||||
currency: room.currencyCode,
|
||||
pointsPerNight: room.roomPoints / nights,
|
||||
pointsPerStay: room.roomPoints,
|
||||
@@ -80,7 +82,6 @@ export function calculateTotalPrice(rooms: Room[], currency: CurrencyEnum) {
|
||||
switch (room.priceType) {
|
||||
case PriceTypeEnum.cheque:
|
||||
case PriceTypeEnum.points:
|
||||
case PriceTypeEnum.voucher:
|
||||
{
|
||||
if (room.totalPrice) {
|
||||
total.local.additionalPrice =
|
||||
@@ -88,8 +89,19 @@ export function calculateTotalPrice(rooms: Room[], currency: CurrencyEnum) {
|
||||
}
|
||||
|
||||
if (!total.local.additionalPriceCurrency) {
|
||||
if (room.currencyCode) {
|
||||
total.local.additionalPriceCurrency = room.currencyCode
|
||||
total.local.additionalPriceCurrency = currency
|
||||
}
|
||||
}
|
||||
break
|
||||
case PriceTypeEnum.voucher:
|
||||
{
|
||||
if (room.packages) {
|
||||
const pkgsSum = sumPackages(room.packages)
|
||||
total.local.additionalPrice =
|
||||
(total.local.additionalPrice || 0) + pkgsSum.price
|
||||
|
||||
if (pkgsSum.currency) {
|
||||
total.local.additionalPriceCurrency = pkgsSum.currency
|
||||
} else {
|
||||
total.local.additionalPriceCurrency = currency
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user