Merged in feat/SW-1077-enter-details-edit-room (pull request #1360)
Feat/SW-1077 enter details edit room * feat(SW-1077): persist state when changing rooms * fix: issue with step state when closing accordion and transition to correct room when modifying step Approved-by: Pontus Dreij
This commit is contained in:
@@ -78,16 +78,14 @@ export default function SectionAccordion({
|
||||
|
||||
function close() {
|
||||
setIsOpen(false)
|
||||
const isLastStep = step === StepEnum.details
|
||||
const hasNextRoom = roomIndex + 1 <= roomStatuses.length
|
||||
|
||||
if (!isLastStep) {
|
||||
const nextStep = selectNextStep(roomStatus)
|
||||
if (nextStep) {
|
||||
setStep(nextStep, roomIndex)
|
||||
}
|
||||
} else if (isLastStep && hasNextRoom) {
|
||||
setStep(StepEnum.selectBed, roomIndex + 1)
|
||||
const nextRoom = roomStatuses.find((room) => !room.isComplete)
|
||||
const nextStep = nextRoom
|
||||
? Object.values(nextRoom.steps).find((step) => !step.isValid)?.step
|
||||
: null
|
||||
|
||||
if (nextRoom !== undefined && nextStep !== undefined) {
|
||||
setStep(nextStep, roomStatuses.indexOf(nextRoom))
|
||||
} else {
|
||||
// Time for payment, collapse any open step
|
||||
setStep(null)
|
||||
|
||||
Reference in New Issue
Block a user