feat: add block to ARB rate when trying multiroom booking
This commit is contained in:
committed by
Simon.Emanuelsson
parent
01e160db41
commit
3e0f503314
@@ -2,7 +2,7 @@ import stringify from "json-stable-stringify-without-jsonify"
|
|||||||
import { notFound } from "next/navigation"
|
import { notFound } from "next/navigation"
|
||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
|
|
||||||
import { REDEMPTION } from "@/constants/booking"
|
import { combineRegExps, rateTypeRegex, REDEMPTION } from "@/constants/booking"
|
||||||
|
|
||||||
import SelectRate from "@/components/HotelReservation/SelectRate"
|
import SelectRate from "@/components/HotelReservation/SelectRate"
|
||||||
import { HotelInfoCardSkeleton } from "@/components/HotelReservation/SelectRate/HotelInfoCard"
|
import { HotelInfoCardSkeleton } from "@/components/HotelReservation/SelectRate/HotelInfoCard"
|
||||||
@@ -12,6 +12,11 @@ import { convertSearchParamsToObj } from "@/utils/url"
|
|||||||
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||||
import type { LangParams, PageArgs } from "@/types/params"
|
import type { LangParams, PageArgs } from "@/types/params"
|
||||||
|
|
||||||
|
const singleRoomRateTypes = combineRegExps(
|
||||||
|
[rateTypeRegex.ARB, rateTypeRegex.VOUCHER],
|
||||||
|
"i"
|
||||||
|
)
|
||||||
|
|
||||||
export default async function SelectRatePage({
|
export default async function SelectRatePage({
|
||||||
params,
|
params,
|
||||||
searchParams,
|
searchParams,
|
||||||
@@ -21,11 +26,11 @@ export default async function SelectRatePage({
|
|||||||
|
|
||||||
const isMultiRoom = booking.rooms.length > 1
|
const isMultiRoom = booking.rooms.length > 1
|
||||||
const isRedemption = booking.searchType === REDEMPTION
|
const isRedemption = booking.searchType === REDEMPTION
|
||||||
const isVoucher = booking.bookingCode
|
const isArbOrVoucher = booking.bookingCode
|
||||||
? /(^VO[0-9a-z]*$)/i.test(booking.bookingCode)
|
? singleRoomRateTypes.test(booking.bookingCode)
|
||||||
: false
|
: false
|
||||||
|
|
||||||
if ((isMultiRoom && isRedemption) || (isMultiRoom && isVoucher)) {
|
if ((isMultiRoom && isRedemption) || (isMultiRoom && isArbOrVoucher)) {
|
||||||
return notFound()
|
return notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,3 +170,12 @@ export enum PaymentCallbackStatusEnum {
|
|||||||
Error = "error",
|
Error = "error",
|
||||||
Cancel = "cancel",
|
Cancel = "cancel",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function combineRegExps(regexps: RegExp[], flags = "") {
|
||||||
|
return new RegExp(regexps.map((r) => r.source).join("|"), flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const rateTypeRegex = {
|
||||||
|
ARB: /(^B[a-z]{3}\d{6}$)/,
|
||||||
|
VOUCHER: /(^VO[0-9a-z]*$)/,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user