feat: translate Voucher everywhere during booking flow
This commit is contained in:
committed by
Simon.Emanuelsson
parent
a0b0ed2544
commit
59f4a27cb1
@@ -102,6 +102,30 @@ export default function Room({
|
||||
const guests = guestsParts.join(", ")
|
||||
const zeroPrice = formatPrice(intl, 0, defaultCurrency)
|
||||
|
||||
let price = showMemberPrice
|
||||
? formatPrice(intl, memberPrice.amount, memberPrice.currency)
|
||||
: formatPrice(
|
||||
intl,
|
||||
room.roomPrice.perStay.local.price,
|
||||
room.roomPrice.perStay.local.currency,
|
||||
room.roomPrice.perStay.local.additionalPrice,
|
||||
room.roomPrice.perStay.local.additionalPriceCurrency
|
||||
)
|
||||
|
||||
let currency: string = room.roomPrice.perStay.local.currency
|
||||
const voucherCurrency = intl.formatMessage({ defaultMessage: "Voucher" })
|
||||
const isVoucher = "voucher" in room.roomRate
|
||||
if (isVoucher) {
|
||||
currency = voucherCurrency
|
||||
price = formatPrice(
|
||||
intl,
|
||||
room.roomPrice.perStay.local.price,
|
||||
voucherCurrency,
|
||||
room.roomPrice.perStay.local.additionalPrice,
|
||||
room.roomPrice.perStay.local.additionalPriceCurrency
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={styles.room} data-testid={`summary-room-${roomNumber}`}>
|
||||
@@ -139,19 +163,7 @@ export default function Room({
|
||||
[styles.discounted]: showDiscounted,
|
||||
})}
|
||||
>
|
||||
{showMemberPrice
|
||||
? formatPrice(
|
||||
intl,
|
||||
memberPrice.amount,
|
||||
memberPrice.currency
|
||||
)
|
||||
: formatPrice(
|
||||
intl,
|
||||
room.roomPrice.perStay.local.price,
|
||||
room.roomPrice.perStay.local.currency,
|
||||
room.roomPrice.perStay.local.additionalPrice,
|
||||
room.roomPrice.perStay.local.additionalPriceCurrency
|
||||
)}
|
||||
{price}
|
||||
</p>
|
||||
{showDiscounted && publicPrice ? (
|
||||
<s className={styles.strikeThroughRate}>
|
||||
@@ -262,7 +274,7 @@ export default function Room({
|
||||
</div>
|
||||
<div className={styles.prices}>
|
||||
<span className={styles.price}>
|
||||
{formatPrice(intl, 0, room.roomPrice.perStay.local.currency)}
|
||||
{formatPrice(intl, 0, currency)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -284,7 +296,7 @@ export default function Room({
|
||||
</p>
|
||||
<div className={styles.prices}>
|
||||
<span className={styles.price}>
|
||||
{formatPrice(intl, 0, room.roomPrice.perStay.local.currency)}
|
||||
{formatPrice(intl, 0, currency)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { cx } from "class-variance-authority"
|
||||
import { useIntl } from "react-intl"
|
||||
import { useMediaQuery } from "usehooks-ts"
|
||||
|
||||
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { Divider } from "@scandic-hotels/design-system/Divider"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
@@ -66,11 +67,12 @@ export default function SummaryUI({
|
||||
const roomOneMemberPrice = getMemberPrice(rooms[0].room.roomRate)
|
||||
|
||||
const roomOneRoomRate = rooms[0].room.roomRate
|
||||
const isVoucherRate = "voucher" in roomOneRoomRate
|
||||
// In case of Redemption, voucher and Corporate cheque do not show approx price
|
||||
const isSpecialRate =
|
||||
"corporateCheque" in roomOneRoomRate ||
|
||||
"redemption" in roomOneRoomRate ||
|
||||
"voucher" in roomOneRoomRate
|
||||
isVoucherRate
|
||||
|
||||
const priceDetailsRooms = mapToPrice(rooms, isMember)
|
||||
const isAllCampaignRate = rooms.every(
|
||||
@@ -84,6 +86,16 @@ export default function SummaryUI({
|
||||
)
|
||||
const showDiscounted = containsBookingCodeRate || isMember
|
||||
|
||||
const totalCurrency = isVoucherRate
|
||||
? intl.formatMessage({ defaultMessage: "Voucher" })
|
||||
: totalPrice.local.currency
|
||||
|
||||
if (isVoucherRate && defaultCurrency === CurrencyEnum.Voucher) {
|
||||
defaultCurrency = intl.formatMessage({
|
||||
defaultMessage: "Voucher",
|
||||
}) as CurrencyEnum
|
||||
}
|
||||
|
||||
return (
|
||||
<section className={styles.summary}>
|
||||
<header
|
||||
@@ -179,7 +191,7 @@ export default function SummaryUI({
|
||||
{formatPrice(
|
||||
intl,
|
||||
totalPrice.local.price,
|
||||
totalPrice.local.currency,
|
||||
totalCurrency,
|
||||
totalPrice.local.additionalPrice,
|
||||
totalPrice.local.additionalPriceCurrency
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user