feat: SW-602 Optimized code
This commit is contained in:
@@ -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}
|
<Rooms
|
||||||
noAvailability={!roomsAvailability || !!noRoomsAvailable}
|
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