import api from 'src/config/api';
import {
  ServiceItemTypes,
  type State,
  type StateTransition,
  type Task,
} from 'src/pages/dashboard/serviceManagement/types';

export const getStates = (
  taskType: ServiceItemTypes = ServiceItemTypes.INCIDENT,
) =>
  api.get<State[]>('workflows/states', {
    params: {
      taskType,
    },
  });

export const getTransitionsStates = (stateId: string) =>
  api.get<StateTransition[]>(`workflows/states/${stateId}/transitions`);

export const updateState = (taskId: string, body: unknown) =>
  api.patch<Task>(`workflows/tasks/${taskId}/state`, body);
