import { create } from "zustand";

export enum EVENT_TYPES {
    SAVE = "save",
    ADD = "add",
    CLEAR = "clear",
    FILTER = "filter",
    SLEEP = "sleep",
    NEED_SAVE = "need-save",
    NEED_ADD = "need-add",
    LOADING = "loading",
}

interface IEventHandlerStore {
    eventType: EVENT_TYPES;
    setEventType: (state: EVENT_TYPES) => void;
    clear: () => void;
}

export type EventHandlerState = IEventHandlerStore;

const useEventHandlerStore = create<EventHandlerState>()((set) => ({
    eventType: EVENT_TYPES.SLEEP,
    setEventType: (state: EVENT_TYPES) => set(() => ({ eventType: state })),
    clear: () =>
        set(() => ({
            eventType: EVENT_TYPES.SLEEP,
        })),
}));

export { useEventHandlerStore };
