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