Merge branch 'master' of bitbucket.org:scandic-swap/web into fix/loading-rooms-separately

This commit is contained in:
Joakim Jäderberg
2024-11-20 14:33:05 +01:00
108 changed files with 1115 additions and 683 deletions
-1
View File
@@ -94,7 +94,6 @@ export function createDetailsStore(
state.data.membershipNo = data.membershipNo
}
state.data.phoneNumber = data.phoneNumber
state.data.termsAccepted = data.termsAccepted
state.data.zipCode = data.zipCode
})
)
+7 -10
View File
@@ -1,6 +1,7 @@
"use client"
import merge from "deepmerge"
import { produce } from "immer"
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime"
import { useContext } from "react"
import { create, useStore } from "zustand"
@@ -18,17 +19,13 @@ import { StepEnum } from "@/types/enums/step"
import type { DetailsState } from "@/types/stores/details"
import type { StepState } from "@/types/stores/steps"
function push(data: Record<string, string>, url: string) {
if (typeof window !== "undefined") {
window.history.pushState(data, "", url + window.location.search)
}
}
export function createStepsStore(
currentStep: StepEnum,
isMember: boolean,
noBedChoices: boolean,
noBreakfast: boolean
noBreakfast: boolean,
searchParams: string,
push: AppRouterInstance["push"]
) {
const isBrowser = typeof window !== "undefined"
const steps = [
@@ -51,14 +48,14 @@ export function createStepsStore(
steps.splice(1, 1)
if (currentStep === StepEnum.breakfast) {
currentStep = steps[1]
push({ step: currentStep }, currentStep)
push(`${currentStep}?${searchParams}`)
}
}
if (noBedChoices) {
if (currentStep === StepEnum.selectBed) {
currentStep = steps[1]
push({ step: currentStep }, currentStep)
push(`${currentStep}?${searchParams}`)
}
}
@@ -94,7 +91,7 @@ export function createStepsStore(
if (!validPaths.includes(currentStep) && isBrowser) {
// We will always have at least one valid path
currentStep = validPaths.pop()!
push({ step: currentStep }, currentStep)
push(`${currentStep}?${searchParams}`)
}
}