Merged in feat/sw-2857-refactor-booking-flow-url-updates (pull request #2302)
feat(SW-2857): Refactor booking flow url updates * Add support for removing parameters when using initial values in serializeSearchParams * Don't manually write search params in rate store * Booking is already from live search params so no need * Fix input type in serializeBookingSearchParams Approved-by: Linus Flood
This commit is contained in:
@@ -45,9 +45,9 @@ export function findProduct(
|
||||
}
|
||||
|
||||
export function findProductInRoom(
|
||||
rateCode: string | undefined,
|
||||
rateCode: string | undefined | null,
|
||||
room: RoomConfiguration,
|
||||
counterRateCode = ""
|
||||
counterRateCode: string | undefined | null
|
||||
) {
|
||||
if (!rateCode) {
|
||||
return null
|
||||
@@ -55,7 +55,7 @@ export function findProductInRoom(
|
||||
|
||||
if (room.campaign.length) {
|
||||
const campaignProduct = room.campaign.find((product) =>
|
||||
findProduct(rateCode, product, counterRateCode)
|
||||
findProduct(rateCode, product, counterRateCode || "")
|
||||
)
|
||||
if (campaignProduct) {
|
||||
return campaignProduct
|
||||
@@ -63,7 +63,7 @@ export function findProductInRoom(
|
||||
}
|
||||
if (room.code.length) {
|
||||
const codeProduct = room.code.find((product) =>
|
||||
findProduct(rateCode, product, counterRateCode)
|
||||
findProduct(rateCode, product, counterRateCode || "")
|
||||
)
|
||||
if (codeProduct) {
|
||||
return codeProduct
|
||||
@@ -79,7 +79,7 @@ export function findProductInRoom(
|
||||
}
|
||||
if (room.regular.length) {
|
||||
const regularProduct = room.regular.find((product) =>
|
||||
findProduct(rateCode, product, counterRateCode)
|
||||
findProduct(rateCode, product, counterRateCode || "")
|
||||
)
|
||||
if (regularProduct) {
|
||||
return regularProduct
|
||||
@@ -88,9 +88,9 @@ export function findProductInRoom(
|
||||
}
|
||||
|
||||
export function findSelectedRate(
|
||||
rateCode: string | undefined,
|
||||
counterRateCode: string | undefined,
|
||||
roomTypeCode: string | undefined,
|
||||
rateCode: string | undefined | null,
|
||||
counterRateCode: string | undefined | null,
|
||||
roomTypeCode: string | undefined | null,
|
||||
rooms: RoomConfiguration[] | AvailabilityError
|
||||
) {
|
||||
if (!Array.isArray(rooms)) {
|
||||
@@ -109,17 +109,6 @@ export function findSelectedRate(
|
||||
})
|
||||
}
|
||||
|
||||
export function clearRoomSelectionFromUrl(
|
||||
roomIdx: number,
|
||||
searchParams: URLSearchParams
|
||||
) {
|
||||
searchParams.delete(`room[${roomIdx}].bookingCode`)
|
||||
searchParams.delete(`room[${roomIdx}].counterratecode`)
|
||||
searchParams.delete(`room[${roomIdx}].ratecode`)
|
||||
searchParams.delete(`room[${roomIdx}].roomtype`)
|
||||
return searchParams
|
||||
}
|
||||
|
||||
export function findDefaultCurrency(
|
||||
roomsAvailability: (RoomsAvailability | AvailabilityError)[] | undefined
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user