Merged in fix/LOY-606 (pull request #3535)
fix(LOY-606): breakfast price now considers number of nights in MyStay/ChangeDates * fix(LOY-606): breakfast price now considers number of nights in MyStay/ChangeDates Approved-by: Linus Flood
This commit is contained in:
@@ -4,6 +4,7 @@ import { useIntl } from "react-intl"
|
|||||||
|
|
||||||
import { sumPackages } from "@scandic-hotels/booking-flow/utils/SelectRate"
|
import { sumPackages } from "@scandic-hotels/booking-flow/utils/SelectRate"
|
||||||
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
||||||
|
import { dt } from "@scandic-hotels/common/dt"
|
||||||
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
|
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
|
||||||
import { trpc } from "@scandic-hotels/trpc/client"
|
import { trpc } from "@scandic-hotels/trpc/client"
|
||||||
|
|
||||||
@@ -66,9 +67,14 @@ export default function Steps({ closeModal }: ChangeDatesStepsProps) {
|
|||||||
|
|
||||||
setDates({ fromDate, toDate })
|
setDates({ fromDate, toDate })
|
||||||
|
|
||||||
|
const numberOfNights = dt(toDate).diff(dt(fromDate), "days")
|
||||||
|
|
||||||
const pkgsSum = sumPackages(packages)
|
const pkgsSum = sumPackages(packages)
|
||||||
const extraPrice =
|
const breakfastPrice = !!breakfast
|
||||||
pkgsSum.price + ((breakfast && breakfast.localPrice.totalPrice) || 0)
|
? breakfast.localPrice.price * numberOfNights
|
||||||
|
: 0
|
||||||
|
|
||||||
|
const extraPrice = pkgsSum.price + breakfastPrice
|
||||||
if (isLoggedIn && "member" in data.product && data.product.member) {
|
if (isLoggedIn && "member" in data.product && data.product.member) {
|
||||||
const { currency, pricePerStay } = data.product.member.localPrice
|
const { currency, pricePerStay } = data.product.member.localPrice
|
||||||
setNewPrice(formatPrice(intl, pricePerStay + extraPrice, currency))
|
setNewPrice(formatPrice(intl, pricePerStay + extraPrice, currency))
|
||||||
|
|||||||
Reference in New Issue
Block a user