Merged in fix/allow-single-rateCode (pull request #1438)
fix: allow rates that only have either of member or public to be selectable * fix: allow rates that only have either of member or public to be selectable Approved-by: Michael Zetterberg
This commit is contained in:
committed by
Linus Flood
parent
3f01266a75
commit
c3e3fa62ec
@@ -25,6 +25,7 @@ import styles from "./summary.module.css"
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import type { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
|
||||
import type { SelectRateSummaryProps } from "@/types/components/hotelReservation/summary"
|
||||
import { RateTypeEnum } from "@/types/enums/rateType"
|
||||
|
||||
export default function Summary({
|
||||
booking,
|
||||
@@ -56,6 +57,11 @@ export default function Summary({
|
||||
|
||||
const memberPrice = getMemberPrice(rooms[0].roomRate)
|
||||
|
||||
const containsBookingCodeRate = rooms.find(
|
||||
(room) => room.roomRate.publicRate?.rateType !== RateTypeEnum.Regular
|
||||
)
|
||||
const showDiscounted = containsBookingCodeRate || isMember
|
||||
|
||||
return (
|
||||
<section className={styles.summary}>
|
||||
<header className={styles.header}>
|
||||
@@ -103,6 +109,9 @@ export default function Summary({
|
||||
|
||||
const memberPrice = getMemberPrice(room.roomRate)
|
||||
const showMemberPrice = !!(isMember && memberPrice && roomNumber === 1)
|
||||
const isBookingCodeRate =
|
||||
room.roomRate.publicRate?.rateType !== RateTypeEnum.Regular
|
||||
const showDiscounted = isBookingCodeRate || showMemberPrice
|
||||
|
||||
const adultsMsg = intl.formatMessage(
|
||||
{ id: "{totalAdults, plural, one {# adult} other {# adults}}" },
|
||||
@@ -134,7 +143,7 @@ export default function Summary({
|
||||
) : null}
|
||||
<div className={styles.entry}>
|
||||
<Body color="uiTextHighContrast">{room.roomType}</Body>
|
||||
<Body color={showMemberPrice ? "red" : "uiTextHighContrast"}>
|
||||
<Body color={showDiscounted ? "red" : "uiTextHighContrast"}>
|
||||
{formatPrice(
|
||||
intl,
|
||||
room.roomPrice.perStay.local.price,
|
||||
@@ -249,7 +258,11 @@ export default function Summary({
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Body textTransform="bold" data-testid="total-price">
|
||||
<Body
|
||||
color={showDiscounted ? "red" : "uiTextHighContrast"}
|
||||
textTransform="bold"
|
||||
data-testid="total-price"
|
||||
>
|
||||
{formatPrice(
|
||||
intl,
|
||||
totalPrice.local.price,
|
||||
|
||||
@@ -14,6 +14,7 @@ import Summary from "./Summary"
|
||||
import styles from "./mobileSummary.module.css"
|
||||
|
||||
import type { MobileSummaryProps } from "@/types/components/hotelReservation/selectRate/rateSummary"
|
||||
import { RateTypeEnum } from "@/types/enums/rateType"
|
||||
|
||||
export default function MobileSummary({
|
||||
isAllRoomsSelected,
|
||||
@@ -71,19 +72,24 @@ export default function MobileSummary({
|
||||
roomPrice: {
|
||||
perNight: {
|
||||
local: {
|
||||
price: room.public.localPrice.pricePerNight,
|
||||
currency: room.public.localPrice.currency,
|
||||
price: (room.public?.localPrice.pricePerNight ||
|
||||
room.member?.localPrice.pricePerNight)!,
|
||||
currency: (room.public?.localPrice.currency ||
|
||||
room.member?.localPrice.currency)!,
|
||||
},
|
||||
requested: undefined,
|
||||
},
|
||||
perStay: {
|
||||
local: {
|
||||
price: room.public.localPrice.pricePerStay,
|
||||
currency: room.public.localPrice.currency,
|
||||
price: (room.public?.localPrice.pricePerStay ||
|
||||
room.member?.localPrice.pricePerStay)!,
|
||||
currency: (room.public?.localPrice.currency ||
|
||||
room.member?.localPrice.currency)!,
|
||||
},
|
||||
requested: undefined,
|
||||
},
|
||||
currency: room.public.localPrice.currency,
|
||||
currency: (room.public?.localPrice.currency ||
|
||||
room.member?.localPrice.currency)!,
|
||||
},
|
||||
roomRate: {
|
||||
...room.public,
|
||||
@@ -91,13 +97,23 @@ export default function MobileSummary({
|
||||
publicRate: room.public,
|
||||
},
|
||||
rateDetails: rateDefinitions.find(
|
||||
(rate) => rate.rateCode === room.public.rateCode
|
||||
(rate) =>
|
||||
rate.rateCode === room.public?.rateCode ||
|
||||
rate.rateCode === room.member?.rateCode
|
||||
)?.generalTerms,
|
||||
cancellationText:
|
||||
rateDefinitions.find((rate) => rate.rateCode === room.public.rateCode)
|
||||
?.cancellationText ?? "",
|
||||
rateDefinitions.find(
|
||||
(rate) =>
|
||||
rate.rateCode === room.public?.rateCode ||
|
||||
rate.rateCode === room.member?.rateCode
|
||||
)?.cancellationText ?? "",
|
||||
}))
|
||||
|
||||
const containsBookingCodeRate = rateSummary.find(
|
||||
(rate) => rate.public?.rateType !== RateTypeEnum.Regular
|
||||
)
|
||||
const showDiscounted = containsBookingCodeRate || isUserLoggedIn
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper} data-open={isSummaryOpen}>
|
||||
<div className={styles.content}>
|
||||
@@ -122,7 +138,7 @@ export default function MobileSummary({
|
||||
className={styles.priceDetailsButton}
|
||||
>
|
||||
<Caption>{intl.formatMessage({ id: "Total price" })}</Caption>
|
||||
<Subtitle>
|
||||
<Subtitle color={showDiscounted ? "red" : "uiTextHighContrast"}>
|
||||
{formatPrice(
|
||||
intl,
|
||||
totalPriceToShow.local.price,
|
||||
|
||||
Reference in New Issue
Block a user