import { create } from "zustand";
import { immer } from "zustand/middleware/immer";
import { persist } from "zustand/middleware";

const INITIAL = {
  region: null,
};

const store = (set) => ({
  filters: INITIAL,

  setRegion: (value) =>
    set((state) => {
      state.filters.region = value;
    }),

  clear: () =>
    set((state) => {
      state.filters = INITIAL;
    }),
});

export const useOnApprovalPointsFilters = create(
  persist(immer(store), { name: "postnet/on-approval-filters" })
);
