@tesouro/embedded-components-react 0.5.200 → 0.5.202

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.
Files changed (45) hide show
  1. package/dist/index.d.ts +20 -0
  2. package/dist/index.js +1 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +20 -0
  4. package/dist/lib/ReceivablesWidget.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +6 -6
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +24 -18
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +65 -2
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +174 -234
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +32 -65
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +143 -102
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +48 -221
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +303 -0
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +75 -0
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +114 -0
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +237 -0
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index4.js +14 -1
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +30 -215
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +211 -370
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +64 -62
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +409 -187
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +73 -40
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +10 -9
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +0 -9
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +4 -1
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +10 -263
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +1 -72
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +241 -363
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +66 -100
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +406 -76
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +92 -330
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +93 -0
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +344 -0
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +10 -1
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +157 -20
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +24 -1
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +1 -3
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +3 -18
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +2 -0
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +18 -4
  41. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +37 -37
  42. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +54 -54
  43. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +115 -94
  44. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  45. package/package.json +1 -1
@@ -2,254 +2,194 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { getStateOptions as e } from "../../../shared/util/dist/lib/usStates.js";
6
- import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
7
- import { usePaymentTermsQuery as n } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
8
- import { COUNTERPART_MESSAGE_LABELS_EN as r } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
9
- import { useCounterpartAddressesQuery as i } from "../../../shared/counterpart-management/data-access/dist/index7.js";
10
- import { useCounterpartForm as ee } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
11
- import "../../../shared/counterpart-management/feature/dist/index.js";
12
- import { buildLineItemControls as a, commitLineItemField as te, convertPriceInput as ne, createLineItem as re, getCurrencySymbol as o, lineItemFromProduct as s, reconcileMeasureUnits as c, sanitizeLineItemPatch as l, stepLineItemQuantity as u, stripBlankLineItems as ie, summarizeLineItemErrors as ae, toSheetLineItem as d, validateLineItems as oe } from "./index5.js";
13
- import { createEmptyReceivableFormValues as f, getPaymentTermOptions as se, hasReceivableFormErrors as ce, receivableFormValuesToCreatePayload as le, receivableFormValuesToLineItemChanges as ue, receivableFormValuesToUpdatePayload as de, receivableToFormValues as fe, validateReceivableForm as p } from "./index6.js";
14
- import { useCreateReceivableMutation as m, useUpdateReceivableMutation as pe } from "../../data-access/dist/index6.js";
5
+ import { extractApiErrorMessage as e } from "../../../shared/util/dist/lib/apiErrors.js";
6
+ import { defaultPaymentValues as t, defaultSendValues as n, fromMajorUnits as r, hasPaymentErrors as i, hasSendErrors as a, splitEmailList as o, validatePaymentValues as s, validateSendValues as c } from "./index8.js";
7
+ import { useSendReceivableEmailMutation as l } from "../../data-access/dist/index5.js";
8
+ import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as te, useCloneReceivableMutation as u, useDeclineReceivableMutation as d, useDeleteReceivableMutation as f, useIssueReceivableMutation as p } from "../../data-access/dist/index6.js";
9
+ import { useMarkReceivablePaidMutation as m, useMarkReceivablePartiallyPaidMutation as h, useMarkReceivableUncollectibleMutation as g } from "../../data-access/dist/index8.js";
15
10
  import "../../data-access/dist/index.js";
