From 3869c41f58371e0706f81bcf5e59883d0d52c7a3 Mon Sep 17 00:00:00 2001 From: Pontus Dreij Date: Wed, 13 Nov 2024 08:21:47 +0100 Subject: [PATCH] feat(SW-874): Rename function --- components/HotelReservation/SelectRate/Rooms/index.tsx | 4 ++-- components/HotelReservation/SelectRate/Rooms/utils.ts | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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