@tesouro/embedded-components-react 0.5.257 → 0.5.259

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 (64) hide show
  1. package/README.md +2 -1
  2. package/dist/fixtures/index.d.ts +1 -1
  3. package/dist/index.css +109 -9
  4. package/dist/index.d.ts +41 -10
  5. package/dist/lib/ReceivablesWidget.d.ts +41 -10
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +42 -94
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +91 -76
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +67 -173
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +186 -17
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +27 -0
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +28 -72
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +128 -53
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +66 -28
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +28 -34
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +24 -168
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +173 -44
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +274 -267
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +99 -95
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +1 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +28 -25
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +49 -43
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/unsavedChanges.js +13 -0
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +4 -4
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +2 -2
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js +77 -72
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +4 -4
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +363 -295
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +1 -1
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +1 -1
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePreview.js +36 -21
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +1 -1
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +1 -1
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +12 -10
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +21 -14
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +1 -1
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +1 -1
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +68 -64
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +383 -379
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +22 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +8 -2
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +258 -1
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +2 -100
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +95 -23
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +23 -231
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +237 -3
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +3 -249
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +234 -78
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +87 -53
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +49 -349
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +359 -0
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +45 -0
  55. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
  56. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +247 -214
  57. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +175 -147
  58. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +1 -1
  59. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  60. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
  61. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +2 -1
  62. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +109 -89
  63. package/package.json +1 -1
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +0 -4
@@ -2,19 +2,25 @@ import { minorExponentForCurrency as e } from "../../../../../shared/util/dist/l
2
2
  import "../../../../ui/dist/index19.js";
3
3
  import "../../../../ui/dist/index.js";
4
4
  import { isBlankLineItem as t, keepsSavedTaxRates as n, lineItemTaxRateMinorUnits as r, parseQuantity as i, priceInputToMinorUnits as a, taxRateToMinorUnits as o } from "./lineItems.js";
5
- import { formatTermDate as s, resolveIssueDate as c, termDueDate as l } from "./paymentTerms.js";
5
+ import { formatPreviewDate as s, resolveIssueDate as c, termDueDate as l } from "./paymentTerms.js";
6
6
  import { formatMoney as u } from "./helpers.js";
7
7
  import { differenceInCalendarDays as d, parseISO as f } from "date-fns";
8
8
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js
9
9
  var p = "US", m = 100;
10
10
  function h(e) {
11
+ return (e ?? []).some(({ status: e, direction: t }) => e === "active" && t === "receive");
12
+ }
13
+ function g(e) {
14
+ return e?.invoice?.display_organization_bank_account ?? e?.display_organization_bank_account ?? !0;
15
+ }
16
+ function _(e) {
11
17
  try {
12
18
  return new Intl.DisplayNames(void 0, { type: "region" }).of(e) ?? e;
13
19
  } catch {
14
20
  return e;
15
21
  }
16
22
  }
