import { TDataSourceError } from "@/lib/hooks/useDataSource/types";
import { useDataSource } from "@/lib/hooks/useDataSource/useDataSource";
import { ISendIncidence_Request_DTO } from "@shared/contexts";
import { useMutation, UseMutationOptions } from "@tanstack/react-query";

export type UseSupportGetParamsType = {
  mutateOptions?: UseMutationOptions<void, TDataSourceError, ISendIncidence_Request_DTO>;
};

export const useSupport = () => {
  const dataSource = useDataSource();

  return {
    useSubmitIncidence: (params?: UseSupportGetParamsType) => {
      const { mutateOptions = {} } = params || {};

      return useMutation<void, TDataSourceError, ISendIncidence_Request_DTO>({
        mutationFn: (data) => {
          return dataSource.createOne({
            resource: "support",
            data,
          });
        },
        ...mutateOptions,
      });
    },
  };
};