16
- import { getCurrencyOptions as me } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
17
- import { useMeasureUnitsQuery as he } from "../../../shared/product-catalog/data-access/dist/index9.js";
18
- import { useMeasureUnits as ge } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
19
- import "../../../shared/product-catalog/feature/dist/index.js";
20
- import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
11
+ import { useCallback as _, useState as v } from "react";
21
12
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js
22
- function b({ messages: b, counterpartMessageLabels: x, onCreated: S }) {
23
- let C = m(), w = pe(), T = v([]), E = v(""), D = n(), [O, k] = y(!1), [A, j] = y("create"), [M, N] = y(), [P, F] = y(() => f()), [I, L] = y({}), [R, _e] = y("none"), z = ge(), B = he(), V = B.data?.data, { unitNamesById: H } = z, [ve, U] = y(), [W, G] = y(!1), K = v(!1), ye = _(() => e(), []), be = _(() => ({
24
- ...r,
25
- ...x
26
- }), [x]), q = i(P.customerId), xe = q.data?.data?.[0], J = q.data?.data?.[0]?.id, Se = h((e) => {
27
- F((t) => ({
28
- ...t,
29
- customerId: e ?? ""
30
- }));
31
- }, []), Y = ee({
32
- view: R,
33
- setView: _e,
34
- selectedId: P.customerId || void 0,
35
- setSelectedId: Se,
36
- messages: be,
37
- counterpartType: "customer",
38
- counterpart: void 0,
39
- primaryAddress: xe
40
- }), X = h(() => {
41
- T.current = [], U(void 0), j("create"), N(void 0), F(f()), L({}), G(!1);
42
- }, []), Ce = h((e = "invoice") => {
43
- T.current = [], U(void 0), j("create"), N(void 0), F({
44
- ...f(),
45
- type: e
46
- }), L({}), G(!1), k(!0);
47
- }, []), we = h((e) => {
48
- e.type !== "credit_note" && (T.current = e.line_items, E.current = e.currency, U(void 0), j("edit"), N(e.id), F(fe(e, V)), L({}), G(!1), k(!0));
49
- }, [V]);
50
- g(() => {
51
- V?.length && F((e) => {
52
- let t = c(e.lineItems, V);
53
- return t === e.lineItems ? e : {
54
- ...e,
55
- lineItems: t
56
- };
57
- });
58
- }, [V]);
59
- let Te = h(() => {
60
- k(!1), L({});
61
- }, []), Ee = h((e) => {
62
- let { currency: t } = e;
63
- if (t === void 0) {
64
- F((t) => ({
65
- ...t,
66
- ...e
67
- }));
13
+ function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C }) {
14
+ let w = p(), T = te(), E = u(), D = ee(), O = d(), k = f(), A = l(), j = m(), M = h(), N = g(), [P, F] = v(), [I, L] = v(), [R, z] = v(), [B, V] = v(() => n(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => t()), [J, Y] = v({}), X = _((e, r, i) => {
15
+ let a = "documentLabel" in r ? r.documentLabel : r.title, o = {
16
+ id: r.id,
17
+ type: r.type,
18
+ title: a,
19
+ action: e
20
+ }, s = i === void 0 ? y : i ?? void 0;
21
+ if (e === "send") {
22
+ z(o), V(n(s, x)), U({});
68
23
  return;
69
24
  }
70
- K.current = !0, F((n) => n.currency === t ? {
71
- ...n,
72
- ...e
73
- } : {
74
- ...n,
75
- ...e,
76
- lineItems: n.lineItems.map((e) => ({
77
- ...e,
78
- price: ne(e.price, n.currency, t)
79
- }))
80
- });
81
- }, []), Z = h((e, t) => {
82
- let n = oe(e, {
83
- currency: t,
84
- messages: b
85
- });
86
- L((e) => ({
87
- ...e,
88
- lineItems: n,
89
- lineItemsSummary: ae(n)
90
- }));
91
- }, [b]), Q = h((e, { validate: t }) => {
92
- t && (K.current = !0), F((t) => ({
93
- ...t,
94
- lineItems: e(t.lineItems)
95
- }));
96
- }, []);
97
- g(() => {
98
- K.current && (K.current = !1, Z(P.lineItems, P.currency));
99
- }, [
100
- Z,
101
- P.currency,
102
- P.lineItems
103
- ]);
104
- let De = h((e, t) => {
105
- let { unit: n, ...r } = t, i = l(r);
106
- i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), Q((t) => t.map((t) => t.id === e ? {
107
- ...t,
108
- ...i
109
- } : t), { validate: W });
110
- }, [Q, W]), Oe = h((e, t) => {
111
- Q((n) => n.map((n) => n.id === e ? {
112
- ...n,
113
- ...s({
114
- product: t,
115
- currency: P.currency,
116
- unitNamesById: H
117
- })
118
- } : n), { validate: !0 });
119
- }, [
120
- Q,
121
- H,
122
- P.currency
123
- ]), $ = h((e, t) => {
124
- t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
125
- ...n,
126
- ...t.patch
127
- } : n), { validate: !0 });
128
- }, [Q]), ke = h((e, t) => {
129
- let n = P.lineItems.find((t) => t.id === e);
130
- n && $(e, te({
131
- lineItem: n,
132
- field: t,
133
- rowCount: P.lineItems.length,
134
- currency: P.currency
135
- }));
25
+ if (e === "recordPayment") {
26
+ G({
27
+ ...o,
28
+ currency: s?.currency
29
+ }), q(t()), Y({});
30
+ return;
31
+ }
32
+ L(void 0), F(o);
33
+ }, [x, y]), Z = _(() => {
34
+ F(void 0), L(void 0);
35
+ }, []), Q = _(() => {
36
+ z(void 0), U({});
37
+ }, []), $ = _(() => {
38
+ G(void 0), Y({});
39
+ }, []), ne = _(async () => {
40
+ if (!P) return;
41
+ let t = { receivable_id: P.id };
42
+ try {
43
+ if (P.action === "issue") await w.mutateAsync({ path: t });
44
+ else if (P.action === "cancel") await T.mutateAsync({ path: t });
45
+ else if (P.action === "clone") {
46
+ let e = await E.mutateAsync({ path: t });
47
+ e?.id && S?.(e.id, e.type);
48
+ } else P.action === "accept" ? await D.mutateAsync({ path: t }) : P.action === "decline" ? await O.mutateAsync({ path: t }) : P.action === "delete" ? (await k.mutateAsync({ path: t }), C?.(P.id)) : P.action === "markPaid" ? await j.mutateAsync({
49
+ path: t,
50
+ body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
51
+ }) : P.action === "markUncollectible" && await N.mutateAsync({ path: t });
52
+ F(void 0), L(void 0);
53
+ } catch (t) {
54
+ L(e(t) ?? x.genericError);
55
+ }
136
56
  }, [
137
- $,
138
- P.currency,
139
- P.lineItems
140
- ]), Ae = h((e, t) => {
141
- let n = P.lineItems.find((t) => t.id === e);
142
- n && $(e, u({
143
- lineItem: n,
144
- step: t,
145
- rowCount: P.lineItems.length
146
- }));
147
- }, [$, P.lineItems]), je = h(() => {
148
- let e = re(P.currency);
149
- U(e.id), F((t) => ({
150
- ...t,
151
- lineItems: [...t.lineItems, e]
152
- }));
153
- }, [P.currency]), Me = h((e) => {
154
- Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
155
- }, [Q]), Ne = h(async () => {
156
- if (B.isLoading) {
157
- L({ form: b.lineItemsLoading });
57
+ D,
58
+ P,
59
+ T,
60
+ E,
61
+ O,
62
+ k,
63
+ w,
64
+ j,
65
+ x.genericError,
66
+ S,
67
+ C,
68
+ N
69
+ ]), re = _(async () => {
70
+ if (!R) return;
71
+ let t = c(B, x);
72
+ if (a(t)) {
73
+ U(t);
158
74
  return;
159
75
  }
160
- let e = ie(P.lineItems), n = e.length === P.lineItems.length ? P : {
161
- ...P,
162
- lineItems: e
163
- };
164
- n !== P && F(n);
165
- let r = p({
166
- values: n,
167
- billingAddressId: J,
168
- messages: b
169
- });
170
- if (ce(r)) {
171
- L(r), G(!0);
76
+ try {
77
+ await A.mutateAsync({
78
+ path: { receivable_id: R.id },
79
+ body: {
80
+ body_text: B.body,
81
+ subject_text: B.subject,
82
+ recipients: {
83
+ to: o(B.to),
84
+ cc: o(B.cc),
85
+ bcc: o(B.bcc)
86
+ }
87
+ }
88
+ }), Q();
89
+ } catch (t) {
90
+ U({ form: e(t) ?? x.genericError });
91
+ }
92
+ }, [
93
+ Q,
94
+ x,
95
+ A,
96
+ R,
97
+ B
98
+ ]), ie = _(async () => {
99
+ if (!W) return;
100
+ let t = s(K, x, W.currency);
101
+ if (i(t)) {
102
+ Y(t);
172
103
  return;
173
104
  }
174
- L({});
175
105
  try {
176
- if (A === "edit" && M) {
177
- let e = { receivable_id: M };
178
- await w.mutateAsync({
179
- path: e,
180
- body: de({
181
- values: n,
182
- billingAddressId: J ?? "",
183
- lineItemChanges: ue({
184
- values: n,
185
- originalLineItems: T.current,
186
- originalCurrency: E.current,
187
- unitNamesById: H,
188
- units: V
189
- })
190
- })
191
- }), k(!1), X();
192
- return;
193
- }
194
- let e = await C.mutateAsync({ body: le({
195
- values: n,
196
- billingAddressId: J ?? "",
197
- unitNamesById: H
198
- }) });
199
- k(!1), X(), e?.id && S?.(e.id, e.type);
200
- } catch (e) {
201
- L({ form: t(e) ?? b.genericError });
106
+ let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
107
+ K.mode === "full" ? await j.mutateAsync({
108
+ path: e,
109
+ body: {
110
+ comment: K.comment || void 0,
111
+ paid_at: t
112
+ }
113
+ }) : await M.mutateAsync({
114
+ path: e,
115
+ body: {
116
+ amount_paid: r(K.amountPaid, W.currency) ?? 0,
117
+ comment: K.comment || void 0
118
+ }
119
+ }), $();
120
+ } catch (t) {
121
+ Y({ form: e(t) ?? x.genericError });
202
122
  }
203
123
  }, [
204
- J,
205
- C,
124
+ $,
125
+ j,
126
+ x,
206
127
  M,
207
- b,
208
- A,
209
- S,
210
- X,
211
- V,
212
- H,
213
- B.isLoading,
214
- w,
215
- P
216
- ]), Pe = _(() => ({
217
- ...P,
218
- lineItems: P.lineItems.map(d)
219
- }), [P]), Fe = _(() => a(P.lineItems), [P.lineItems]);
128
+ W,
129
+ K
130
+ ]);
220
131
  return {
221
- open: O,
222
- setOpen: k,
223
- mode: A,
224
- values: P,
225
- sheetValues: Pe,
226
- errors: I,
227
- setValues: F,
228
- updateValues: Ee,
229
- updateLineItem: De,
230
- selectProduct: Oe,
231
- commitLineItem: ke,
232
- stepLineItem: Ae,
233
- addLineItem: je,
234
- removeLineItem: Me,
235
- autoFocusLineItemId: ve,
236
- lineItemUnitOptions: z.unitOptions,
237
- lineItemsLoading: B.isLoading,
238
- lineItemControls: Fe,
239
- currencySymbol: o(P.currency),
240
- isSubmitting: C.isPending || w.isPending,
241
- currencyOptions: me(P.currency),
242
- paymentTermsOptions: se(D.data?.data),
243
- openCreate: Ce,
244
- openEdit: we,
245
- close: Te,
246
- submit: Ne,
247
- units: z,
248
- counterpartView: R,
249
- counterpartForm: Y,
250
- stateOptions: ye,
251
- openCounterpartCreate: Y.openCreate
132
+ actionTarget: P,
133
+ actionDialog: P ? b(P.action, x) : void 0,
134
+ actionError: I,
135
+ actionInProgress: w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || N.isPending,
136
+ openAction: X,
137
+ closeAction: Z,
138
+ confirmAction: ne,
139
+ sendOpen: !!R,
140
+ sendValues: B,
141
+ sendErrors: H,
142
+ sendInProgress: A.isPending,
143
+ setSendValues: V,
144
+ closeSend: Q,
145
+ submitSend: re,
146
+ paymentOpen: !!W,
147
+ paymentValues: K,
148
+ paymentErrors: J,
149
+ paymentInProgress: j.isPending || M.isPending,
150
+ setPaymentValues: q,
151
+ closePayment: $,
152
+ submitPayment: ie
153
+ };
154
+ }
155
+ function b(e, t) {
156
+ return e === "issue" ? {
157
+ title: t.issueTitle,
158
+ description: t.issueDescription,
159
+ confirmLabel: t.issueConfirm
160
+ } : e === "accept" ? {
161
+ title: t.acceptTitle,
162
+ description: t.acceptDescription,
163
+ confirmLabel: t.acceptConfirm
164
+ } : e === "decline" ? {
165
+ title: t.declineTitle,
166
+ description: t.declineDescription,
167
+ confirmLabel: t.declineConfirm,
168
+ destructive: !0
169
+ } : e === "cancel" ? {
170
+ title: t.cancelTitle,
171
+ description: t.cancelDescription,
172
+ confirmLabel: t.cancelConfirm,
173
+ destructive: !0
174
+ } : e === "clone" ? {
175
+ title: t.cloneTitle,
176
+ description: t.cloneDescription,
177
+ confirmLabel: t.cloneConfirm
178
+ } : e === "delete" ? {
179
+ title: t.deleteTitle,
180
+ description: t.deleteDescription,
181
+ confirmLabel: t.deleteConfirm,
182
+ destructive: !0
183
+ } : e === "markPaid" ? {
184
+ title: t.markPaidTitle,
185
+ description: t.markPaidDescription,
186
+ confirmLabel: t.markPaidConfirm
187
+ } : {
188
+ title: t.markUncollectibleTitle,
189
+ description: t.markUncollectibleDescription,
190
+ confirmLabel: t.markUncollectibleConfirm,
191
+ destructive: !0
252
192
  };
253
193
  }
