@bigbinary/neeto-rules-frontend 1.2.0-beta1 → 1.2.0-beta3

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
@@ -4,7 +4,7 @@ import { isNotEmpty, isPresent, renameKeys, findBy, noop as noop$4, nullSafe, to
4
4
  import { DEFAULT_PAGE_SIZE } from '@bigbinary/neeto-commons-frontend/constants';
5
5
  import { useMutationWithInvalidation, useQueryParams, withImmutableActions, withT, useStateWithDependency, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
6
6
  import Container from '@bigbinary/neeto-molecules/Container';
7
- import { useQuery } from 'react-query';
7
+ import { useQuery, keepPreviousData } from '@tanstack/react-query';
8
8
  import axios from 'axios';
9
9
  import NeetoHeader from '@bigbinary/neeto-molecules/Header';
10
10
  import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
@@ -222,34 +222,36 @@ function ownKeys$v(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
222
222
  function _objectSpread$t(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$v(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$v(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
223
223
  var useFetchAutomationRules = function useFetchAutomationRules(params) {
224
224
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
225
- return useQuery([AUTOMATION_RULES, params], function () {
226
- return automationRulesApi.fetch(params);
227
- }, _objectSpread$t({
225
+ return useQuery(_objectSpread$t({
226
+ queryKey: [AUTOMATION_RULES, params],
227
+ queryFn: function queryFn() {
228
+ return automationRulesApi.fetch(params);
229
+ },
228
230
  staleTime: STALE_TIME,
229
231
  select: function select(response) {
230
232
  return response.data || response;
231
233
  },
232
- keepPreviousData: true
234
+ placeholderData: keepPreviousData
233
235
  }, options));
234
236
  };
235
237
  var useUpdateAutomationRule = function useUpdateAutomationRule() {
236
238
  return useMutationWithInvalidation(automationRulesApi.update, {
237
- keysToInvalidate: [AUTOMATION_RULES]
239
+ keysToInvalidate: [[AUTOMATION_RULES]]
238
240
  });
239
241
  };
240
242
  var useCloneAutomationRule = function useCloneAutomationRule() {
241
243
  return useMutationWithInvalidation(automationRulesApi.clone, {
242
- keysToInvalidate: [AUTOMATION_RULES]
244
+ keysToInvalidate: [[AUTOMATION_RULES]]
243
245
  });
244
246
  };
245
247
  var useDeleteAutomationRule = function useDeleteAutomationRule() {
246
248
  return useMutationWithInvalidation(automationRulesApi.destroy, {
247
- keysToInvalidate: [AUTOMATION_RULES]
249
+ keysToInvalidate: [[AUTOMATION_RULES]]
248
250
  });
249
251
  };
250
252
  var useReorderAutomationRules = function useReorderAutomationRules() {
251
253
  return useMutationWithInvalidation(automationRulesApi.reorder, {
252
- keysToInvalidate: [AUTOMATION_RULES]
254
+ keysToInvalidate: [[AUTOMATION_RULES]]
253
255
  });
254
256
  };
255
257
 
@@ -9438,7 +9440,7 @@ var RulesReorder = function RulesReorder(_ref) {
9438
9440
  t = _useTranslation.t;
9439
9441
  var _useReorderAutomation = useReorderAutomationRules(),
9440
9442
  reOrder = _useReorderAutomation.mutate,
9441
- isLoading = _useReorderAutomation.isLoading;
9443
+ isPending = _useReorderAutomation.isPending;
9442
9444
  var handleReorderSave = function handleReorderSave(rules) {
9443
9445
  var params = [];
9444
9446
  rules.forEach(function (rule, index) {
@@ -9532,9 +9534,9 @@ var RulesReorder = function RulesReorder(_ref) {
9532
9534
  }), /*#__PURE__*/jsxs(Pane.Footer, {
9533
9535
  className: "flex items-center gap-x-2",
9534
9536
  children: [/*#__PURE__*/jsx$1(Button, {
9535
- disabled: isLoading || equals(rules, initialRules),
9537
+ disabled: isPending || equals(rules, initialRules),
9536
9538
  label: t("neetoRules.common.saveChange"),
9537
- loading: isLoading,
9539
+ loading: isPending,
9538
9540
  style: "primary",
9539
9541
  onClick: function onClick() {
9540
9542
  return handleReorderSave(initialRules);
@@ -9775,13 +9777,13 @@ var RulesTable = function RulesTable(_ref) {
9775
9777
  t = _useTranslation.t;
9776
9778
  var _useUpdateAutomationR = useUpdateAutomationRule(),
9777
9779
  updateRule = _useUpdateAutomationR.mutate,
9778
- isUpdating = _useUpdateAutomationR.isLoading;
9780
+ isUpdating = _useUpdateAutomationR.isPending;
9779
9781
  var _useCloneAutomationRu = useCloneAutomationRule(),
9780
9782
  cloneRule = _useCloneAutomationRu.mutate,
9781
- isCloning = _useCloneAutomationRu.isLoading;
9783
+ isCloning = _useCloneAutomationRu.isPending;
9782
9784
  var _useDeleteAutomationR = useDeleteAutomationRule(),
9783
9785
  deleteRule = _useDeleteAutomationR.mutate,
9784
- isDeleting = _useDeleteAutomationR.isLoading;
9786
+ isDeleting = _useDeleteAutomationR.isPending;
9785
9787
  var handleChangeStatus = function handleChangeStatus(event, id) {
9786
9788
  var status = event.target.checked ? STATUS_KEYS$1.ENABLED : STATUS_KEYS$1.DISABLED;
9787
9789
  var payload = {
@@ -9794,15 +9796,17 @@ var RulesTable = function RulesTable(_ref) {
9794
9796
  url: url,
9795
9797
  payload: payload
9796
9798
  }, {
9797
- onSuccess: onUpdateSuccess
9799
+ onSuccess: function onSuccess() {
9800
+ return onUpdateSuccess === null || onUpdateSuccess === void 0 ? void 0 : onUpdateSuccess();
9801
+ }
9798
9802
  });
9799
9803
  };
9800
9804
  var handleCloneSuccess = function handleCloneSuccess() {
9801
- onCloneSuccess();
9805
+ onCloneSuccess === null || onCloneSuccess === void 0 || onCloneSuccess();
9802
9806
  hidePreviewPane();
9803
9807
  };
9804
9808
  var handleDeleteSuccess = function handleDeleteSuccess() {
9805
- onDeleteSuccess();
9809
+ onDeleteSuccess === null || onDeleteSuccess === void 0 || onDeleteSuccess();
9806
9810
  hidePreviewPane();
9807
9811
  setSelectedRule(null);
9808
9812
  };