import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import type { ViewMode } from './config';

interface IssueViewState {
  viewMode: ViewMode;
  search: string;
  setSearch: (s: string) => void;
  setViewMode: (m: ViewMode) => void;
}

export const useIssueViewStore = create<IssueViewState>()(
  persist(
    (set) => ({
      viewMode: 'board',
      search: '',
      setSearch: (search) => set({ search }),
      setViewMode: (viewMode) => set({ viewMode }),
    }),
    {
      name: 'issue-view-prefs',
    },
  ),
);
