import { persist, createJSONStorage } from "zustand/middleware";
import { create } from "zustand";

export type ButtonPanelMode = "icon" | "button";

export interface ILoginActionStore {
    mode: ButtonPanelMode;
    setMode: (mod: ButtonPanelMode) => void;
    clear: () => void;
}

const useButtonPanelStore = create<ILoginActionStore>()(
    persist(
        (set) => ({
            mode: "button",
            setMode: (mod: ButtonPanelMode) => set(() => ({ mode: mod })),
            clear: () => set(() => ({ mode: "button" })),
        }),
        {
            name: "site-panel-mode",
            storage: createJSONStorage(() => localStorage),
        }
    )
);

export { useButtonPanelStore };