17
- function g({ address: e, issuerCountry: t, formatCountry: n = h }) {
23
+ function v({ address: e, issuerCountry: t, formatCountry: n = _ }) {
18
24
  if (!e) return [];
19
25
  let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country === p && t === p;
20
26
  return [
@@ -23,65 +29,65 @@ function g({ address: e, issuerCountry: t, formatCountry: n = h }) {
23
29
  e.country && !i ? n(e.country) : ""
24
30
  ].filter(Boolean);
25
31
  }
26
- var _ = { kind: "pending" }, v = (e) => ({
32
+ var y = { kind: "pending" }, b = (e) => ({
27
33
  kind: "text",
28
34
  lines: e
29
35
  });
30
- function y(e, t) {
36
+ function x(e, t) {
31
37
  return e.previewNetDays.replace("{days}", String(t));
32
38
  }
33
- function b(e, t) {
39
+ function S(e, t) {
34
40
  let n = e.previewEarlyPaymentDays.replace("{days}", String(t.number_of_days));
35
41
  return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / m))}` : n;
36
42
  }
37
- function x({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
43
+ function C({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
38
44
  let a = {
39
- dueDate: _,
40
- paymentTerms: _
45
+ dueDate: y,
46
+ paymentTerms: y
41
47
  };
42
48
  if (e === "custom") {
43
49
  if (!t) return a;
44
50
  let e = f(t), n = Math.max(0, d(e, r));
45
51
  return {
46
- dueDate: v([s(e)]),
47
- paymentTerms: v([y(i, n)])
52
+ dueDate: b([s(e)]),
53
+ paymentTerms: b([x(i, n)])
48
54
  };
49
55
  }
50
56
  if (e === "receipt_due") return {
51
- dueDate: v([s(r)]),
52
- paymentTerms: v([i.previewDueOnReceipt])
57
+ dueDate: b([s(r)]),
58
+ paymentTerms: b([i.previewDueOnReceipt])
53
59
  };
54
60
  let o = n?.find((t) => t.id === e);
55
61
  if (!o) return a;
56
62
  let c = l(o, r), u = [
57
- o.term_1 && b(i, o.term_1),
58
- o.term_2 && b(i, o.term_2),
59
- o.term_final && y(i, o.term_final.number_of_days)
63
+ o.term_1 && S(i, o.term_1),
64
+ o.term_2 && S(i, o.term_2),
65
+ o.term_final && x(i, o.term_final.number_of_days)
60
66
  ].filter((e) => !!e);
61
67
  return {
62
- dueDate: c ? v([s(c)]) : _,
63
- paymentTerms: u.length > 0 ? v(u) : _
68
+ dueDate: c ? b([s(c)]) : y,
69
+ paymentTerms: u.length > 0 ? b(u) : y
64
70
  };
65
71
  }
66
- function S(e, t) {
72
+ function w(e, t) {
67
73
  return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
68
74
  }
69
- function C(e) {
75
+ function T(e) {
70
76
  return e.length > 0 ? e : void 0;
71
77
  }
72
- function w(e, t) {
78
+ function E(e, t) {
73
79
  return e ? {
74
80
  name: e.type === "organization" ? e.organization.legal_name : void 0,
75
- addressLines: C(g({
81
+ addressLines: T(v({
76
82
  address: e.address,
77
83
  issuerCountry: e.address?.country
78
84
  })),
79
- taxIdLine: S(t, e.tax_id),
85
+ taxIdLine: w(t, e.tax_id),
80
86
  email: e.email ?? void 0,
81
87
  phone: e.phone ?? void 0
82
88
  } : {};
83
89
  }
84
- function T(e) {
90
+ function D(e) {
85
91
  let t = "organization" in e ? e.organization : e.individual;
86
92
  return {
87
93
  name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
@@ -89,22 +95,22 @@ function T(e) {
89
95
  phone: t.phone
90
96
  };
91
97
  }
92
- function E({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
98
+ function O({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
93
99
  if (!e) return { kind: "pending" };
94
- let { name: i, email: a, phone: o } = T(e);
100
+ let { name: i, email: a, phone: o } = D(e);
95
101
  return i ? {
96
102
  kind: "party",
97
103
  name: i,
98
- addressLines: C(g({
104
+ addressLines: T(v({
99
105
  address: t,
100
106
  issuerCountry: n
101
107
  })),
102
- taxIdLine: S(r, e.tax_id),
108
+ taxIdLine: w(r, e.tax_id),
103
109
  email: a || void 0,
104
110
  phone: o || void 0
105
111
  } : { kind: "pending" };
106
112
  }
107
- function D({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
113
+ function k({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
108
114
  return e.filter((e) => !t(e)).map((e) => {
109
115
  let t = a(e.price, n), s = i(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
110
116
  return {
@@ -126,19 +132,19 @@ function D({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
126
132
  };
127
133
  });
128
134
  }
129
- function O(t, n) {
135
+ function A(t, n) {
130
136
  return n ? new Intl.NumberFormat(void 0, {
131
137
  style: "currency",
132
138
  currency: n,
133
139
  currencySign: "accounting"
134
140
  }).format(-t / 10 ** e(n)) : "";
135
141
  }
136
- function k(e, i) {
142
+ function j(e, i) {
137
143
  if (!e.taxRate) return i.previewTax;
138
144
  let a = o(e.taxRate), s = n(e.taxRate, e.savedTaxRate);
139
145
  return new Set(e.lineItems.filter((e) => e.taxable && !t(e)).map((e) => r(e, a, s))).size > 1 ? i.previewTax : i.previewTaxWithRate.replace("{rate}", String(a / m));
140
146
  }
141
- function A({ totals: e, currency: t, taxLabel: n, messages: r }) {
147
+ function M({ totals: e, currency: t, taxLabel: n, messages: r }) {
142
148
  let i = (e) => u({
143
149
  amount: e,
144
150
  currency: t,
@@ -151,7 +157,7 @@ function A({ totals: e, currency: t, taxLabel: n, messages: r }) {
151
157
  return a && c.push({
152
158
  id: "discount",
153
159
  label: r.previewDiscount,
154
- value: O(e.discountAmount, t)
160
+ value: A(e.discountAmount, t)
155
161
  }), s && (o || a) && c.push({
156
162
  id: "nonTaxableSubtotal",
157
163
  label: r.previewNonTaxableSubtotal,
@@ -174,7 +180,7 @@ function A({ totals: e, currency: t, taxLabel: n, messages: r }) {
174
180
  }
175
181
  };
176
182
  }
177
- function j({ bankDetails: e, canReceivePayments: t, messages: n }) {
183
+ function N({ bankDetails: e, canReceivePayments: t, messages: n }) {
178
184
  let r = e ? [
179
185
  [n.previewAccountHolderName, e.accountHolderName],
180
186
  [n.previewRoutingNumber, e.routingNumber],
@@ -185,13 +191,13 @@ function j({ bankDetails: e, canReceivePayments: t, messages: n }) {
185
191
  bankLines: r
186
192
  };
187
193
  }
188
- function M({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: l, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
189
- let p = D({
194
+ function P({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: l, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
195
+ let p = k({
190
196
  lineItems: e.lineItems,
191
197
  currency: e.currency,
192
198
  unitNamesById: o,
193
199
  messages: d
194
- }), m = n?.logo?.url, h = w(n, d), g = c(e.issueDate, f);
200
+ }), m = n?.logo?.url, h = E(n, d), g = c(e.issueDate, f);
195
201
  return {
196
202
  issuer: h,
197
203
  logo: m ? {
@@ -199,15 +205,15 @@ function M({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
199
205
  src: m,
200
206
  alt: h.name ? d.previewLogoAlt.replace("{name}", h.name) : d.previewLogoAltNoName
201
207
  } : { kind: "placeholder" },
202
- billTo: E({
208
+ billTo: O({
203
209
  counterpart: r,
204
210
  billingAddress: i,
205
211
  issuerCountry: n?.address?.country,
206
212
  messages: d
207
213
  }),
208
- invoiceNumber: _,
214
+ invoiceNumber: y,
209
215
  issueDate: s(g),
210
- ...x({
216
+ ...C({
211
217
  paymentTermsId: e.paymentTermsId,
212
218
  paymentTermsCustomDate: e.paymentTermsCustomDate,
213
219
  paymentTerms: a,
@@ -219,14 +225,14 @@ function M({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
219
225
  kind: "rows",
220
226
  rows: p
221
227
  } : { kind: "empty" },
222
- totals: p.length > 0 ? A({
228
+ totals: p.length > 0 ? M({
223
229
  totals: t,
224
230
  currency: e.currency,
225
- taxLabel: k(e, d),
231
+ taxLabel: j(e, d),
226
232
  messages: d
227
233
  }) : void 0,
228
234
  closingNote: e.closingNote || void 0,
229
- payment: j({
235
+ payment: N({
230
236
  bankDetails: l,
231
237
  canReceivePayments: u,
232
238
  messages: d
@@ -234,4 +240,4 @@ function M({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
234
240
  };
235
241
  }
236
242
  //#endregion
237
- export { g as buildPreviewAddressLines, x as buildPreviewPaymentTerms, M as buildReceivablePreviewView, h as formatCountryName, O as formatDeduction };
243
+ export { v as buildPreviewAddressLines, C as buildPreviewPaymentTerms, P as buildReceivablePreviewView, g as displaysBankAccount, _ as formatCountryName, A as formatDeduction, h as hasReceivePaymentMethod };
@@ -0,0 +1,13 @@
1
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/unsavedChanges.js
2
+ function e(t, n) {
3
+ if (Object.is(t, n)) return !0;
4
+ if (Array.isArray(t) || Array.isArray(n)) return !Array.isArray(t) || !Array.isArray(n) || t.length !== n.length ? !1 : t.every((t, r) => e(t, n[r]));
5
+ if (!t || !n || typeof t != "object" || typeof n != "object") return !1;
6
+ let r = t, i = n;
7
+ return [.../* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])].every((t) => e(r[t], i[t]));
8
+ }
9
+ function t(t, n) {
10
+ return !e(t, n);
11
+ }
12
+ //#endregion
13
+ export { t as hasUnsavedChanges };
@@ -7,10 +7,10 @@ import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib
7
7
  import "../../../../../shared/ui/dist/index.js";
8
8
  import { defaultSendValues as n, formatMoney as r, hasSendErrors as i, isReceivableReadyToIssue as a, splitEmailList as o, validateSendValues as s } from "./helpers.js";
9
9
  import { getIssueReminderBlocker as c, hasSelectedReminder as ee } from "./reminders.js";
10
- import { useSendReceivableEmailMutation as l } from "../../../../data-access/dist/index7.js";
11
- import { useAcceptReceivableMutation as u, useCancelReceivableMutation as d, useCloneReceivableMutation as f, useDeclineReceivableMutation as te, useDeleteReceivableMutation as ne, useIssueReceivableMutation as p } from "../../../../data-access/dist/index8.js";
12
- import { useMarkReceivablePaidMutation as re, useMarkReceivableUncollectibleMutation as ie } from "../../../../data-access/dist/index10.js";
13
- import { useCancelRecurrenceMutation as ae, usePauseRecurrenceMutation as m, useResumeRecurrenceMutation as oe } from "../../../../data-access/dist/index12.js";
10
+ import { useSendReceivableEmailMutation as l } from "../../../../data-access/dist/index8.js";
11
+ import { useAcceptReceivableMutation as u, useCancelReceivableMutation as d, useCloneReceivableMutation as f, useDeclineReceivableMutation as te, useDeleteReceivableMutation as ne, useIssueReceivableMutation as p } from "../../../../data-access/dist/index9.js";
12
+ import { useMarkReceivablePaidMutation as re, useMarkReceivableUncollectibleMutation as ie } from "../../../../data-access/dist/index11.js";
13
+ import { useCancelRecurrenceMutation as ae, usePauseRecurrenceMutation as m, useResumeRecurrenceMutation as oe } from "../../../../data-access/dist/index13.js";
14
14
  import "../../../../data-access/dist/index.js";
15
15
  import { useReceivableIssuePreflight as h } from "./useReceivableIssuePreflight.js";
16
16
  import { useReceivablePaymentRecord as g } from "./useReceivablePaymentRecord.js";
@@ -11,8 +11,8 @@ import { useCreateProductMutation as i } from "../../../../../shared/product-cat
11
11
  import { useMeasureUnits as a } from "../../../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
12
12
  import "../../../../../shared/product-catalog/feature/dist/index.js";
13
13
  import { getInlineItemPriceLabel as o, getIssueAttachments as s, getIssueSubject as c, getProductsStepTitle as l, inlineItemToProductRequest as u } from "./actionsModal.js";
14
- import { useSendReceivableEmailMutation as d } from "../../../../data-access/dist/index7.js";
15
- import { useReceivableQuery as f } from "../../../../data-access/dist/index11.js";
14
+ import { useSendReceivableEmailMutation as d } from "../../../../data-access/dist/index8.js";
15
+ import { useReceivableQuery as f } from "../../../../data-access/dist/index12.js";
16
16
  import "../../../../data-access/dist/index.js";
17
17
  import { useCallback as p, useMemo as m, useState as h } from "react";
18
18
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js
@@ -3,7 +3,7 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { toFileArray as e, validateAttachmentFile as t } from "./attachments.js";
6
- import { useDeleteReceivableAttachmentMutation as n, useUploadReceivableAttachmentMutation as r } from "../../../../data-access/dist/index5.js";
6
+ import { useDeleteReceivableAttachmentMutation as n, useUploadReceivableAttachmentMutation as r } from "../../../../data-access/dist/index6.js";
7
7
  import "../../../../data-access/dist/index.js";
8
8
  import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
9
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js
@@ -7,98 +7,103 @@ import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib
7
7
  import "../../../../../shared/ui/dist/index.js";
8
8
  import { useWidgetConfig as n } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
9
  import "../../../../../shared/feature/dist/index.js";
10
- import { useCreateEntityBankAccountMutation as r, usePaymentAccountsQuery as i } from "../../../../data-access/dist/index4.js";
10
+ import { useCreateEntityBankAccountMutation as r, usePaymentAccountQuery as i, usePaymentAccountsQuery as a } from "../../../../data-access/dist/index5.js";
11
11
  import "../../../../data-access/dist/index.js";
12
- import { EMPTY_BANK_ACCOUNT_FORM_VALUES as a, bankAccountFormToPayload as o, buildBankAccountSectionView as s, buildPaymentAccountOptions as c, getBankAccountPermissions as l, validateBankAccountForm as u } from "./bankAccounts.js";
13
- import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
12
+ import { EMPTY_BANK_ACCOUNT_FORM_VALUES as o, bankAccountFormToPayload as s, buildBankAccountSectionView as c, buildPaymentAccountOptions as l, getBankAccountPermissions as u, validateBankAccountForm as d } from "./bankAccounts.js";
13
+ import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
14
14
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js
15
- function g({ open: g, bankAccountId: _, embeddedBankName: v, messages: y, onSelect: b }) {
16
- let { initResponse: x } = n(), S = p(() => l(x?.scopes), [x?.scopes]), { paymentAccounts: C, isLoading: w, isIncomplete: T } = i({
17
- enabled: g,
18
- canReadEmbedded: S.canReadEmbedded,
19
- canReadExternal: S.canReadExternal
20
- }), E = r(), [D, O] = h(!1), [k, A] = h(a), [j, M] = h({}), N = m(!1), P = d(() => {
21
- N.current = !1, O(!1), A(a), M({});
15
+ function _({ open: _, bankAccountId: v, bankAccountType: y, embeddedBankName: b, messages: x, onSelect: S }) {
16
+ let { initResponse: C } = n(), w = m(() => u(C?.scopes), [C?.scopes]), { paymentAccounts: T, isLoading: E, isIncomplete: D } = a({
17
+ enabled: _,
18
+ canReadEmbedded: w.canReadEmbedded,
19
+ canReadExternal: w.canReadExternal
20
+ }), O = r(), [k, A] = g(!1), [j, M] = g(o), [N, P] = g({}), F = h(!1), I = f(() => {
21
+ F.current = !1, A(!1), M(o), P({});
22
22
  }, []);
23
- f(() => {
24
- if (!g || T || N.current || C.length !== 1) return;
25
- let [e] = C;
26
- N.current = !0, b({
23
+ p(() => {
24
+ if (!_ || D || F.current || T.length !== 1) return;
25
+ let [e] = T;
26
+ F.current = !0, S({
27
27
  bankAccountId: e.id,
28
28
  bankAccountType: e.type
29
- });
29
+ }, { automatic: !0 });
30
30
  }, [
31
- T,
32
- b,
33
- g,
34
- C
31
+ D,
32
+ S,
33
+ _,
34
+ T
35
35
  ]);
36
- let F = d((e) => {
37
- let t = C.find((t) => t.id === e);
38
- t && b({
36
+ let L = f((e) => {
37
+ let t = T.find((t) => t.id === e);
38
+ t && S({
39
39
  bankAccountId: t.id,
40
40
  bankAccountType: t.type
41
41
  });
42
- }, [b, C]), I = d(() => O(!0), []), L = d(() => {
43
- O(!1), A(a), M({});
44
- }, []), R = d((e) => A((t) => ({
42
+ }, [S, T]), R = f(() => A(!0), []), z = f(() => {
43
+ A(!1), M(o), P({});
44
+ }, []), B = f((e) => M((t) => ({
45
45
  ...t,
46
46
  ...e
47
- })), []), z = d(async () => {
48
- let n = u(k, y);
49
- if (M(n), !(Object.keys(n).length > 0)) try {
50
- let t = await E.mutateAsync({ body: o(k) });
51
- O(!1), A(a), b({
47
+ })), []), V = f(async () => {
48
+ let n = d(j, x);
49
+ if (P(n), !(Object.keys(n).length > 0)) try {
50
+ let t = await O.mutateAsync({ body: s(j) });
51
+ A(!1), M(o), S({
52
52
  bankAccountId: t.id,
53
53
  bankAccountType: "BANK_DETAILS"
54
- }), e.success(y.bankAccountCreated.replace("{name}", t.display_name ?? ""));
54
+ }), e.success(x.bankAccountCreated.replace("{name}", t.display_name ?? ""));
55
55
  } catch (n) {
56
- e.error(t(n) ?? y.bankAccountCreateFailed);
56
+ e.error(t(n) ?? x.bankAccountCreateFailed);
57
57
  }
58
58
  }, [
59
- E,
60
- k,
61
- y,
62
- b
63
- ]), B = p(() => c({
64
- accounts: C,
65
- embeddedBankName: v,
66
- messages: y
59
+ O,
60
+ j,
61
+ x,
62
+ S
63
+ ]), H = m(() => l({
64
+ accounts: T,
65
+ embeddedBankName: b,
66
+ messages: x
67
+ }), [
68
+ b,
69
+ x,
70
+ T
71
+ ]), U = m(() => c({
72
+ options: H,
73
+ isLoading: E,
74
+ selectedId: v,
75
+ isAddingAccount: k,
76
+ canAddAccount: w.canAddAccount,
77
+ formValues: j,
78
+ formErrors: N,
79
+ isSaving: O.isPending
67
80
  }), [
68
81
  v,
69
- y,
70
- C
71
- ]);
82
+ O.isPending,
83
+ N,
84
+ j,
85
+ k,
86
+ E,
87
+ H,
88
+ w.canAddAccount
89
+ ]), W = m(() => T.find((e) => e.id === v), [v, T]), { paymentAccount: G } = i({
90
+ id: v,
91
+ type: y || (v ? "BANK_DETAILS" : void 0),
92
+ enabled: _ && !E && !W
93
+ });
72
94
  return {
73
- view: p(() => s({
74
- options: B,
75
- isLoading: w,
76
- selectedId: _,
77
- isAddingAccount: D,
78
- canAddAccount: S.canAddAccount,
79
- formValues: k,
80
- formErrors: j,
81
- isSaving: E.isPending
82
- }), [
83
- _,
84
- E.isPending,
85
- j,
86
- k,
87
- D,
88
- w,
89
- B,
90
- S.canAddAccount
91
- ]),
92
- isLoading: w,
93
- hasAccounts: C.length > 0,
94
- canAddAccount: S.canAddAccount,
95
- reset: P,
96
- selectAccount: F,
97
- openAddAccount: I,
98
- cancelAddAccount: L,
99
- updateAccountForm: R,
100
- saveAccount: z
95
+ view: U,
96
+ selectedAccount: W ?? G,
97
+ isLoading: E,
98
+ hasAccounts: T.length > 0,
99
+ canAddAccount: w.canAddAccount,
100
+ reset: I,
101
+ selectAccount: L,
102
+ openAddAccount: R,
103
+ cancelAddAccount: z,
104
+ updateAccountForm: B,
105
+ saveAccount: V
101
106
  };
102
107
  }
103
108
  //#endregion
104
- export { g as useReceivableBankAccount };
109
+ export { _ as useReceivableBankAccount };
@@ -12,10 +12,10 @@ import "../../../../../shared/feature/dist/index.js";
12
12
  import { RECEIVABLE_DETAILS_SECTION as i } from "../../../../ui/dist/index25.js";
13
13
  import "../../../../ui/dist/index.js";
14
14
  import { useAllReceivableHistoryQuery as a } from "../../../../data-access/dist/index3.js";
15
- import { usePaymentAccountsQuery as te } from "../../../../data-access/dist/index4.js";
16
- import { useReceivablePaymentRecordsQuery as o } from "../../../../data-access/dist/index9.js";
17
- import { useReceivablePdfLinkQuery as s, useReceivableQuery as ne, useReceivablesByIdQueries as re } from "../../../../data-access/dist/index11.js";
18
- import { useOverdueRemindersQuery as c, usePaymentRemindersQuery as ie, useRecurrenceQuery as l } from "../../../../data-access/dist/index12.js";
15
+ import { usePaymentAccountsQuery as te } from "../../../../data-access/dist/index5.js";
16
+ import { useReceivablePaymentRecordsQuery as o } from "../../../../data-access/dist/index10.js";
17
+ import { useReceivablePdfLinkQuery as s, useReceivableQuery as ne, useReceivablesByIdQueries as re } from "../../../../data-access/dist/index12.js";
18
+ import { useOverdueRemindersQuery as c, usePaymentRemindersQuery as ie, useRecurrenceQuery as l } from "../../../../data-access/dist/index13.js";
19
19
  import "../../../../data-access/dist/index.js";
20
20
  import { canRecordPayments as u } from "./paymentRecord.js";
21
21
  import { buildReceivableAuditHistoryLabels as d } from "./auditHistory/labels.js";