import { create } from 'zustand';

interface VirtualSettings {
  enabled: boolean;
  virtualAccountCount: number;
  ruleDescription: string;
}

interface DisplaySettings {
  frontendDisplayCount: 10 | 20 | 50;
}

interface LeaderboardStore {
  activeBoard: 'daily' | 'weekly' | 'monthly';
  virtualSettings: VirtualSettings;
  displaySettings: DisplaySettings;
  setActiveBoard: (board: 'daily' | 'weekly' | 'monthly') => void;
  updateVirtualSettings: (settings: Partial<VirtualSettings>) => void;
  updateDisplaySettings: (settings: Partial<DisplaySettings>) => void;
}

export const useLeaderboardStore = create<LeaderboardStore>((set) => ({
  activeBoard: 'daily',
  virtualSettings: {
    enabled: false,
    virtualAccountCount: 0,
    ruleDescription: '',
  },
  displaySettings: {
    frontendDisplayCount: 10,
  },
  setActiveBoard: (board) => set({ activeBoard: board }),
  updateVirtualSettings: (settings) =>
    set((state) => ({
      virtualSettings: { ...state.virtualSettings, ...settings },
    })),
  updateDisplaySettings: (settings) =>
    set((state) => ({
      displaySettings: { ...state.displaySettings, ...settings },
    })),
}));
