Merged in fix/SW-2905-select-rate-page-multi- (pull request #2465)

fix: SW-2905 Fixed room auto close after filter changes

* fix: SW-2905 Fixed room auto close after filter changes


Approved-by: Linus Flood
This commit is contained in:
Hrishikesh Vaipurkar
2025-07-01 09:28:23 +00:00
parent 6eeaa1cd40
commit 67ebef4fa0

View File

@@ -31,10 +31,15 @@ export function createRatesStore({
initialActiveRoom,
vat,
}: InitialState) {
function updateUrl(booking: RatesState["booking"]) {
function updateUrl(booking: RatesState["booking"], activeRoom: number = -1) {
const searchParams = serializeBookingSearchParams(booking, {
initialSearchParams: new URLSearchParams(window.location.search),
})
if (activeRoom >= 0) {
searchParams.set("modifyRateIndex", activeRoom.toString())
} else {
searchParams.delete("modifyRateIndex")
}
window.history.replaceState({}, "", `${pathname}?${searchParams}`)
}
@@ -111,7 +116,7 @@ export function createRatesStore({
}
let activeRoom = rateSummary.length
if (initialActiveRoom) {
if (initialActiveRoom !== undefined && initialActiveRoom >= 0) {
activeRoom = initialActiveRoom
} else if (rateSummary.length === booking.rooms.length) {
// Finds the first unselected room and sets that to active
@@ -274,7 +279,7 @@ export function createRatesStore({
state.booking.rooms[idx].packages = null
}
updateUrl(state.booking)
updateUrl(state.booking, state.activeRoom)
})
)
},
@@ -293,7 +298,7 @@ export function createRatesStore({
}
state.booking.rooms[idx].packages = null
updateUrl(state.booking)
updateUrl(state.booking, state.activeRoom)
})
)
},
@@ -433,7 +438,7 @@ export function createRatesStore({
state.booking.rooms[idx].packages = null
}
updateUrl(state.booking)
updateUrl(state.booking, state.activeRoom)
})
)
},