Feat(SW-1274) modify date my stay * feat(SW-1676): Modify guest details step 1 * feat(SW-1676) Integration to api to update guest details * feat(SW-1676) Reuse of old modal * feat(SW-1676) updated modify guest * feat(SW-1676) cleanup * feat(SW-1274) modify stay modal and datepicker * feat(SW-1274) DatePicker from modify dates * feat(SW-1274) Modify dates fixes and merge conflicts * feat(SW-1274) handle modify for multiroom * feat(SW-1274) update manage stay * feat(SW-1274) fixed some comments * feat(SW-1274) use Modal instead * feat(SW-1274) fixed formatChildBedPreferences * feat(SW-1274) removed any as prop * feat(SW-1274) fix rebase conflicts * feat(SW-1274) fix flicker on modify modal * feat(SW-1274) CalendarButton * feat(SW-1274) fixed gap variable * feat(SW-1274) simplified code * feat(SW-1274) Split up DatePicker on mode * feat(SW-1274) Updated file structure for datepicker Approved-by: Arvid Norlin
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { create } from "zustand"
|
|
|
|
type ActiveView =
|
|
| "actionPanel"
|
|
| "cancelStay"
|
|
| "modifyStay"
|
|
| "guaranteeLateArrival"
|
|
|
|
interface ManageStayState {
|
|
isOpen: boolean
|
|
activeView: ActiveView
|
|
currentStep: number
|
|
isLoading: boolean
|
|
actions: {
|
|
setIsOpen: (isOpen: boolean) => void
|
|
setActiveView: (view: ActiveView) => void
|
|
setCurrentStep: (step: number) => void
|
|
setIsLoading: (isLoading: boolean) => void
|
|
handleForward: () => void
|
|
handleCloseView: () => void
|
|
handleCloseModal: () => void
|
|
}
|
|
}
|
|
|
|
export const useManageStayStore = create<ManageStayState>((set) => ({
|
|
isOpen: false,
|
|
activeView: "actionPanel",
|
|
currentStep: 1,
|
|
isLoading: false,
|
|
actions: {
|
|
setIsOpen: (isOpen) => set({ isOpen }),
|
|
setActiveView: (activeView) => set({ activeView }),
|
|
setCurrentStep: (currentStep) => set({ currentStep }),
|
|
setIsLoading: (isLoading) => set({ isLoading }),
|
|
handleForward: () =>
|
|
set((state) => ({ currentStep: state.currentStep + 1 })),
|
|
handleCloseView: () =>
|
|
set({
|
|
currentStep: 1,
|
|
isLoading: false,
|
|
activeView: "actionPanel",
|
|
}),
|
|
handleCloseModal: () =>
|
|
set({
|
|
currentStep: 1,
|
|
isOpen: false,
|
|
activeView: "actionPanel",
|
|
}),
|
|
},
|
|
}))
|