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()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
const [user, availability] = await Promise.all([
|
const availability = await getSelectedRoomAvailability({
|
||||||
getProfileSafely(),
|
hotelId: parseInt(hotel),
|
||||||
getSelectedRoomAvailability({
|
adults,
|
||||||
hotelId: parseInt(hotel),
|
children,
|
||||||
adults,
|
roomStayStartDate: fromDate,
|
||||||
children,
|
roomStayEndDate: toDate,
|
||||||
roomStayStartDate: fromDate,
|
rateCode,
|
||||||
roomStayEndDate: toDate,
|
roomTypeCode,
|
||||||
rateCode,
|
})
|
||||||
roomTypeCode,
|
const user = await getProfileSafely()
|
||||||
}),
|
|
||||||
])
|
|
||||||
|
|
||||||
if (!availability) {
|
if (!availability) {
|
||||||
console.error("No hotel or availability data", availability)
|
console.error("No hotel or availability data", availability)
|
||||||
|
|||||||
@@ -52,46 +52,37 @@ export default async function StepPage({
|
|||||||
toDate,
|
toDate,
|
||||||
} = getQueryParamsForEnterDetails(selectRoomParams)
|
} = getQueryParamsForEnterDetails(selectRoomParams)
|
||||||
|
|
||||||
void getRoomAvailability({
|
|
||||||
hotelId: parseInt(hotelId),
|
|
||||||
adults,
|
|
||||||
children,
|
|
||||||
roomStayStartDate: fromDate,
|
|
||||||
roomStayEndDate: toDate,
|
|
||||||
rateCode
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if (!rateCode || !roomTypeCode) {
|
if (!rateCode || !roomTypeCode) {
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
const [
|
void getSelectedRoomAvailability({
|
||||||
hotelData,
|
hotelId: parseInt(searchParams.hotel),
|
||||||
user,
|
adults,
|
||||||
savedCreditCards,
|
children,
|
||||||
breakfastPackages,
|
roomStayStartDate: fromDate,
|
||||||
roomAvailability,
|
roomStayEndDate: toDate,
|
||||||
] = await Promise.all([
|
rateCode,
|
||||||
getHotelData({
|
roomTypeCode,
|
||||||
hotelId,
|
})
|
||||||
language: lang,
|
|
||||||
include: [HotelIncludeEnum.RoomCategories],
|
|
||||||
}),
|
|
||||||
|
|
||||||
getProfileSafely(),
|
const hotelData = await getHotelData({
|
||||||
getCreditCardsSafely(),
|
hotelId,
|
||||||
getBreakfastPackages(searchParams.hotel),
|
language: lang,
|
||||||
getSelectedRoomAvailability({
|
include: [HotelIncludeEnum.RoomCategories],
|
||||||
hotelId: parseInt(searchParams.hotel),
|
})
|
||||||
adults,
|
const roomAvailability = await getSelectedRoomAvailability({
|
||||||
children,
|
hotelId: parseInt(searchParams.hotel),
|
||||||
roomStayStartDate: fromDate,
|
adults,
|
||||||
roomStayEndDate: toDate,
|
children,
|
||||||
rateCode,
|
roomStayStartDate: fromDate,
|
||||||
roomTypeCode,
|
roomStayEndDate: toDate,
|
||||||
}),
|
rateCode,
|
||||||
])
|
roomTypeCode,
|
||||||
|
})
|
||||||
|
const breakfastPackages = await getBreakfastPackages(searchParams.hotel)
|
||||||
|
const user = await getProfileSafely()
|
||||||
|
const savedCreditCards = await getCreditCardsSafely()
|
||||||
|
|
||||||
if (!isValidStep(params.step) || !hotelData || !roomAvailability) {
|
if (!isValidStep(params.step) || !hotelData || !roomAvailability) {
|
||||||
return notFound()
|
return notFound()
|
||||||
|
|||||||
Reference in New Issue
Block a user