fix: filter out room availability based on packages
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { selectRate } from "@/constants/routes/hotelReservation"
|
||||
import {
|
||||
getPackages,
|
||||
getProfileSafely,
|
||||
@@ -17,6 +20,7 @@ import { SelectRateSearchParams } from "@/types/components/hotelReservation/sele
|
||||
import { LangParams, PageArgs, SearchParams } from "@/types/params"
|
||||
|
||||
export default async function SummaryPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, SearchParams<SelectRateSearchParams>>) {
|
||||
const selectRoomParams = new URLSearchParams(searchParams)
|
||||
@@ -39,6 +43,7 @@ export default async function SummaryPage({
|
||||
roomStayEndDate: toDate,
|
||||
rateCode,
|
||||
roomTypeCode,
|
||||
packageCodes,
|
||||
})
|
||||
const user = await getProfileSafely()
|
||||
const packages = await getPackages({
|
||||
@@ -50,10 +55,10 @@ export default async function SummaryPage({
|
||||
packageCodes,
|
||||
})
|
||||
|
||||
if (!availability) {
|
||||
if (!availability || !availability.selectedRoom) {
|
||||
console.error("No hotel or availability data", availability)
|
||||
// TODO: handle this case
|
||||
return null
|
||||
redirect(selectRate[params.lang])
|
||||
}
|
||||
|
||||
const prices =
|
||||
|
||||
@@ -46,7 +46,7 @@ export default async function StepPage({
|
||||
toDate,
|
||||
} = getQueryParamsForEnterDetails(selectRoomParams)
|
||||
|
||||
const { adults, children, roomTypeCode, rateCode } = rooms[0] // TODO: Handle multiple rooms
|
||||
const { adults, children, roomTypeCode, rateCode, packages } = rooms[0] // TODO: Handle multiple rooms
|
||||
|
||||
const childrenAsString = children && generateChildrenString(children)
|
||||
|
||||
@@ -60,6 +60,7 @@ export default async function StepPage({
|
||||
roomStayEndDate: toDate,
|
||||
rateCode,
|
||||
roomTypeCode,
|
||||
packageCodes: packages,
|
||||
})
|
||||
|
||||
const roomAvailability = await getSelectedRoomAvailability({
|
||||
@@ -70,6 +71,7 @@ export default async function StepPage({
|
||||
roomStayEndDate: toDate,
|
||||
rateCode,
|
||||
roomTypeCode,
|
||||
packageCodes: packages,
|
||||
})
|
||||
const hotelData = await getHotelData({
|
||||
hotelId,
|
||||
|
||||
Reference in New Issue
Block a user