import { create } from 'zustand';

interface UserFilters {
  keyword: string;
  province: string;
  city: string;
  status: string;
  rankRange: [number, number] | null;
  adoptionRange: [number, number] | null;
}

interface UserFiltersStore {
  filters: UserFilters;
  setKeyword: (keyword: string) => void;
  setFilters: (filters: Partial<UserFilters>) => void;
  resetFilters: () => void;
}

const initialFilters: UserFilters = {
  keyword: '',
  province: '',
  city: '',
  status: '',
  rankRange: null,
  adoptionRange: null,
};

export const useUserFiltersStore = create<UserFiltersStore>((set) => ({
  filters: initialFilters,
  setKeyword: (keyword) =>
    set((state) => ({
      filters: { ...state.filters, keyword },
    })),
  setFilters: (newFilters) =>
    set((state) => ({
      filters: { ...state.filters, ...newFilters },
    })),
  resetFilters: () => set({ filters: initialFilters }),
}));
