Feat/SW-1719 strikethrough rates * feat(SW-1719): Strikethrough rate if logged in on regular rate cards * feat(SW-1719): Strikethrough rate if logged in on rate summary * feat(SW-1719): Strikethrough rate if logged in on mobile rate summary * feat(SW-1719): Strikethrough rate if logged in on enter details * feat(SW-1719): Strikethrough rate support for multiple rooms * feat(SW-1719): booking receipt fixes on confirmation page * feat(SW-1719): improve initial total price calculation * feat: harmonize enter details total price to use one and the same function Approved-by: Michael Zetterberg
34 lines
930 B
TypeScript
34 lines
930 B
TypeScript
import type { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
|
|
import { RateTypeEnum } from "@/types/enums/rateType"
|
|
import type { Product } from "@/types/trpc/routers/hotel/roomAvailability"
|
|
|
|
export function getMemberPrice(roomRate: RoomRate) {
|
|
if ("member" in roomRate && roomRate.member) {
|
|
return {
|
|
amount: roomRate.member.localPrice.pricePerStay,
|
|
currency: roomRate.member.localPrice.currency,
|
|
pricePerNight: roomRate.member.localPrice.pricePerNight,
|
|
}
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
export function isBookingCodeRate(product: Product) {
|
|
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
|
|
}
|
|
}
|