"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useFindCaseUserActions = void 0;
var _reactQuery = require("@tanstack/react-query");
var _api = require("./api");
var _use_cases_toast = require("../common/use_cases_toast");
var _translations = require("./translations");
var _constants = require("./constants");
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

const useFindCaseUserActions = (caseId, params, isEnabled) => {
  const {
    showErrorToast
  } = (0, _use_cases_toast.useCasesToast)();
  return (0, _reactQuery.useQuery)(_constants.casesQueriesKeys.caseUserActions(caseId, params), async ({
    signal
  }) => (0, _api.findCaseUserActions)(caseId, params, signal), {
    enabled: isEnabled,
    onError: error => {
      showErrorToast(error, {
        title: _translations.ERROR_TITLE
      });
    }
  });
};
exports.useFindCaseUserActions = useFindCaseUserActions;