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"
|
||||
|
||||
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({
|
||||
lang,
|
||||
searchParams,
|
||||
@@ -41,17 +31,17 @@ export async function SelectRatePage({
|
||||
logger.debug("Invalid search params", searchParams)
|
||||
notFound()
|
||||
}
|
||||
|
||||
const isMultiRoom = booking.rooms.length > 1
|
||||
const isRedemption = booking.searchType === SEARCH_TYPE_REDEMPTION
|
||||
const isArbOrVoucher = booking.bookingCode
|
||||
? singleRoomRateTypes.test(booking.bookingCode)
|
||||
const voucherPattern = /^VO[0-9a-z]*$/i
|
||||
const isVoucher = booking.bookingCode
|
||||
? voucherPattern.test(booking.bookingCode)
|
||||
: false
|
||||
|
||||
if ((isMultiRoom && isRedemption) || (isMultiRoom && isArbOrVoucher)) {
|
||||
if ((isMultiRoom && isRedemption) || (isMultiRoom && isVoucher)) {
|
||||
logger.debug(
|
||||
"Invalid search params, can't have multiroom and redemption/voucher",
|
||||
{ isMultiRoom, isRedemption, isArbOrVoucher }
|
||||
{ isMultiRoom, isRedemption, isVoucher }
|
||||
)
|
||||
notFound()
|
||||
}
|
||||
@@ -82,7 +72,3 @@ export async function SelectRatePage({
|
||||
</BookingFlowConfig>
|
||||
)
|
||||
}
|
||||
|
||||
function combineRegExps(regexps: RegExp[], flags = "") {
|
||||
return new RegExp(regexps.map((r) => r.source).join("|"), flags)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user