import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { useQuery } from '@tanstack/react-query';
import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
import axios from 'axios';
import { B as BASE_URL, Q as QUERY_KEYS } from './constants-CXdiW8NZ.js';

var fetch = function fetch() {
  return axios.get("".concat(BASE_URL, "/api/v1/invite_links"));
};
var create = function create(payload) {
  return axios.post("".concat(BASE_URL, "/api/v1/invite_links"), {
    inviteLink: payload
  });
};
var regenerate = function regenerate(inviteLinkId, payload) {
  return axios.put("".concat(BASE_URL, "/api/v1/invite_links/").concat(inviteLinkId), {
    inviteLink: payload
  });
};
var inviteLinksApi = {
  fetch: fetch,
  create: create,
  regenerate: regenerate
};

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var useFetchInviteLinks = function useFetchInviteLinks() {
  return useQuery({
    queryKey: [QUERY_KEYS.INVITATION_LINK],
    queryFn: function queryFn() {
      return inviteLinksApi.fetch();
    }
  });
};
var useCreateInviteLinks = function useCreateInviteLinks() {
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  return useMutationWithInvalidation(function (payload) {
    return inviteLinksApi.create(payload);
  }, _objectSpread({
    keysToInvalidate: [[QUERY_KEYS.INVITATION_LINK]]
  }, options));
};
var useRegenerateInviteLink = function useRegenerateInviteLink() {
  return useMutationWithInvalidation(function (_ref) {
    var inviteLinkId = _ref.inviteLinkId,
      payload = _ref.payload;
    return inviteLinksApi.regenerate(inviteLinkId, payload);
  }, {
    keysToInvalidate: [[QUERY_KEYS.INVITATION_LINK]]
  });
};

export { useRegenerateInviteLink as a, useFetchInviteLinks as b, useCreateInviteLinks as u };
//# sourceMappingURL=useInviteLinksApi-gn-AP0Yx.js.map
