fix(SW-3091): Fixed strikethrough price for logged-in user * fix(SW-3091): Fixed strikethrough price for logged-in user Approved-by: Anton Gunnarsson Approved-by: Matilda Landström
36 lines
945 B
TypeScript
36 lines
945 B
TypeScript
import { RateTypeEnum } from "@scandic-hotels/trpc/enums/rateType"
|
|
|
|
import type { Product } from "@scandic-hotels/trpc/types/roomAvailability"
|
|
|
|
import type { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
|
|
|
|
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
|
|
}
|
|
}
|