254
194
  //#endregion
255
- export { b as useReceivableForm };
195
+ export { y as useReceivableActions };
@@ -2,74 +2,41 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { buildReceivableRows as e, statusFilterOptions as t, typeForTab as n } from "./index6.js";
6
- import { useReceivablesQuery as r } from "../../data-access/dist/index9.js";
5
+ import { buildReceivableDetailsView as e } from "./index8.js";
6
+ import { useReceivableHistoryQuery as t, useReceivableMailsQuery as n, useReceivablePdfLinkQuery as r, useReceivableQuery as i } from "../../data-access/dist/index9.js";
7
7
  import "../../data-access/dist/index.js";
8
- import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
8
+ import { useMemo as a } from "react";
9
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js
10
- var c = [];
11
- function l({ activeTab: l, messages: d }) {
12
- let [f, p] = s([]), [m, h] = s(10), [g, _] = s(), [v, y] = s(""), [b, x] = s(""), [S, C] = s("all");
13
- a(() => {
14
- _(void 0), C("all");
15
- }, [l]), a(() => {
16
- let e = setTimeout(() => {
17
- x(v), _(void 0);
18
- }, 300);
19
- return () => clearTimeout(e);
20
- }, [v]);
21
- let w = f[0]?.id, T = w ? u[w] : void 0, E = f[0] ? f[0].desc ? "desc" : "asc" : void 0, D = r({
22
- type: n(l),
23
- limit: m,
24
- pagination_token: g,
25
- search_text: b || void 0,
26
- status: S === "all" ? void 0 : S,
27
- ...T ? {
28
- sort: T,
29
- order: E
30
- } : {}
31
- }), O = D.data?.data ?? c, k = o(() => new Map(O.map((e) => [e.id, e])), [O]), A = i((e) => k.get(e), [k]), j = o(() => e({
32
- receivables: O,
33
- messages: d
34
- }), [d, O]), M = !!b || S !== "all", N = i((e) => {
35
- let t = typeof e == "function" ? e(f) : e;
36
- p(t), _(void 0);
37
- }, [f]), P = i((e) => {
38
- h(e), _(void 0);
39
- }, []), F = i((e) => {
40
- C(e), _(void 0);
41
- }, []), I = i(() => _(D.data?.next_pagination_token ?? void 0), [D.data?.next_pagination_token]), L = i(() => _(D.data?.prev_pagination_token ?? void 0), [D.data?.prev_pagination_token]), R = i(() => {
42
- D.refetch();
43
- }, [D]);
10
+ function o({ selectedReceivableId: o, enabled: s = !0, messages: c }) {
11
+ let l = i(o, { enabled: s }), u = t(o, {
12
+ enabled: s,
13
+ limit: 25,
14
+ sort: "timestamp",
15
+ order: "desc"
16
+ }), d = n(o, {
17
+ enabled: s,
18
+ limit: 10,
19
+ sort: "created_at",
20
+ order: "desc"
21
+ }), f = r(o, { enabled: s && !!l.data }), p = a(() => e({
22
+ receivable: l.data,
23
+ history: u.data?.data ?? [],
24
+ mails: d.data?.data ?? [],
25
+ pdfUrl: f.data?.file_url || f.data?.original_file_url || void 0,
26
+ messages: c
27
+ }), [
28
+ l.data,
29
+ u.data?.data,
30
+ d.data?.data,
31
+ c,
32
+ f.data
33
+ ]);
44
34
  return {
45
- rows: j,
46
- isLoading: D.isLoading,
47
- isError: D.isError,
48
- sorting: f,
49
- onSortingChange: N,
50
- pageSize: m,
51
- onPageSizeChange: P,
52
- hasNextPage: !!D.data?.next_pagination_token,
53
- hasPrevPage: !!D.data?.prev_pagination_token,
54
- onNextPage: I,
55
- onPrevPage: L,
56
- searchValue: v,
57
- onSearchChange: y,
58
- statusFilter: S,
59
- statusOptions: t(),
60
- onStatusFilterChange: F,
61
- isFiltering: M,
62
- onRetry: R,
63
- getReceivableById: A
35
+ receivable: l.data,
36
+ detailsView: p,
37
+ isLoading: l.isLoading || u.isLoading || d.isLoading || f.isLoading,
38
+ isError: l.isError
64
39
  };
65
40
  }
66
- var u = {
67
- documentLabel: "document_id",
68
- customerLabel: "counterpart_name",
69
- status: "status",
70
- issueDateLabel: "issue_date",
71
- dueDateLabel: "due_date",
72
- totalLabel: "total_amount"
73
- };
74
41
  //#endregion
75
- export { l as useReceivablesTable };
42
+ export { o as useReceivableDetails };