import { create } from "./Create";
type State = {
  flow: any;
  currentFlowId: string;
};

type Actions = {
  setFlow: (flow: any) => void;
  setCurrentFlowId: (flowId: string) => void;
  reset: () => void;
};

// define the initial state
const initialState: State = {
  flow: {},
  currentFlowId: "",
};

// create store
const useCurrentFlow = create<State & Actions>()((set, get) => ({
  ...initialState,

  setFlow: (_flow: any) => {
    set({ flow: _flow });
  },

  setCurrentFlowId: (flowId: string) => {
    set({ currentFlowId: flowId });
  },

  reset: () => {
    set(initialState);
  },
}));

export { useCurrentFlow };
