import { create } from "zustand"

interface HotelFilterState {
  activeFilters: string[]
  toggleFilter: (filterId: string) => void
  setFilters: (filters: string[]) => void
  resultCount: number
  setResultCount: (count: number) => void
}

export const useHotelFilterStore = create<HotelFilterState>((set) => ({
  activeFilters: [],

  setFilters: (filters) => set({ activeFilters: filters }),

  toggleFilter: (filterId: string) =>
    set((state) => {
      const isActive = state.activeFilters.includes(filterId)
      const newFilters = isActive
        ? state.activeFilters.filter((id) => id !== filterId)
        : [...state.activeFilters, filterId]
      return { activeFilters: newFilters }
    }),
  resultCount: 0,
  setResultCount: (count) => set({ resultCount: count }),
}))
