import { DashboardFilterSlice } from '@/types/stores';
import { StateCreator } from 'zustand';

export const createDashboardFilterSlice: StateCreator<
  DashboardFilterSlice,
  [],
  [],
  DashboardFilterSlice
> = (set) => ({
  // Initial state
  filterValues: {
    startDate: '',
    endDate: '',
    analysisMode: 'OVERVIEW',
    comparisonType: undefined,
    location: [],
    locationIds: undefined,
    flock: undefined,
    flockIds: undefined,
    kandang: undefined,
    kandangIds: undefined,
  },

  // Actions
  setFilterValues: (values) => set({ filterValues: values }),

  resetFilterValues: () => {
    return set({
      filterValues: {
        startDate: '',
        endDate: '',
        analysisMode: 'OVERVIEW',
        comparisonType: undefined,
        location: [],
        locationIds: undefined,
        flock: undefined,
        flockIds: undefined,
        kandang: undefined,
        kandangIds: undefined,
      },
    });
  },
});
