diff --git a/components/HotelReservation/SelectRate/Rooms/index.tsx b/components/HotelReservation/SelectRate/Rooms/index.tsx index a3454818a..d4c8ec50b 100644 --- a/components/HotelReservation/SelectRate/Rooms/index.tsx +++ b/components/HotelReservation/SelectRate/Rooms/index.tsx @@ -4,7 +4,7 @@ import { useCallback, useState } from "react" import RoomFilter from "../RoomFilter" import RoomSelection from "../RoomSelection" -import { getLowestPricedRooms } from "./utils" +import { getLowestPricedDuplicateRooms } from "./utils" import styles from "./rooms.module.css" @@ -25,7 +25,7 @@ export default function Rooms({ packages, }: Omit) { console.log("roomsAvailability", roomsAvailability) - const visibleRooms: RoomConfiguration[] = getLowestPricedRooms( + const visibleRooms: RoomConfiguration[] = getLowestPricedDuplicateRooms( roomsAvailability.roomConfigurations ) diff --git a/components/HotelReservation/SelectRate/Rooms/utils.ts b/components/HotelReservation/SelectRate/Rooms/utils.ts index bb1ff48c9..3c0507371 100644 --- a/components/HotelReservation/SelectRate/Rooms/utils.ts +++ b/components/HotelReservation/SelectRate/Rooms/utils.ts @@ -1,6 +1,12 @@ import { RoomConfiguration } from "@/server/routers/hotels/output" -export function getLowestPricedRooms(roomConfigurations: RoomConfiguration[]) { +/** + * Get the lowest priced room for each room type that appears more than once. + */ + +export function getLowestPricedDuplicateRooms( + roomConfigurations: RoomConfiguration[] +) { const roomTypeCount = roomConfigurations.reduce( (acc, room) => { acc[room.roomType] = (acc[room.roomType] || 0) + 1