@nivaro/react 0.2.49 → 0.2.51

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.
@@ -1,52 +1,53 @@
1
1
  import { useQuery as m } from "@tanstack/react-query";
2
2
  import { useNivaroClient as y } from "../../context.js";
3
- import { get as p, post as c } from "../../lib/commands.js";
4
- import { builtinListed as d } from "./PushBulkButtons.js";
5
- function q(t) {
6
- const s = /* @__PURE__ */ new Set(), a = [];
7
- for (const e of t) {
8
- const r = String(e.external_api ?? "");
9
- s.has(r) || (s.add(r), (e.status === "failed" || e.status === "rejected") && a.push(e.external_api_name ?? `API ${e.external_api ?? "?"}`));
3
+ import { get as d, post as f } from "../../lib/commands.js";
4
+ import { builtinListed as p } from "./PushBulkButtons.js";
5
+ function g(e) {
6
+ const s = /* @__PURE__ */ new Set(), n = [];
7
+ for (const t of e) {
8
+ const r = String(t.external_api ?? "");
9
+ s.has(r) || (s.add(r), (t.status === "failed" || t.status === "rejected") && n.push(t.external_api_name ?? `API ${t.external_api ?? "?"}`));
10
10
  }
11
- return a;
11
+ return n;
12
12
  }
13
- function _({
14
- collection: t,
13
+ function S({
14
+ collection: e,
15
15
  id: s,
16
- open: a,
17
- bulkData: e,
16
+ open: n,
17
+ bulkData: t,
18
18
  bulkEnabledKeys: r
19
19
  }) {
20
- const u = y(), n = d(e, r, t, "push"), i = d(e, r, t, "retry-push"), { data: h = [] } = m({
21
- queryKey: ["item-actions", t, String(s)],
22
- queryFn: () => u.request(
23
- p("/item-actions/registered", { collection: t, item: String(s) })
24
- ).then((o) => o.data ?? []).catch(() => []),
25
- enabled: a && n,
20
+ const i = y(), a = p(t, r, e, "push"), c = p(t, r, e, "retry-push"), { data: u = [] } = m({
21
+ queryKey: ["item-actions", e, String(s)],
22
+ queryFn: () => i.request(
23
+ d("/item-actions/registered", { collection: e, item: String(s) })
24
+ ).then((h) => h.data ?? []).catch(() => []),
25
+ enabled: n && a,
26
26
  staleTime: 5 * 6e4
27
- }), { data: f = [] } = m({
28
- queryKey: ["row-push-state", t, String(s)],
29
- queryFn: () => u.request(p(`/erp-submissions/${t}/${s}`)).then((o) => q(o.data ?? [])).catch(() => []),
30
- enabled: a && i,
27
+ }), { data: o = [] } = m({
28
+ queryKey: ["row-push-state", e, String(s)],
29
+ queryFn: () => i.request(d(`/erp-submissions/${e}/${s}`)).then((h) => g(h.data ?? [])).catch(() => []),
30
+ enabled: n && c,
31
31
  staleTime: 15e3
32
32
  });
33
- return { pushActions: n ? h : [], failedPartners: i ? f : [] };
33
+ return { pushActions: a ? u : [], failedPartners: c ? o : [] };
34
34
  }
35
- async function l(t, s, a, e, r) {
36
- var n, i;
37
- return ((i = (n = (e.kind === "push" ? await t.request(
38
- c("/bulk-actions/push", {
35
+ async function _(e, s, n, t, r, i) {
36
+ var u, o;
37
+ const a = {};
38
+ return r != null && r.trim() && (a.message = r.trim()), t.kind === "push" && t.action.choose && i != null && (a[t.action.choose.key] = i), ((o = (u = (t.kind === "push" ? await e.request(
39
+ f("/bulk-actions/push", {
39
40
  collection: s,
40
- action_id: e.action.id,
41
- ids: [a],
42
- ...r != null && r.trim() ? { payload: { message: r.trim() } } : {}
41
+ action_id: t.action.id,
42
+ ids: [n],
43
+ ...Object.keys(a).length > 0 ? { payload: a } : {}
43
44
  })
44
- ) : await t.request(
45
- c("/bulk-actions/retry-push", { collection: s, ids: [a] })
46
- )).data) == null ? void 0 : n.outcomes) == null ? void 0 : i[0]) ?? null;
45
+ ) : await e.request(
46
+ f("/bulk-actions/retry-push", { collection: s, ids: [n] })
47
+ )).data) == null ? void 0 : u.outcomes) == null ? void 0 : o[0]) ?? null;
47
48
  }
48
49
  export {
49
- q as latestFailedPartners,
50
- l as runRowPush,
51
- _ as useRowPushActions
50
+ g as latestFailedPartners,
51
+ _ as runRowPush,
52
+ S as useRowPushActions
52
53
  };