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