Merged in fix/SW-3091-the-strikethrough-price- (pull request #2567)

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
This commit is contained in:
Hrishikesh Vaipurkar
2025-07-28 11:20:49 +00:00
parent a12dfb4b5b
commit eca29fb540
2 changed files with 5 additions and 29 deletions

View File

@@ -12,11 +12,7 @@ import { getRoomPrice } from "@/stores/enter-details/helpers"
import Modal from "@/components/Modal"
import { formatPrice } from "@/utils/numberFormatting"
import {
getMemberPrice,
getNonDiscountedRate,
isBookingCodeRate,
} from "../utils"
import { getMemberPrice, isBookingCodeRate } from "../utils"
import styles from "./room.module.css"
@@ -151,12 +147,12 @@ export default function Room({
)}
</p>
{/* Show the price on which discount applies as Striked when discounted price is available */}
{showDiscounted ? (
{showDiscounted && regularRate.perStay.local.regularPrice ? (
<s className={styles.strikeThroughRate}>
{getNonDiscountedRate(
{formatPrice(
intl,
showMemberPrice,
regularRate.perStay
regularRate.perStay.local.regularPrice,
regularRate.perStay.local.currency
)}
</s>
) : null}

View File

@@ -1,12 +1,8 @@
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) {
@@ -37,19 +33,3 @@ export function isBookingCodeRate(product: Product) {
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
}
}