import { useMutation, UseMutationResult } from "@tanstack/react-query";
import recordAxiosInstance from "@/shared/services/recordAxiosInstance";

export interface SendBackPayload {
  recordId: string;
  action: string;
  comment: string;
}

const sendBackToInitiator = async (payload: SendBackPayload) => {
  const { data } = await recordAxiosInstance.post(
    "outgoing-instances/send-back-to-initiator",
    payload
  );
  return data;
};

export const useSendBackToInitiator = (): UseMutationResult<
  any,
  Error,
  SendBackPayload,
  unknown
> => {
  return useMutation({
    mutationFn: sendBackToInitiator,
  });
};
