fix(SW-614): move filtering logic to routes
This commit is contained in:
@@ -22,7 +22,12 @@ import type { LangParams, PageArgs } from "@/types/params"
|
||||
export function preload() {
|
||||
void getProfileSafely()
|
||||
void getCreditCardsSafely()
|
||||
void getRoomAvailability("811", 1, "2024-11-01", "2024-11-02")
|
||||
void getRoomAvailability({
|
||||
hotelId: "811",
|
||||
adults: 1,
|
||||
roomStayStartDate: "2024-11-01",
|
||||
roomStayEndDate: "2024-11-02",
|
||||
})
|
||||
}
|
||||
|
||||
function isValidStep(step: string): step is StepEnum {
|
||||
@@ -45,12 +50,12 @@ export default async function StepPage({
|
||||
const savedCreditCards = await getCreditCardsSafely()
|
||||
const breakfastPackages = await getBreakfastPackages(searchParams.hotel)
|
||||
|
||||
const roomAvailability = await getRoomAvailability(
|
||||
searchParams.hotel,
|
||||
Number(searchParams.adults),
|
||||
searchParams.checkIn,
|
||||
searchParams.checkOut
|
||||
)
|
||||
const roomAvailability = await getRoomAvailability({
|
||||
hotelId: searchParams.hotel,
|
||||
adults: Number(searchParams.adults),
|
||||
roomStayStartDate: searchParams.checkIn,
|
||||
roomStayEndDate: searchParams.checkOut,
|
||||
})
|
||||
|
||||
if (!isValidStep(params.step) || !hotel || !roomAvailability) {
|
||||
return notFound()
|
||||
@@ -103,10 +108,8 @@ export default async function StepPage({
|
||||
<Payment
|
||||
hotelId={searchParams.hotel}
|
||||
otherPaymentOptions={
|
||||
mustBeGuaranteed
|
||||
? []
|
||||
: hotel.data.attributes.merchantInformationData
|
||||
.alternatePaymentOptions
|
||||
hotel.data.attributes.merchantInformationData
|
||||
.alternatePaymentOptions
|
||||
}
|
||||
savedCreditCards={savedCreditCards}
|
||||
mustBeGuaranteed={mustBeGuaranteed}
|
||||
|
||||
Reference in New Issue
Block a user