feat: SW-602 Optimized code

This commit is contained in:
Hrishikesh Vaipurkar
2024-11-15 12:45:43 +01:00
parent f432508112
commit 0a3b9450b6

View File

@@ -84,13 +84,17 @@ export default async function SelectRatePage({
getProfileSafely(), getProfileSafely(),
]) ])
if (!roomsAvailability) {
return "No rooms found" // TODO: Add a proper error message
}
if (!hotelData) { if (!hotelData) {
return "No hotel data found" // TODO: Add a proper error message return "No hotel data found" // TODO: Add a proper error message
} }
const roomCategories = hotelData?.included const roomCategories = hotelData?.included
const noRoomsAvailable = roomsAvailability?.roomConfigurations.reduce( const noRoomsAvailable = roomsAvailability.roomConfigurations.reduce(
(acc, room) => { (acc, room) => {
return acc && room.status === "NotAvailable" return acc && room.status === "NotAvailable"
}, },
@@ -99,18 +103,13 @@ export default async function SelectRatePage({
return ( return (
<> <>
<HotelInfoCard <HotelInfoCard hotelData={hotelData} noAvailability={noRoomsAvailable} />
hotelData={hotelData}
noAvailability={!roomsAvailability || !!noRoomsAvailable}
/>
{roomsAvailability ? (
<Rooms <Rooms
roomsAvailability={roomsAvailability} roomsAvailability={roomsAvailability}
roomCategories={roomCategories ?? []} roomCategories={roomCategories ?? []}
user={user} user={user}
packages={packages ?? []} packages={packages ?? []}
/> />
) : null}
</> </>
) )
} }