import { create } from 'zustand'
import type { ReminderType, ReminderStatus, ReminderPriority } from '../domain/reminder'

export type FilterHorizon = 'ALL' | 'OVERDUE' | 'THIS_WEEK' | 'THIS_MONTH' | 'LATER'

interface ReminderStore {
  selectedId: string | null
  setSelectedId: (id: string | null) => void
  drawerOpen: boolean
  setDrawerOpen: (open: boolean) => void
  filterType: ReminderType | 'ALL'
  setFilterType: (t: ReminderType | 'ALL') => void
  filterStatus: ReminderStatus | 'ALL' | 'ACTIVE'
  setFilterStatus: (s: ReminderStatus | 'ALL' | 'ACTIVE') => void
  filterPriority: ReminderPriority | 'ALL'
  setFilterPriority: (p: ReminderPriority | 'ALL') => void
  filterHorizon: FilterHorizon
  setFilterHorizon: (h: FilterHorizon) => void
  searchQuery: string
  setSearchQuery: (q: string) => void
  viewMode: 'list' | 'card'
  setViewMode: (m: 'list' | 'card') => void
}

export const useReminderStore = create<ReminderStore>((set) => ({
  selectedId: null,
  setSelectedId: (id) => set({ selectedId: id }),
  drawerOpen: false,
  setDrawerOpen: (open) => set({ drawerOpen: open }),
  filterType: 'ALL',
  setFilterType: (t) => set({ filterType: t }),
  filterStatus: 'ACTIVE',
  setFilterStatus: (s) => set({ filterStatus: s }),
  filterPriority: 'ALL',
  setFilterPriority: (p) => set({ filterPriority: p }),
  filterHorizon: 'ALL',
  setFilterHorizon: (h) => set({ filterHorizon: h }),
  searchQuery: '',
  setSearchQuery: (q) => set({ searchQuery: q }),
  viewMode: 'list',
  setViewMode: (m) => set({ viewMode: m }),
}))
