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

interface Tab {
  id: string;
  title: string;
  component: React.ComponentType;
  path: string;
  icon?: React.ComponentType<{ className?: string }>;
  clearTabs?: () => void;
}

interface TabStore {
  dashboarTabs: Tab[];
  activeTabId: string | null;
  setDashboardTabs: (dashboarTabs: Tab[]) => void;
  setActiveTabId: (id: string | null) => void;
  clearTabs: () => void;
}

export const useDashboardTabStore = create<TabStore>()(
  persist(
    (set) => ({
      dashboarTabs: [],
      activeTabId: null,
      setDashboardTabs: (dashboarTabs) => set({ dashboarTabs }),
      setActiveTabId: (id) => set({ activeTabId: id }),
      clearTabs: () => set({ dashboarTabs: [], activeTabId: null }),
    }),
    {
      name: "dashboard-tabs-storage",
    }
  )
);


