+
{getBreakfastMessage(rates.flexRate)}
diff --git a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/roomCard.module.css b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/roomCard.module.css
index 9847ba98b..1a2bfd83d 100644
--- a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/roomCard.module.css
+++ b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/roomCard.module.css
@@ -12,7 +12,6 @@
}
.card.noAvailability {
- justify-content: flex-start;
opacity: 0.6;
}
diff --git a/components/HotelReservation/SelectRate/RoomSelection/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/index.tsx
index 3c6b75707..0e71c5fde 100644
--- a/components/HotelReservation/SelectRate/RoomSelection/index.tsx
+++ b/components/HotelReservation/SelectRate/RoomSelection/index.tsx
@@ -8,7 +8,9 @@ import RateSummary from "./RateSummary"
import RoomCard from "./RoomCard"
import {
getHotelReservationQueryParams,
- rateCardEqualHeightSelector,
+ RATE_CARD_EQUAL_HEIGHT_CLASS,
+ RATE_CARDS_AVAILABLE_HEIGHT_CLASS,
+ RATE_CARDS_NOT_AVAILABLE_HEIGHT_CLASS,
} from "./utils"
import styles from "./roomSelection.module.css"
@@ -34,41 +36,44 @@ export default function RoomSelection({
const equalizePriceOptionHeights = useCallback(() => {
if (!roomRefs.current.length) return
+ const optionsSelector = `.${RATE_CARD_EQUAL_HEIGHT_CLASS}`
+ const availableSelector = `.${RATE_CARDS_AVAILABLE_HEIGHT_CLASS}`
+ const notAvailableSelector = `.${RATE_CARDS_NOT_AVAILABLE_HEIGHT_CLASS}`
+ const DEFAULT_RATE_CARD_HEIGHT = 420
+
+ const maxOptionHeights: number[] = []
+ let maxPriceCardHeight = DEFAULT_RATE_CARD_HEIGHT
+
roomRefs.current.forEach((room) => {
- const options = room.querySelectorAll(
- `.${rateCardEqualHeightSelector}`
- )
- options.forEach((option) => {
+ const options = room.querySelectorAll(optionsSelector)
+ options.forEach((option, i) => {
option.style.height = "auto"
+ const optionHeight = option.getBoundingClientRect().height
+ maxOptionHeights[i] = Math.max(maxOptionHeights[i] || 0, optionHeight)
})
+
+ const priceCard = room.querySelector(availableSelector) as HTMLElement
+ if (priceCard) {
+ const priceCardHeight = priceCard.getBoundingClientRect().height
+ maxPriceCardHeight = Math.max(maxPriceCardHeight, priceCardHeight)
+ }
})
- const numOptions =
- roomRefs.current[0]?.querySelectorAll(
- `.${rateCardEqualHeightSelector}`
- ).length || 0
-
- for (let i = 0; i < numOptions; i++) {
- let maxHeight = 0
-
- roomRefs.current.forEach((room) => {
- const option = room.querySelectorAll(
- `.${rateCardEqualHeightSelector}`
- )[i]
+ roomRefs.current.forEach((room) => {
+ const options = room.querySelectorAll(optionsSelector)
+ options.forEach((option, i) => {
if (option) {
- maxHeight = Math.max(maxHeight, option.offsetHeight)
+ option.style.height = `${maxOptionHeights[i]}px`
}
})
- roomRefs.current.forEach((room) => {
- const option = room.querySelectorAll(
- `.${rateCardEqualHeightSelector}`
- )[i]
- if (option) {
- option.style.height = `${maxHeight}px`
- }
- })
- }
+ const noPriceCard = room.querySelector(
+ notAvailableSelector
+ ) as HTMLElement
+ if (noPriceCard) {
+ noPriceCard.style.height = `${maxPriceCardHeight}px`
+ }
+ })
}, [])
useEffect(() => {
diff --git a/components/HotelReservation/SelectRate/RoomSelection/utils.ts b/components/HotelReservation/SelectRate/RoomSelection/utils.ts
index 92ef0be01..d66fe9b9b 100644
--- a/components/HotelReservation/SelectRate/RoomSelection/utils.ts
+++ b/components/HotelReservation/SelectRate/RoomSelection/utils.ts
@@ -102,4 +102,8 @@ export function createQueryParamsForEnterDetails(
return searchParams
}
-export const rateCardEqualHeightSelector = "rateCardEqualHeight"
+export const RATE_CARD_EQUAL_HEIGHT_CLASS = "rateCardEqualHeightSelector"
+export const RATE_CARDS_AVAILABLE_HEIGHT_CLASS =
+ "rateCardAvailableEqualHeightSelector"
+export const RATE_CARDS_NOT_AVAILABLE_HEIGHT_CLASS =
+ "rateCardNotAvailableEqualHeightSelector"