import { useQuery } from '@tanstack/react-query';
import { fetchSprintTickets } from '@/features/projects/services/projectService';

export const sprintTicketsQueryKey = (projectId: string, sprintId: string) =>
  ['projects', projectId, 'sprints', sprintId, 'tickets'] as const;

export function useSprintTickets(projectId: string | undefined, sprintId: string | undefined) {
  return useQuery({
    queryKey: sprintTicketsQueryKey(projectId ?? '', sprintId ?? ''),
    queryFn: () => fetchSprintTickets(projectId!, sprintId!),
    enabled: Boolean(projectId && sprintId),
  });
}
