@bigbinary/neeto-webhooks-frontend 1.6.30 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10,8 +10,8 @@ import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
10
10
  import NoData from '@bigbinary/neetoui/NoData';
11
11
  import Table from '@bigbinary/neetoui/Table';
12
12
  import { useTranslation } from 'react-i18next';
13
- import { QueryClient, QueryCache, QueryClientProvider, useQuery, useQueryClient, useMutation } from 'react-query';
14
- import { ReactQueryDevtools } from 'react-query/devtools';
13
+ import { QueryClient, QueryCache, QueryClientProvider, useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
14
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
15
15
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
16
16
  import axios from 'axios';
17
17
  import DateFormat from '@bigbinary/neeto-molecules/DateFormat';
@@ -23,6 +23,7 @@ import Tag from '@bigbinary/neetoui/Tag';
23
23
  import { t as t$1 } from 'i18next';
24
24
  import { prop, pluck, assoc } from 'ramda';
25
25
  import Alert from '@bigbinary/neetoui/Alert';
26
+ import { useMutationWithInvalidation, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
26
27
  import Plus from '@bigbinary/neeto-icons/Plus';
27
28
  import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
28
29
  import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
@@ -34,7 +35,6 @@ import Select from '@bigbinary/neetoui/formik/Select';
34
35
  import Switch from '@bigbinary/neetoui/formik/Switch';
35
36
  import Textarea from '@bigbinary/neetoui/formik/Textarea';
36
37
  import * as yup from 'yup';
37
- import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
38
38
 
39
39
  var getDeliveriesPath = function getDeliveriesPath(webhooksPath) {
40
40
  return "".concat(webhooksPath, "/:webhookId/deliveries");
@@ -172,7 +172,7 @@ var withReactQuery = function withReactQuery(Component) {
172
172
  client: queryClient,
173
173
  children: [/*#__PURE__*/jsx(Component, _objectSpread$2({}, props)), /*#__PURE__*/jsx(ReactQueryDevtools, {
174
174
  initialIsOpen: false,
175
- position: "bottom-right"
175
+ position: "bottom"
176
176
  })]
177
177
  });
178
178
  };
@@ -209,28 +209,35 @@ var WEBHOOK_STALE_TIME = 3200000; // 1 hour
209
209
  var POST_REDELIVERY_ON_SUCCESS_TIMEOUT = 5000; // 5 seconds
210
210
 
211
211
  var useFetchDeliveries = function useFetchDeliveries(webhookId, params) {
212
- return useQuery([QUERY_KEYS.DELIVERY_LIST, webhookId, params], function () {
213
- return deliveriesApi.fetch(webhookId, params);
214
- }, {
212
+ return useQuery({
213
+ queryKey: [QUERY_KEYS.DELIVERY_LIST, webhookId, params],
214
+ queryFn: function queryFn() {
215
+ return deliveriesApi.fetch(webhookId, params);
216
+ },
215
217
  staleTime: DELIVERY_STALE_TIME
216
218
  });
217
219
  };
218
220
  var useShowDelivery = function useShowDelivery(id, webhookId) {
219
- return useQuery([QUERY_KEYS.DELIVERY_DETAILS, id, webhookId], function () {
220
- return deliveriesApi.show(id, webhookId);
221
- }, {
221
+ return useQuery({
222
+ queryKey: [QUERY_KEYS.DELIVERY_DETAILS, id, webhookId],
223
+ queryFn: function queryFn() {
224
+ return deliveriesApi.show(id, webhookId);
225
+ },
222
226
  staleTime: DELIVERY_STALE_TIME,
223
227
  enabled: !!id
224
228
  });
225
229
  };
226
230
  var useRedeliverWebhook = function useRedeliverWebhook(deliveryId, webhookSid) {
227
231
  var queryClient = useQueryClient();
228
- return useMutation(function () {
229
- return deliveriesApi.redeliver(deliveryId, webhookSid);
230
- }, {
232
+ return useMutation({
233
+ mutationFn: function mutationFn() {
234
+ return deliveriesApi.redeliver(deliveryId, webhookSid);
235
+ },
231
236
  onSuccess: function onSuccess() {
232
237
  setTimeout(function () {
233
- return queryClient.invalidateQueries(QUERY_KEYS.DELIVERY_LIST);
238
+ return queryClient.invalidateQueries({
239
+ queryKey: [QUERY_KEYS.DELIVERY_LIST]
240
+ });
234
241
  }, POST_REDELIVERY_ON_SUCCESS_TIMEOUT);
235
242
  }
236
243
  });
@@ -755,7 +762,7 @@ var Details = function Details(_ref) {
755
762
  var _useTranslation = useTranslation(),
756
763
  t = _useTranslation.t;
757
764
  var _useRedeliverWebhook = useRedeliverWebhook(deliveryId, webhookSid),
758
- isRedelivering = _useRedeliverWebhook.isLoading,
765
+ isRedelivering = _useRedeliverWebhook.isPending,
759
766
  redeliverWebhook = _useRedeliverWebhook.mutateAsync;
760
767
  var _useShowDelivery = useShowDelivery(deliveryId, webhookSid),
761
768
  isLoading = _useShowDelivery.isLoading,
@@ -1011,52 +1018,51 @@ var webhooksApi = {
1011
1018
  };
1012
1019
 
1013
1020
  var useFetchWebhooks = function useFetchWebhooks(params) {
1014
- return useQuery([QUERY_KEYS.WEBHOOK_LIST, params], function () {
1015
- return webhooksApi.fetch(params);
1016
- }, {
1021
+ return useQuery({
1022
+ queryKey: [QUERY_KEYS.WEBHOOK_LIST, params],
1023
+ queryFn: function queryFn() {
1024
+ return webhooksApi.fetch(params);
1025
+ },
1017
1026
  staleTime: WEBHOOK_STALE_TIME
1018
1027
  });
1019
1028
  };
1020
1029
  var useCreateWebhook = function useCreateWebhook(options) {
1021
- var queryClient = useQueryClient();
1022
- return useMutation(webhooksApi.create, {
1030
+ return useMutationWithInvalidation(webhooksApi.create, {
1031
+ keysToInvalidate: [[QUERY_KEYS.WEBHOOK_LIST]],
1023
1032
  onSuccess: function onSuccess() {
1024
1033
  var _options$onSuccess;
1025
- queryClient.invalidateQueries(QUERY_KEYS.WEBHOOK_LIST);
1026
1034
  options === null || options === void 0 || (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 || _options$onSuccess.call(options);
1027
1035
  }
1028
1036
  });
1029
1037
  };
1030
1038
  var useShowWebhook = function useShowWebhook(id) {
1031
- return useQuery([QUERY_KEYS.WEBHOOK_DETAILS, id], function () {
1032
- return webhooksApi.show(id);
1033
- }, {
1039
+ return useQuery({
1040
+ queryKey: [QUERY_KEYS.WEBHOOK_DETAILS, id],
1041
+ queryFn: function queryFn() {
1042
+ return webhooksApi.show(id);
1043
+ },
1034
1044
  enabled: !!id,
1035
1045
  staleTime: WEBHOOK_STALE_TIME
1036
1046
  });
1037
1047
  };
1038
1048
  var useUpdateWebhook = function useUpdateWebhook(id, options) {
1039
- var queryClient = useQueryClient();
1040
- return useMutation(function (_ref) {
1049
+ return useMutationWithInvalidation(function (_ref) {
1041
1050
  var id = _ref.id,
1042
1051
  payload = _ref.payload;
1043
1052
  return webhooksApi.update(id, payload);
1044
1053
  }, {
1054
+ keysToInvalidate: [[QUERY_KEYS.WEBHOOK_LIST], [QUERY_KEYS.WEBHOOK_DETAILS, id], [QUERY_KEYS.DELIVERY_LIST, id]],
1045
1055
  onSuccess: function onSuccess() {
1046
1056
  var _options$onSuccess2;
1047
- queryClient.invalidateQueries(QUERY_KEYS.WEBHOOK_LIST);
1048
- queryClient.invalidateQueries([QUERY_KEYS.WEBHOOK_DETAILS, id]);
1049
- queryClient.invalidateQueries([QUERY_KEYS.DELIVERY_LIST, id]);
1050
1057
  options === null || options === void 0 || (_options$onSuccess2 = options.onSuccess) === null || _options$onSuccess2 === void 0 || _options$onSuccess2.call(options);
1051
1058
  }
1052
1059
  });
1053
1060
  };
1054
1061
  var useDestroyWebhook = function useDestroyWebhook(options) {
1055
- var queryClient = useQueryClient();
1056
- return useMutation(webhooksApi.destroy, {
1062
+ return useMutationWithInvalidation(webhooksApi.destroy, {
1063
+ keysToInvalidate: [[QUERY_KEYS.WEBHOOK_LIST]],
1057
1064
  onSuccess: function onSuccess() {
1058
1065
  var _options$onSuccess3;
1059
- queryClient.invalidateQueries(QUERY_KEYS.WEBHOOK_LIST);
1060
1066
  options === null || options === void 0 || (_options$onSuccess3 = options.onSuccess) === null || _options$onSuccess3 === void 0 || _options$onSuccess3.call(options);
1061
1067
  }
1062
1068
  });
@@ -1074,7 +1080,9 @@ var eventsApi = {
1074
1080
  };
1075
1081
 
1076
1082
  var useFetchEvents = function useFetchEvents() {
1077
- return useQuery([QUERY_KEYS.EVENTS_LIST], eventsApi.all, {
1083
+ return useQuery({
1084
+ queryKey: [QUERY_KEYS.EVENTS_LIST],
1085
+ queryFn: eventsApi.all,
1078
1086
  staleTime: WEBHOOK_STALE_TIME
1079
1087
  });
1080
1088
  };
@@ -1538,7 +1546,7 @@ var Webhooks = function Webhooks(_ref) {
1538
1546
  onDelete === null || onDelete === void 0 || onDelete();
1539
1547
  }
1540
1548
  }),
1541
- isDeleting = _useDestroyWebhook.isLoading,
1549
+ isDeleting = _useDestroyWebhook.isPending,
1542
1550
  destroyWebhook = _useDestroyWebhook.mutate;
1543
1551
  var handlePaneClose = function handlePaneClose() {
1544
1552
  setEditingWebhookId(null);