import { create } from 'zustand';
import { storage } from '../lib/storage';

type Theme = 'dark' | 'light' | 'system';

interface UIStore {
  theme: Theme;
  selectedDate: Date;
  setTheme: (theme: Theme) => void;
  setSelectedDate: (date: Date) => void;
}

export const useUIStore = create<UIStore>((set) => ({
  theme: (storage.getString('theme') as Theme) || 'system',
  selectedDate: new Date(),

  setTheme: (theme) => {
    storage.set('theme', theme);
    set({ theme });
  },

  setSelectedDate: (date) => set({ selectedDate: date }),
}));
