Merged in fix/handle-bed-reselect-navigation (pull request #1321)
fix: adjust allowed step navigation condition * fix: adjust allowed step navigation condition Approved-by: Tobias Johansson
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
getRoomPrice,
|
||||
getTotalPrice,
|
||||
handleStepProgression,
|
||||
selectPreviousSteps,
|
||||
selectRoom,
|
||||
selectRoomStatus,
|
||||
writeToSessionStorage,
|
||||
@@ -24,6 +25,7 @@ import type {
|
||||
InitialState,
|
||||
RoomState,
|
||||
RoomStatus,
|
||||
RoomStep,
|
||||
} from "@/types/stores/enter-details"
|
||||
import type { SafeUser } from "@/types/user"
|
||||
|
||||
@@ -138,7 +140,7 @@ export function createDetailsStore(
|
||||
|
||||
actions: {
|
||||
setStep(step: StepEnum | null, roomIndex?: number) {
|
||||
if (!step) {
|
||||
if (step === null) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -146,15 +148,16 @@ export function createDetailsStore(
|
||||
produce((state: DetailsState) => {
|
||||
const currentRoomIndex =
|
||||
roomIndex ?? state.bookingProgress.currentRoomIndex
|
||||
|
||||
const previousSteps = selectPreviousSteps(state, roomIndex)
|
||||
const arePreviousStepsCompleted = Object.values(
|
||||
previousSteps
|
||||
).every((step: RoomStep) => step.isValid)
|
||||
const arePreviousRoomsCompleted = state.bookingProgress.roomStatuses
|
||||
.slice(0, currentRoomIndex)
|
||||
.every((room) => room.isComplete)
|
||||
|
||||
const roomStatus = selectRoomStatus(state, roomIndex)
|
||||
const roomStep = roomStatus.steps[step]
|
||||
|
||||
if (arePreviousRoomsCompleted && roomStep?.isValid) {
|
||||
if (arePreviousRoomsCompleted && arePreviousStepsCompleted) {
|
||||
roomStatus.currentStep = step
|
||||
|
||||
if (roomIndex !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user