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((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", }), }, }))