import api from 'src/config/api';
import {
  type Event,
  EventsType,
  type TaskEventsViews,
} from 'src/pages/dashboard/serviceManagement/types';
import { type Pagination } from 'src/types/services';

export const getComments = (taskId: string, cursor: string, limit = 10) =>
  api.get<Pagination<Event>>(`workflows/tasks/${taskId}/events`, {
    params: {
      typesIn: EventsType.COMMENT,
      cursor,
      limit,
    },
  });

export const getActivities = (
  taskId: string,
  cursor: string,
  views: TaskEventsViews[],
  limit = 10,
  children = true,
) =>
  api.get<Pagination<Event>>(`workflows/tasks/${taskId}/events`, {
    params: {
      views: views.join(','),
      cursor,
      limit,
      includeEventsOfChildren: children,
    },
  });
