/**
 * Dummy Data Toggle Hook
 * 
 * Provides a global toggle for using dummy data vs real API data
 * Useful for development and showcasing charts when store has no data
 */

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

interface DummyDataStore {
  useDummyData: boolean;
  toggleDummyData: () => void;
  setDummyData: (value: boolean) => void;
}

export const useDummyDataStore = create<DummyDataStore>()(
  persist(
    (set) => ({
      useDummyData: false,
      toggleDummyData: () => set((state) => ({ useDummyData: !state.useDummyData })),
      setDummyData: (value: boolean) => set({ useDummyData: value }),
    }),
    {
      name: 'woonoow-dummy-data',
    }
  )
);

/**
 * Hook to check if dummy data should be used
 */
export function useDummyData() {
  const { useDummyData } = useDummyDataStore();
  return useDummyData;
}

/**
 * Hook to toggle dummy data
 */
export function useDummyDataToggle() {
  const { useDummyData, toggleDummyData, setDummyData } = useDummyDataStore();
  return { useDummyData, toggleDummyData, setDummyData };
}
