feat: show both prices for multiroom room 2-4 on all users

This commit is contained in:
Simon Emanuelsson
2025-02-17 15:10:48 +01:00
parent cf3268bda3
commit b536c51889
12 changed files with 92 additions and 49 deletions

View File

@@ -102,7 +102,7 @@ export default function Summary({
const childBedExtraBed = childrenBeds?.get(ChildBedMapEnum.IN_EXTRA_BED)
const memberPrice = getMemberPrice(room.roomRate)
const showMemberPrice = !!(isMember && memberPrice)
const showMemberPrice = !!(isMember && memberPrice && roomNumber === 1)
const adultsMsg = intl.formatMessage(
{ id: "{totalAdults, plural, one {# adult} other {# adults}}" },

View File

@@ -38,6 +38,7 @@ export default function RateSummary({ isUserLoggedIn }: RateSummaryProps) {
roomsAvailability: state.roomsAvailability,
searchParams: state.searchParams,
}))
const intl = useIntl()
const router = useRouter()
const params = new URLSearchParams(searchParams)
@@ -130,24 +131,44 @@ export default function RateSummary({ isUserLoggedIn }: RateSummaryProps) {
<div className={styles.summary}>
<div className={styles.content}>
<div className={styles.summaryText}>
{rateSummary.map((room, index) => (
<div key={index} className={styles.roomSummary}>
<Subtitle color="uiTextHighContrast">
{intl.formatMessage(
{ id: "Room {roomIndex}" },
{ roomIndex: index + 1 }
{rateSummary.map((room, index) => {
const isMainRoom = index + 1 === 1
return (
<div key={index} className={styles.roomSummary}>
{rateSummary.length > 1 ? (
<>
<Subtitle color="uiTextHighContrast">
{intl.formatMessage(
{ id: "Room {roomIndex}" },
{ roomIndex: index + 1 }
)}
</Subtitle>
<Body color="uiTextMediumContrast">{room.roomType}</Body>
<Caption color="uiTextMediumContrast">
{getRateDetails(
isUserLoggedIn && room.member && isMainRoom
? room.member?.rateCode
: room.public.rateCode
)}
</Caption>
</>
) : (
<>
<Subtitle color="uiTextHighContrast">
{room.roomType}
</Subtitle>
<Body color="uiTextMediumContrast">
{getRateDetails(
isUserLoggedIn && room.member && isMainRoom
? room.member?.rateCode
: room.public.rateCode
)}
</Body>
</>
)}
</Subtitle>
<Body color="uiTextMediumContrast">{room.roomType}</Body>
<Caption color="uiTextMediumContrast">
{getRateDetails(
isUserLoggedIn && room.member
? room.member?.rateCode
: room.public.rateCode
)}
</Caption>
</div>
))}
</div>
)
})}
{/* Render unselected rooms */}
{Array.from({
length: totalRoomsRequired - rateSummary.length,

View File

@@ -11,9 +11,11 @@ export const calculateTotalPrice = (
petRoomPackage: RoomPackage | undefined
) => {
return selectedRateSummary.reduce<Price>(
(total, room) => {
(total, room, idx) => {
const priceToUse =
isUserLoggedIn && room.member ? room.member : room.public
isUserLoggedIn && room.member && idx + 1 === 1
? room.member
: room.public
const isPetRoom = room.features.find(
(feature) => feature.code === RoomPackageCodeEnum.PET_ROOM
)