diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx index 38444447f..946aea241 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx @@ -19,11 +19,6 @@ export default async function SummaryPage({ const { hotel, adults, children, roomTypeCode, rateCode, fromDate, toDate } = getQueryParamsForEnterDetails(selectRoomParams) - if (!roomTypeCode || !rateCode) { - console.log("No roomTypeCode or rateCode") - return notFound() - } - const availability = await getSelectedRoomAvailability({ hotelId: parseInt(hotel), adults, diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/page.tsx index e5bf9f73b..ba4e44e34 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/page.tsx @@ -1,11 +1,10 @@ -import { notFound, redirect } from "next/navigation" +import { notFound } from "next/navigation" import { getBreakfastPackages, getCreditCardsSafely, getHotelData, getProfileSafely, - getRoomAvailability, getSelectedRoomAvailability, } from "@/lib/trpc/memoizedRequests" import { HotelIncludeEnum } from "@/server/routers/hotels/input" @@ -38,8 +37,6 @@ export default async function StepPage({ }: PageArgs) { const { lang } = params - void getBreakfastPackages(searchParams.hotel) - const intl = await getIntl() const selectRoomParams = new URLSearchParams(searchParams) const { @@ -52,10 +49,7 @@ export default async function StepPage({ toDate, } = getQueryParamsForEnterDetails(selectRoomParams) - if (!rateCode || !roomTypeCode) { - return notFound() - } - + void getBreakfastPackages(searchParams.hotel) void getSelectedRoomAvailability({ hotelId: parseInt(searchParams.hotel), adults, diff --git a/next.config.js b/next.config.js index fae418d6c..2e8553f1c 100644 --- a/next.config.js +++ b/next.config.js @@ -72,38 +72,172 @@ const nextConfig = { // https://nextjs.org/docs/app/api-reference/next-config-js/redirects#header-cookie-and-query-matching redirects() { + // Param checks needs to be split as Next.js handles everything + // in the missing array as AND, therefore they need to be separate + // to handle when one or more are missing. + // + // Docs: all missing items must not match for the redirect to be applied. return [ - // { - // ---------------------------------------- - // Uncomment when Team Explorer has deployed - // the select room submission - // ---------------------------------------- - // source: "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", - // destination: "/:lang/hotelreservation/select-rate", - // missing: [ - // { - // key: "hotel", - // type: "query", - // value: undefined, - // }, - // { - // key: "fromDate", - // type: "query", - // value: undefined, - // }, - // { - // key: "toDate", - // type: "query", - // value: undefined, - // }, - // { - // key: "room", - // type: "query", - // value: undefined, - // }, - // ], - // permanent: false, - // }, + { + // ---------------------------------------- + // hotel (hotelId) param missing + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "hotel", + type: "query", + value: undefined, + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // hotel (hotelId) param has to be an integer + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "hotel", + type: "query", + value: "^[0-9]+$", + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // fromDate param missing + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "fromDate", + type: "query", + value: undefined, + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // fromDate param has to be a date + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "fromDate", + type: "query", + value: "^([12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))$", + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // toDate param missing + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "toDate", + type: "query", + value: undefined, + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // toDate param has to be a date + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "toDate", + type: "query", + value: "^([12]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))$", + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // room[0].adults param missing + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "room[0].adults", + type: "query", + value: undefined, + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // room[0].adults param has to be an integer + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "room[0].adults", + type: "query", + value: "^[0-9]+$", + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // room[0].ratecode param missing + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "room[0].ratecode", + type: "query", + value: undefined, + }, + ], + permanent: false, + }, + { + // ---------------------------------------- + // room[0].roomtype param missing + // ---------------------------------------- + source: + "/:lang/hotelreservation/(select-bed|breakfast|details|payment)", + destination: "/:lang/hotelreservation/select-rate", + missing: [ + { + key: "room[0].roomtype", + type: "query", + value: undefined, + }, + ], + permanent: false, + }, ] }, diff --git a/types/components/hotelReservation/selectRate/selectRate.ts b/types/components/hotelReservation/selectRate/selectRate.ts index fd1771955..7083afa6d 100644 --- a/types/components/hotelReservation/selectRate/selectRate.ts +++ b/types/components/hotelReservation/selectRate/selectRate.ts @@ -7,8 +7,8 @@ export interface Child { interface Room { adults: number - roomtype?: string - ratecode?: string + roomtype: string + ratecode: string counterratecode?: string child?: Child[] }