"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useCreateHypothesisMutation = void 0;

var _reactQuery = require("react-query");

var _hypothesis = require("../../api/services/hypothesis");

var _useIncidentQuery = require("../query-hooks/useIncidentQuery");

var useCreateHypothesisMutation = function useCreateHypothesisMutation() {
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var _options$incidentId = options.incidentId,
      incidentId = _options$incidentId === void 0 ? "incorrect_incident_id" : _options$incidentId;
  var queryClient = (0, _reactQuery.useQueryClient)();
  return (0, _reactQuery.useMutation)(function (_ref) {
    var user = _ref.user,
        id = _ref.id,
        incidentId = _ref.incidentId,
        params = _ref.params;
    return (0, _hypothesis.createHypothesis)(user, id, incidentId, params);
  }, {
    onSettled: function onSettled() {
      queryClient.invalidateQueries((0, _useIncidentQuery.createIncidentQueryKey)(incidentId));
    }
  });
};

exports.useCreateHypothesisMutation = useCreateHypothesisMutation;