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:
@@ -12,11 +12,7 @@ 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 {
|
import { getMemberPrice, isBookingCodeRate } from "../utils"
|
||||||
getMemberPrice,
|
|
||||||
getNonDiscountedRate,
|
|
||||||
isBookingCodeRate,
|
|
||||||
} from "../utils"
|
|
||||||
|
|
||||||
import styles from "./room.module.css"
|
import styles from "./room.module.css"
|
||||||
|
|
||||||
@@ -151,12 +147,12 @@ export default function Room({
|
|||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
{/* Show the price on which discount applies as Striked when discounted price is available */}
|
{/* Show the price on which discount applies as Striked when discounted price is available */}
|
||||||
{showDiscounted ? (
|
{showDiscounted && regularRate.perStay.local.regularPrice ? (
|
||||||
<s className={styles.strikeThroughRate}>
|
<s className={styles.strikeThroughRate}>
|
||||||
{getNonDiscountedRate(
|
{formatPrice(
|
||||||
intl,
|
intl,
|
||||||
showMemberPrice,
|
regularRate.perStay.local.regularPrice,
|
||||||
regularRate.perStay
|
regularRate.perStay.local.currency
|
||||||
)}
|
)}
|
||||||
</s>
|
</s>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
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) {
|
||||||
@@ -37,19 +33,3 @@ 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user