fix: display modify dates for already guaranteed changeable rates

This commit is contained in:
Simon Emanuelsson
2025-04-03 15:51:38 +02:00
committed by Michael Zetterberg
parent b8a976db22
commit 2abd4c5c12
17 changed files with 94 additions and 205 deletions

View File

@@ -1,17 +1,11 @@
import type { PriceType } from "@/types/components/hotelReservation/myStay/myStay"
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
type PriceTypeParams = Pick<
BookingConfirmation["booking"],
"rateDefinition" | "vouchers" | "cheques"
>
export function getPriceType({
rateDefinition,
vouchers,
cheques,
}: PriceTypeParams): PriceType {
if (rateDefinition.title === "Reward Night") return "points"
export function getPriceType(
cheques: number,
points: number,
vouchers: number
): PriceType {
if (points > 0) return "points"
if (vouchers > 0) return "voucher"
if (cheques > 0) return "cheque"
return "money"

View File

@@ -1,4 +1,4 @@
import { BookingStatusEnum, CancellationRuleEnum } from "@/constants/booking"
import { BookingStatusEnum } from "@/constants/booking"
import { dt } from "@/lib/dt"
import { formatChildBedPreferences } from "../utils"
@@ -81,16 +81,11 @@ export function mapRoomDetails({
booking.childBedPreferences
)
const isPrePaid =
!!booking.guaranteeInfo?.paymentMethodDescription ||
booking.rateDefinition.cancellationRule !==
CancellationRuleEnum.CancellableBefore6PM
const priceType = getPriceType({
rateDefinition: booking.rateDefinition,
vouchers: booking.vouchers,
cheques: booking.cheques,
})
const priceType = getPriceType(
booking.cheques,
booking.roomPoints,
booking.vouchers
)
return {
hotelId: booking.hotelId,
@@ -159,7 +154,6 @@ export function mapRoomDetails({
},
},
breakfast,
isPrePaid,
priceType,
}
}