Files
Hrishikesh Vaipurkar 3356523cb2 Merged in fix/SW-3091-the-strikethrough-price- (pull request #2562)
fix(SW-3091): Fixed strike through price shown same as original price

* fix(SW-3091): Fixed strike through price shown same as original price

* fix(SW-3091): Optimized code

* fix(3091): Strikethrough visibility on mobile booking code


Approved-by: Erik Tiekstra
2025-07-18 10:41:14 +00:00

56 lines
1.4 KiB
TypeScript

import { RateTypeEnum } from "@scandic-hotels/trpc/enums/rateType"
import { formatPrice } from "@/utils/numberFormatting"
import type { Product } from "@scandic-hotels/trpc/types/roomAvailability"
import type { IntlShape } from "react-intl"
import type { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
import type { Price } from "@/types/components/hotelReservation/price"
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
}
}
export function getNonDiscountedRate(
intl: IntlShape,
isMemberRate: boolean,
rate: Price
) {
if (isMemberRate) {
return rate.local.price
? formatPrice(intl, rate.local.price, rate.local.currency)
: null
} else {
return rate.local.regularPrice
? formatPrice(intl, rate.local.regularPrice, rate.local.currency)
: null
}
}