import { useQuery } from '@tanstack/react-query';
import { apiClient } from '../lib/apiClient';
import type { Task } from '../types';

interface TasksParams {
  quarter?: string;
  section?: string;
  taskType?: string;
}

export function useTasks(params?: TasksParams) {
  return useQuery({
    queryKey: ['tasks', params],
    queryFn: async () => {
      const { data } = await apiClient.get<Task[]>('/tasks', { params });
      return data;
    },
    refetchInterval: 30_000,
  });
}
