import { create } from 'zustand';
import type { Page, UserType } from '@/types';

interface AppState {
  currentPage: Page;
  searchQuery: string;
  selectedReportId: string | null;
  user: UserType | null;
  isLoading: boolean;

  navigate: (page: Page) => void;
  setSearchQuery: (query: string) => void;
  setSelectedReportId: (id: string | null) => void;
  setUser: (user: UserType | null) => void;
  setIsLoading: (loading: boolean) => void;
}

export const useAppStore = create<AppState>((set) => ({
  currentPage: 'home',
  searchQuery: '',
  selectedReportId: null,
  user: null,
  isLoading: false,

  navigate: (page) => set({ currentPage: page }),
  setSearchQuery: (query) => set({ searchQuery: query }),
  setSelectedReportId: (id) => set({ selectedReportId: id }),
  setUser: (user) => set({ user }),
  setIsLoading: (loading) => set({ isLoading: loading }),
}));
