Merged in feat/SW-599 (pull request #803)
feat: block all entries to enter details that miss the required params Approved-by: Christel Westerberg Approved-by: Tobias Johansson
This commit is contained in:
@@ -19,11 +19,6 @@ export default async function SummaryPage({
|
|||||||
const { hotel, adults, children, roomTypeCode, rateCode, fromDate, toDate } =
|
const { hotel, adults, children, roomTypeCode, rateCode, fromDate, toDate } =
|
||||||
getQueryParamsForEnterDetails(selectRoomParams)
|
getQueryParamsForEnterDetails(selectRoomParams)
|
||||||
|
|
||||||
if (!roomTypeCode || !rateCode) {
|
|
||||||
console.log("No roomTypeCode or rateCode")
|
|
||||||
return notFound()
|
|
||||||
}
|
|
||||||
|
|
||||||
const availability = await getSelectedRoomAvailability({
|
const availability = await getSelectedRoomAvailability({
|
||||||
hotelId: parseInt(hotel),
|
hotelId: parseInt(hotel),
|
||||||
adults,
|
adults,
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { notFound, redirect } from "next/navigation"
|
import { notFound } from "next/navigation"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBreakfastPackages,
|
getBreakfastPackages,
|
||||||
getCreditCardsSafely,
|
getCreditCardsSafely,
|
||||||
getHotelData,
|
getHotelData,
|
||||||
getProfileSafely,
|
getProfileSafely,
|
||||||
getRoomAvailability,
|
|
||||||
getSelectedRoomAvailability,
|
getSelectedRoomAvailability,
|
||||||
} from "@/lib/trpc/memoizedRequests"
|
} from "@/lib/trpc/memoizedRequests"
|
||||||
import { HotelIncludeEnum } from "@/server/routers/hotels/input"
|
import { HotelIncludeEnum } from "@/server/routers/hotels/input"
|
||||||
@@ -38,8 +37,6 @@ export default async function StepPage({
|
|||||||
}: PageArgs<LangParams & { step: StepEnum }, SelectRateSearchParams>) {
|
}: PageArgs<LangParams & { step: StepEnum }, SelectRateSearchParams>) {
|
||||||
const { lang } = params
|
const { lang } = params
|
||||||
|
|
||||||
void getBreakfastPackages(searchParams.hotel)
|
|
||||||
|
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
const selectRoomParams = new URLSearchParams(searchParams)
|
const selectRoomParams = new URLSearchParams(searchParams)
|
||||||
const {
|
const {
|
||||||
@@ -52,10 +49,7 @@ export default async function StepPage({
|
|||||||
toDate,
|
toDate,
|
||||||
} = getQueryParamsForEnterDetails(selectRoomParams)
|
} = getQueryParamsForEnterDetails(selectRoomParams)
|
||||||
|
|
||||||
if (!rateCode || !roomTypeCode) {
|
void getBreakfastPackages(searchParams.hotel)
|
||||||
return notFound()
|
|
||||||
}
|
|
||||||
|
|
||||||
void getSelectedRoomAvailability({
|
void getSelectedRoomAvailability({
|
||||||
hotelId: parseInt(searchParams.hotel),
|
hotelId: parseInt(searchParams.hotel),
|
||||||
adults,
|
adults,
|
||||||
|
|||||||
196
next.config.js
196
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
|
// https://nextjs.org/docs/app/api-reference/next-config-js/redirects#header-cookie-and-query-matching
|
||||||
redirects() {
|
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 [
|
return [
|
||||||
// {
|
{
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// Uncomment when Team Explorer has deployed
|
// hotel (hotelId) param missing
|
||||||
// the select room submission
|
// ----------------------------------------
|
||||||
// ----------------------------------------
|
source:
|
||||||
// source: "/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||||
// destination: "/:lang/hotelreservation/select-rate",
|
destination: "/:lang/hotelreservation/select-rate",
|
||||||
// missing: [
|
missing: [
|
||||||
// {
|
{
|
||||||
// key: "hotel",
|
key: "hotel",
|
||||||
// type: "query",
|
type: "query",
|
||||||
// value: undefined,
|
value: undefined,
|
||||||
// },
|
},
|
||||||
// {
|
],
|
||||||
// key: "fromDate",
|
permanent: false,
|
||||||
// type: "query",
|
},
|
||||||
// value: undefined,
|
{
|
||||||
// },
|
// ----------------------------------------
|
||||||
// {
|
// hotel (hotelId) param has to be an integer
|
||||||
// key: "toDate",
|
// ----------------------------------------
|
||||||
// type: "query",
|
source:
|
||||||
// value: undefined,
|
"/:lang/hotelreservation/(select-bed|breakfast|details|payment)",
|
||||||
// },
|
destination: "/:lang/hotelreservation/select-rate",
|
||||||
// {
|
missing: [
|
||||||
// key: "room",
|
{
|
||||||
// type: "query",
|
key: "hotel",
|
||||||
// value: undefined,
|
type: "query",
|
||||||
// },
|
value: "^[0-9]+$",
|
||||||
// ],
|
},
|
||||||
// permanent: false,
|
],
|
||||||
// },
|
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,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ export interface Child {
|
|||||||
|
|
||||||
interface Room {
|
interface Room {
|
||||||
adults: number
|
adults: number
|
||||||
roomtype?: string
|
roomtype: string
|
||||||
ratecode?: string
|
ratecode: string
|
||||||
counterratecode?: string
|
counterratecode?: string
|
||||||
child?: Child[]
|
child?: Child[]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user