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
This commit is contained in:
Hrishikesh Vaipurkar
2025-07-18 10:41:14 +00:00
parent 876a9cab7f
commit 3356523cb2
5 changed files with 36 additions and 8 deletions

View File

@@ -49,7 +49,7 @@
} }
} }
.strikeThroughRate { .prices .strikeThroughRate {
text-decoration: line-through; text-decoration: line-through;
color: var(--Text-Secondary); color: var(--Text-Secondary);
} }

View File

@@ -7,10 +7,16 @@ import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Typography } from "@scandic-hotels/design-system/Typography" import { Typography } from "@scandic-hotels/design-system/Typography"
import { ChildBedMapEnum } from "@scandic-hotels/trpc/enums/childBedMapEnum" import { ChildBedMapEnum } from "@scandic-hotels/trpc/enums/childBedMapEnum"
import { getRoomPrice } from "@/stores/enter-details/helpers"
import Modal from "@/components/Modal" import Modal from "@/components/Modal"
import { formatPrice } from "@/utils/numberFormatting" import { formatPrice } from "@/utils/numberFormatting"
import { getMemberPrice, isBookingCodeRate } from "../utils" import {
getMemberPrice,
getNonDiscountedRate,
isBookingCodeRate,
} from "../utils"
import styles from "./room.module.css" import styles from "./room.module.css"
@@ -70,6 +76,7 @@ export default function Room({
const memberPrice = getMemberPrice(room.roomRate) const memberPrice = getMemberPrice(room.roomRate)
const showMemberPrice = !!(isMember && memberPrice && roomNumber === 1) const showMemberPrice = !!(isMember && memberPrice && roomNumber === 1)
const showDiscounted = isBookingCodeRate(room.roomRate) || showMemberPrice const showDiscounted = isBookingCodeRate(room.roomRate) || showMemberPrice
const regularRate = getRoomPrice(room.roomRate, showMemberPrice)
const adultsMsg = intl.formatMessage( const adultsMsg = intl.formatMessage(
{ {
@@ -143,12 +150,13 @@ export default function Room({
room.roomPrice.perStay.local.additionalPriceCurrency room.roomPrice.perStay.local.additionalPriceCurrency
)} )}
</p> </p>
{showDiscounted && room.roomPrice.perStay.local.price ? ( {/* Show the price on which discount applies as Striked when discounted price is available */}
{showDiscounted ? (
<s className={styles.strikeThroughRate}> <s className={styles.strikeThroughRate}>
{formatPrice( {getNonDiscountedRate(
intl, intl,
room.roomPrice.perStay.local.price, showMemberPrice,
room.roomPrice.perStay.local.currency regularRate.perStay
)} )}
</s> </s>
) : null} ) : null}

View File

@@ -47,7 +47,7 @@
} }
} }
.strikeThroughRate { .prices .strikeThroughRate {
text-decoration: line-through; text-decoration: line-through;
color: var(--Text-Secondary); color: var(--Text-Secondary);
} }

View File

@@ -88,7 +88,7 @@
} }
} }
.strikeThroughRate { .priceDetailsButton .strikeThroughRate {
text-decoration: line-through; text-decoration: line-through;
color: var(--Text-Secondary); color: var(--Text-Secondary);
} }

View File

@@ -1,8 +1,12 @@
import { RateTypeEnum } from "@scandic-hotels/trpc/enums/rateType" import { RateTypeEnum } from "@scandic-hotels/trpc/enums/rateType"
import { formatPrice } from "@/utils/numberFormatting"
import type { Product } from "@scandic-hotels/trpc/types/roomAvailability" 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 { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
import type { Price } from "@/types/components/hotelReservation/price"
export function getMemberPrice(roomRate: RoomRate) { export function getMemberPrice(roomRate: RoomRate) {
if ("member" in roomRate && roomRate.member) { if ("member" in roomRate && roomRate.member) {
@@ -33,3 +37,19 @@ export function isBookingCodeRate(product: Product) {
return false 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
}
}