diff --git a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/flexibilityOption.module.css b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/flexibilityOption.module.css index 433127ac7..1c6b93e4b 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/flexibilityOption.module.css +++ b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/flexibilityOption.module.css @@ -8,6 +8,7 @@ display: flex; flex-direction: column; gap: var(--Spacing-x-half); + height: 100%; } .noPricesCard { diff --git a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx index a6da82392..c29619c10 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx @@ -11,7 +11,6 @@ import Label from "@/components/TempDesignSystem/Form/Label" import Body from "@/components/TempDesignSystem/Text/Body" import Caption from "@/components/TempDesignSystem/Text/Caption" -import { RATE_CARD_EQUAL_HEIGHT_CLASS } from "../utils" import PriceTable from "./PriceList" import styles from "./flexibilityOption.module.css" @@ -69,7 +68,7 @@ export default function FlexibilityOption({ if (!product) { return ( -
+
@@ -116,7 +115,7 @@ export default function FlexibilityOption({ onClick={onClick} ref={inputElementRef} /> -
+
+
  • @@ -186,9 +182,7 @@ export default function RoomCard({ */}
    -
    +
    {getBreakfastMessage(rates.flexRate)} @@ -204,23 +198,21 @@ export default function RoomCard({
    ) : ( -
    - {Object.entries(rates).map(([key, rate]) => ( - - ))} -
    + Object.entries(rates).map(([key, rate]) => ( + + )) )}
    -
  • + ) } diff --git a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/roomCard.module.css b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/roomCard.module.css index 70bdc7705..f833961f5 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/roomCard.module.css +++ b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/roomCard.module.css @@ -1,13 +1,14 @@ .card { font-size: 14px; - display: flex; - flex-direction: column; + display: grid; + grid-template-columns: 1fr; + grid-template-rows: subgrid; background-color: #fff; border-radius: var(--Corner-radius-Large); border: 1px solid var(--Base-Border-Subtle); position: relative; - height: 100%; justify-content: space-between; + grid-row: span 5; } .card.noAvailability { @@ -38,9 +39,16 @@ .container { padding: var(--Spacing-x1) var(--Spacing-x2) var(--Spacing-x2); - display: flex; - flex-direction: column; + display: grid; + grid-template-rows: subgrid; gap: var(--Spacing-x-one-and-half); + grid-row: span 4; +} + +/* Make sure rows with only unavailable rooms still has a min-height */ +.container:has(.noRoomsContainer) { + min-height: 400px; + grid-template-rows: auto repeat(3, 1fr); } .roomDetails { @@ -62,9 +70,9 @@ } .flexibilityOptions { - display: flex; - flex-direction: column; + display: grid; gap: var(--Spacing-x2); + grid-template-rows: repeat(3, 1fr); } .chipContainer { @@ -89,14 +97,16 @@ } .noRoomsContainer { - padding: var(--Spacing-x2); - background-color: var(--Base-Surface-Secondary-light-Normal); - border-radius: var(--Corner-radius-Medium); - margin: 0; + height: 100%; width: 100%; } .noRooms { + padding: var(--Spacing-x2); + background-color: var(--Base-Surface-Secondary-light-Normal); + border-radius: var(--Corner-radius-Medium); + margin: 0; + display: flex; gap: var(--Spacing-x1); } diff --git a/components/HotelReservation/SelectRate/RoomSelection/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/index.tsx index b784c94bd..3a46fb1fd 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/index.tsx @@ -1,19 +1,10 @@ "use client" import { usePathname, useRouter, useSearchParams } from "next/navigation" -import { useSession } from "next-auth/react" -import { useCallback, useEffect, useMemo, useRef } from "react" - -import { debounce } from "@/utils/debounce" -import { isValidSession } from "@/utils/session" +import { useMemo } from "react" import RateSummary from "./RateSummary" import RoomCard from "./RoomCard" -import { - getHotelReservationQueryParams, - RATE_CARD_EQUAL_HEIGHT_CLASS, - RATE_CARDS_AVAILABLE_HEIGHT_CLASS, - RATE_CARDS_NOT_AVAILABLE_HEIGHT_CLASS, -} from "./utils" +import { getHotelReservationQueryParams } from "./utils" import styles from "./roomSelection.module.css" @@ -32,68 +23,8 @@ export default function RoomSelection({ const router = useRouter() const pathname = usePathname() const searchParams = useSearchParams() - const roomRefs = useRef([]) const { roomConfigurations, rateDefinitions } = roomsAvailability - 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 = 380 - - const maxOptionHeights: number[] = [] - let maxPriceCardHeight = DEFAULT_RATE_CARD_HEIGHT - - roomRefs.current.forEach((room) => { - 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) - } - }) - - roomRefs.current.forEach((room) => { - const options = room.querySelectorAll(optionsSelector) - options.forEach((option, i) => { - if (option) { - option.style.height = `${maxOptionHeights[i]}px` - } - }) - - const noPriceCard = room.querySelector( - notAvailableSelector - ) as HTMLElement - if (noPriceCard) { - noPriceCard.style.height = `${maxPriceCardHeight}px` - } - }) - }, []) - - useEffect(() => { - const debouncedResizeHandler = debounce(function () { - equalizePriceOptionHeights() - }) - - const observer = new ResizeObserver(debouncedResizeHandler) - - observer.observe(document.documentElement) - - return () => { - if (observer) { - observer.unobserve(document.documentElement) - } - } - }, [roomRefs, equalizePriceOptionHeights]) - const queryParams = useMemo(() => { const params = new URLSearchParams(searchParams) const searchParamsObject = getHotelReservationQueryParams(searchParams) @@ -139,23 +70,17 @@ export default function RoomSelection({ >
      {roomConfigurations.map((roomConfiguration, index) => ( -
    • { - if (el) roomRefs.current[index] = el - }} - > - -
    • + /> ))}
    {rateSummary && ( diff --git a/components/HotelReservation/SelectRate/RoomSelection/roomSelection.module.css b/components/HotelReservation/SelectRate/RoomSelection/roomSelection.module.css index 3da3c9fb2..77132700e 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/roomSelection.module.css +++ b/components/HotelReservation/SelectRate/RoomSelection/roomSelection.module.css @@ -5,8 +5,8 @@ .roomList { list-style: none; display: grid; - grid-template-columns: 1fr; gap: var(--Spacing-x3); + grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } .roomList > li { @@ -18,7 +18,3 @@ position: fixed; width: 0; } - -.roomList { - grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); -} diff --git a/components/HotelReservation/SelectRate/RoomSelection/utils.ts b/components/HotelReservation/SelectRate/RoomSelection/utils.ts index 93a364a80..baa890a2b 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/utils.ts +++ b/components/HotelReservation/SelectRate/RoomSelection/utils.ts @@ -111,9 +111,3 @@ export function createQueryParamsForEnterDetails( return searchParams } - -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"