import { useQuery } from '@tanstack/react-query';
import { api } from '@/api';

// Custom hook for fetching tracker data
export function useTracker(year, month) {
  return useQuery({
    queryKey: ['tracker', year, month],
    queryFn: () => api.tracker(year, month),
    staleTime: 1000 * 60 * 5, // 5 minutes
    cacheTime: 1000 * 60 * 30, // 30 minutes
  });
}

// Custom hook for fetching all bills
export function useBills() {
  return useQuery({
    queryKey: ['bills'],
    queryFn: () => api.allBills(),
    staleTime: 1000 * 60 * 5, // 5 minutes
    cacheTime: 1000 * 60 * 30, // 30 minutes
  });
}

// Custom hook for fetching categories
export function useCategories() {
  return useQuery({
    queryKey: ['categories'],
    queryFn: () => api.categories(),
    staleTime: 1000 * 60 * 60, // 1 hour
    cacheTime: 1000 * 60 * 60 * 2, // 2 hours
  });
}