Merged in feat/BOOK-81-enable-multiroom-arb-rate (pull request #3010)
feat(BOOK-81): enable multiroom for arb rates * feat(BOOK-81): enable multiroom for arb rates Approved-by: Erik Tiekstra
This commit is contained in:
@@ -16,16 +16,6 @@ import type { NextSearchParams } from "../types"
|
|||||||
|
|
||||||
export { SelectRateSkeleton as SelectRatePageSkeleton } from "../components/SelectRate"
|
export { SelectRateSkeleton as SelectRatePageSkeleton } from "../components/SelectRate"
|
||||||
|
|
||||||
const rateTypeRegex = {
|
|
||||||
ARB: /(^B[a-z]{3}\d{6}$)/,
|
|
||||||
VOUCHER: /(^VO[0-9a-z]*$)/,
|
|
||||||
}
|
|
||||||
|
|
||||||
const singleRoomRateTypes = combineRegExps(
|
|
||||||
[rateTypeRegex.ARB, rateTypeRegex.VOUCHER],
|
|
||||||
"i"
|
|
||||||
)
|
|
||||||
|
|
||||||
export async function SelectRatePage({
|
export async function SelectRatePage({
|
||||||
lang,
|
lang,
|
||||||
searchParams,
|
searchParams,
|
||||||
@@ -41,17 +31,17 @@ export async function SelectRatePage({
|
|||||||
logger.debug("Invalid search params", searchParams)
|
logger.debug("Invalid search params", searchParams)
|
||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
const isMultiRoom = booking.rooms.length > 1
|
const isMultiRoom = booking.rooms.length > 1
|
||||||
const isRedemption = booking.searchType === SEARCH_TYPE_REDEMPTION
|
const isRedemption = booking.searchType === SEARCH_TYPE_REDEMPTION
|
||||||
const isArbOrVoucher = booking.bookingCode
|
const voucherPattern = /^VO[0-9a-z]*$/i
|
||||||
? singleRoomRateTypes.test(booking.bookingCode)
|
const isVoucher = booking.bookingCode
|
||||||
|
? voucherPattern.test(booking.bookingCode)
|
||||||
: false
|
: false
|
||||||
|
|
||||||
if ((isMultiRoom && isRedemption) || (isMultiRoom && isArbOrVoucher)) {
|
if ((isMultiRoom && isRedemption) || (isMultiRoom && isVoucher)) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Invalid search params, can't have multiroom and redemption/voucher",
|
"Invalid search params, can't have multiroom and redemption/voucher",
|
||||||
{ isMultiRoom, isRedemption, isArbOrVoucher }
|
{ isMultiRoom, isRedemption, isVoucher }
|
||||||
)
|
)
|
||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
@@ -82,7 +72,3 @@ export async function SelectRatePage({
|
|||||||
</BookingFlowConfig>
|
</BookingFlowConfig>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function combineRegExps(regexps: RegExp[], flags = "") {
|
|
||||||
return new RegExp(regexps.map((r) => r.source).join("|"), flags)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user