fix: preload requests to avoid needing to promise.all
This commit is contained in:
@@ -24,18 +24,16 @@ export default async function SummaryPage({
|
||||
return notFound()
|
||||
}
|
||||
|
||||
const [user, availability] = await Promise.all([
|
||||
getProfileSafely(),
|
||||
getSelectedRoomAvailability({
|
||||
hotelId: parseInt(hotel),
|
||||
adults,
|
||||
children,
|
||||
roomStayStartDate: fromDate,
|
||||
roomStayEndDate: toDate,
|
||||
rateCode,
|
||||
roomTypeCode,
|
||||
}),
|
||||
])
|
||||
const availability = await getSelectedRoomAvailability({
|
||||
hotelId: parseInt(hotel),
|
||||
adults,
|
||||
children,
|
||||
roomStayStartDate: fromDate,
|
||||
roomStayEndDate: toDate,
|
||||
rateCode,
|
||||
roomTypeCode,
|
||||
})
|
||||
const user = await getProfileSafely()
|
||||
|
||||
if (!availability) {
|
||||
console.error("No hotel or availability data", availability)
|
||||
|
||||
@@ -52,46 +52,37 @@ export default async function StepPage({
|
||||
toDate,
|
||||
} = getQueryParamsForEnterDetails(selectRoomParams)
|
||||
|
||||
void getRoomAvailability({
|
||||
hotelId: parseInt(hotelId),
|
||||
adults,
|
||||
children,
|
||||
roomStayStartDate: fromDate,
|
||||
roomStayEndDate: toDate,
|
||||
rateCode
|
||||
})
|
||||
|
||||
|
||||
if (!rateCode || !roomTypeCode) {
|
||||
return notFound()
|
||||
}
|
||||
|
||||
const [
|
||||
hotelData,
|
||||
user,
|
||||
savedCreditCards,
|
||||
breakfastPackages,
|
||||
roomAvailability,
|
||||
] = await Promise.all([
|
||||
getHotelData({
|
||||
hotelId,
|
||||
language: lang,
|
||||
include: [HotelIncludeEnum.RoomCategories],
|
||||
}),
|
||||
void getSelectedRoomAvailability({
|
||||
hotelId: parseInt(searchParams.hotel),
|
||||
adults,
|
||||
children,
|
||||
roomStayStartDate: fromDate,
|
||||
roomStayEndDate: toDate,
|
||||
rateCode,
|
||||
roomTypeCode,
|
||||
})
|
||||
|
||||
getProfileSafely(),
|
||||
getCreditCardsSafely(),
|
||||
getBreakfastPackages(searchParams.hotel),
|
||||
getSelectedRoomAvailability({
|
||||
hotelId: parseInt(searchParams.hotel),
|
||||
adults,
|
||||
children,
|
||||
roomStayStartDate: fromDate,
|
||||
roomStayEndDate: toDate,
|
||||
rateCode,
|
||||
roomTypeCode,
|
||||
}),
|
||||
])
|
||||
const hotelData = await getHotelData({
|
||||
hotelId,
|
||||
language: lang,
|
||||
include: [HotelIncludeEnum.RoomCategories],
|
||||
})
|
||||
const roomAvailability = await getSelectedRoomAvailability({
|
||||
hotelId: parseInt(searchParams.hotel),
|
||||
adults,
|
||||
children,
|
||||
roomStayStartDate: fromDate,
|
||||
roomStayEndDate: toDate,
|
||||
rateCode,
|
||||
roomTypeCode,
|
||||
})
|
||||
const breakfastPackages = await getBreakfastPackages(searchParams.hotel)
|
||||
const user = await getProfileSafely()
|
||||
const savedCreditCards = await getCreditCardsSafely()
|
||||
|
||||
if (!isValidStep(params.step) || !hotelData || !roomAvailability) {
|
||||
return notFound()
|
||||
|
||||
Reference in New Issue
Block a user