@tesouro/embedded-components-react 0.5.268 → 0.5.270

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 (56) hide show
  1. package/dist/index.css +4 -10
  2. package/dist/index.d.ts +13 -9
  3. package/dist/lib/ReceivablesWidget.d.ts +13 -9
  4. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index.js +3 -1
  5. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsContainer.js +44 -0
  6. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsSheetView.js +97 -0
  7. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js +76 -150
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +63 -57
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/actionsModal.js +1 -1
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/auditHistory/labels.js +1 -1
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +161 -152
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +30 -34
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +12 -8
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/statusCards.js +18 -19
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +208 -158
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +91 -85
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +197 -196
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +147 -115
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +14 -14
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +3 -5
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +37 -34
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +22 -7
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +17 -15
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +17 -13
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +37 -31
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +29 -23
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +38 -11
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +26 -28
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +20 -14
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +8 -24
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +34 -83
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +14 -404
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +28 -2
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +79 -39
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +490 -68
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +2 -502
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +41 -216
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +70 -21
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +484 -5
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +224 -0
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +21 -263
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +8 -2
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +261 -24
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +2 -237
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +100 -3
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +21 -242
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +226 -82
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +3 -59
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +233 -178
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +85 -37
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index54.js +60 -0
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index55.js +194 -0
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index56.js +45 -0
  54. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +0 -100
package/dist/index.css CHANGED
@@ -76,7 +76,6 @@
76
76
  --ttw-color-violet-200: oklch(89.4% 0.057 293.283);
77
77
  --ttw-color-violet-400: oklch(70.2% 0.183 293.541);
78
78
  --ttw-color-violet-700: oklch(49.1% 0.27 292.581);
79
- --ttw-color-violet-950: oklch(28.3% 0.141 291.089);
80
79
  --ttw-color-purple-50: oklch(97.7% 0.014 308.299);
81
80
  --ttw-color-purple-100: oklch(94.6% 0.033 307.174);
82
81
  --ttw-color-purple-400: oklch(71.4% 0.203 305.504);
@@ -1262,9 +1261,6 @@
1262
1261
  .ttw\:w-168 {
1263
1262
  width: calc(var(--ttw-spacing) * 168);
1264
1263
  }
1265
- .ttw\:w-180 {
1266
- width: calc(var(--ttw-spacing) * 180);
1267
- }
1268
1264
  .ttw\:w-560 {
1269
1265
  width: calc(var(--ttw-spacing) * 560);
1270
1266
  }
@@ -2332,6 +2328,10 @@
2332
2328
  border-left-style: var(--tw-border-style);
2333
2329
  border-left-width: 1px;
2334
2330
  }
2331
+ .ttw\:border-l-0 {
2332
+ border-left-style: var(--tw-border-style);
2333
+ border-left-width: 0px;
2334
+ }
2335
2335
  .ttw\:border-l-2 {
2336
2336
  border-left-style: var(--tw-border-style);
2337
2337
  border-left-width: 2px;
@@ -6048,9 +6048,6 @@
6048
6048
  .ttw\:sm\:max-w-178 {
6049
6049
  max-width: calc(var(--ttw-spacing) * 178);
6050
6050
  }
6051
- .ttw\:sm\:max-w-180 {
6052
- max-width: calc(var(--ttw-spacing) * 180);
6053
- }
6054
6051
  .ttw\:sm\:max-w-\[423px\] {
6055
6052
  max-width: 423px;
6056
6053
  }
@@ -6271,9 +6268,6 @@
6271
6268
  .ttw\:dark\:bg-transparent:is(.dark *):not(.tesouro-embedded-light, .tesouro-embedded-light *) {
6272
6269
  background-color: transparent;
6273
6270
  }
6274
- .ttw\:dark\:bg-violet-950:is(.dark *):not(.tesouro-embedded-light, .tesouro-embedded-light *) {
6275
- background-color: var(--ttw-color-violet-950);
6276
- }
6277
6271
  .ttw\:dark\:bg-yellow-950:is(.dark *):not(.tesouro-embedded-light, .tesouro-embedded-light *) {
6278
6272
  background-color: var(--ttw-color-yellow-950);
6279
6273
  }
package/dist/index.d.ts CHANGED
@@ -5167,7 +5167,6 @@ interface ReceivableFormDialogLabels extends ReceivableBillingSectionLabels, Rec
5167
5167
  customerDescription: string;
5168
5168
  customerEmailLabel: string;
5169
5169
  addCustomerDetailsButton: string;
5170
- issueDateLabel: string;
5171
5170
  dueDateLabel: string;
5172
5171
  lineItemsHeading: string;
5173
5172
  lineItemsDescription: string;
@@ -5250,8 +5249,6 @@ type ReceivableFormSheetLabels = ReceivableFormDialogLabels;
5250
5249
  interface ReceivableDetailsPanelLabels {
5251
5250
  hiddenDescription: string;
5252
5251
  loadingTitle: string;
5253
- errorTitle: string;
5254
- errorDescription: string;
5255
5252
  moreActionsLabel: string;
5256
5253
  viewPdfButton: string;
5257
5254
  closeButton: string;
@@ -5289,6 +5286,7 @@ interface ReceivableDetailsPanelLabels {
5289
5286
  noLineItems: string;
5290
5287
  editButton: string;
5291
5288
  issueButton: string;
5289
+ issueAndSendButton: string;
5292
5290
  recordPaymentButton: string;
5293
5291
  sendButton: string;
5294
5292
  acceptButton: string;
@@ -5459,6 +5457,9 @@ interface ReceivableMessageLabels {
5459
5457
  detailsUnsupportedTitle: string;
5460
5458
  /** `{type}` is replaced with the receivable's API type. */
5461
5459
  detailsUnsupportedDescription: string;
5460
+ detailsNotFoundTitle: string;
5461
+ /** `{invoiceId}` is replaced with the requested invoice ID. */
5462
+ detailsNotFoundDescription: string;
5462
5463
  /** `{number}` is replaced with the invoice number. */
5463
5464
  detailsInvoiceSubtitle: string;
5464
5465
  /** `{days}` is replaced with the number of days. */
@@ -5517,21 +5518,23 @@ interface ReceivableMessageLabels {
5517
5518
  detailsIterationStatusCompleted: string;
5518
5519
  sendSubjectDefault: string;
5519
5520
  sendBodyDefault: string;
5520
- issueTitle: string;
5521
- issueDescription: string;
5522
- issueConfirm: string;
5521
+ issueSucceeded: string;
5523
5522
  acceptTitle: string;
5524
5523
  acceptDescription: string;
5525
5524
  acceptConfirm: string;
5526
5525
  declineTitle: string;
5527
5526
  declineDescription: string;
5528
5527
  declineConfirm: string;
5528
+ issueFailed: string;
5529
+ issueAndSendNoEmail: string;
5529
5530
  cancelTitle: string;
5531
+ /** `{number}` is replaced with the invoice number. */
5532
+ cancelNumberedTitle: string;
5533
+ cancelClose: string;
5530
5534
  cancelDescription: string;
5531
5535
  cancelConfirm: string;
5532
- cloneTitle: string;
5533
- cloneDescription: string;
5534
- cloneConfirm: string;
5536
+ cloneSuccess: string;
5537
+ cloneError: string;
5535
5538
  deleteTitle: string;
5536
5539
  deleteDescription: string;
5537
5540
  deleteConfirm: string;
@@ -5683,6 +5686,7 @@ interface ReceivableMessageLabels {
5683
5686
  actionsTitleIssued: string;
5684
5687
  actionsTitleRecurrence: string;
5685
5688
  actionsTitleDraft: string;
5689
+ actionsTitleUpdated: string;
5686
5690
  actionsSelectAll: string;
5687
5691
  actionsDeselectAll: string;
5688
5692
  actionsProductsSaved: string;
@@ -1106,7 +1106,6 @@ interface ReceivableFormDialogLabels extends ReceivableBillingSectionLabels, Rec
1106
1106
  customerDescription: string;
1107
1107
  customerEmailLabel: string;
1108
1108
  addCustomerDetailsButton: string;
1109
- issueDateLabel: string;
1110
1109
  dueDateLabel: string;
1111
1110
  lineItemsHeading: string;
1112
1111
  lineItemsDescription: string;
@@ -1189,8 +1188,6 @@ type ReceivableFormSheetLabels = ReceivableFormDialogLabels;
1189
1188
  interface ReceivableDetailsPanelLabels {
1190
1189
  hiddenDescription: string;
1191
1190
  loadingTitle: string;
1192
- errorTitle: string;
1193
- errorDescription: string;
1194
1191
  moreActionsLabel: string;
1195
1192
  viewPdfButton: string;
1196
1193
  closeButton: string;
@@ -1228,6 +1225,7 @@ interface ReceivableDetailsPanelLabels {
1228
1225
  noLineItems: string;
1229
1226
  editButton: string;
1230
1227
  issueButton: string;
1228
+ issueAndSendButton: string;
1231
1229
  recordPaymentButton: string;
1232
1230
  sendButton: string;
1233
1231
  acceptButton: string;
@@ -1398,6 +1396,9 @@ interface ReceivableMessageLabels {
1398
1396
  detailsUnsupportedTitle: string;
1399
1397
  /** `{type}` is replaced with the receivable's API type. */
1400
1398
  detailsUnsupportedDescription: string;
1399
+ detailsNotFoundTitle: string;
1400
+ /** `{invoiceId}` is replaced with the requested invoice ID. */
1401
+ detailsNotFoundDescription: string;
1401
1402
  /** `{number}` is replaced with the invoice number. */
1402
1403
  detailsInvoiceSubtitle: string;
1403
1404
  /** `{days}` is replaced with the number of days. */
@@ -1456,21 +1457,23 @@ interface ReceivableMessageLabels {
1456
1457
  detailsIterationStatusCompleted: string;
1457
1458
  sendSubjectDefault: string;
1458
1459
  sendBodyDefault: string;
1459
- issueTitle: string;
1460
- issueDescription: string;
1461
- issueConfirm: string;
1460
+ issueSucceeded: string;
1462
1461
  acceptTitle: string;
1463
1462
  acceptDescription: string;
1464
1463
  acceptConfirm: string;
1465
1464
  declineTitle: string;
1466
1465
  declineDescription: string;
1467
1466
  declineConfirm: string;
1467
+ issueFailed: string;
1468
+ issueAndSendNoEmail: string;
1468
1469
  cancelTitle: string;
1470
+ /** `{number}` is replaced with the invoice number. */
1471
+ cancelNumberedTitle: string;
1472
+ cancelClose: string;
1469
1473
  cancelDescription: string;
1470
1474
  cancelConfirm: string;
1471
- cloneTitle: string;
1472
- cloneDescription: string;
1473
- cloneConfirm: string;
1475
+ cloneSuccess: string;
1476
+ cloneError: string;
1474
1477
  deleteTitle: string;
1475
1478
  deleteDescription: string;
1476
1479
  deleteConfirm: string;
@@ -1622,6 +1625,7 @@ interface ReceivableMessageLabels {
1622
1625
  actionsTitleIssued: string;
1623
1626
  actionsTitleRecurrence: string;
1624
1627
  actionsTitleDraft: string;
1628
+ actionsTitleUpdated: string;
1625
1629
  actionsSelectAll: string;
1626
1630
  actionsDeselectAll: string;
1627
1631
  actionsProductsSaved: string;
@@ -1,2 +1,4 @@
1
+ import "./lib/CounterpartsWidget/permissions.js";
1
2
  import { CounterpartsWidget as e } from "./lib/CounterpartsWidget/CounterpartsWidget.js";
2
- export { e as CounterpartsWidget };
3
+ import { CounterpartDetailsContainer as t } from "./lib/CounterpartsWidget/CounterpartDetailsContainer.js";
4
+ export { t as CounterpartDetailsContainer, e as CounterpartsWidget };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useWidgetConfig as e } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
6
+ import "../../../../../shared/feature/dist/index.js";
7
+ import { getCounterpartPermissions as t } from "./permissions.js";
8
+ import { useCounterpartDetailsSheetView as n } from "./useCounterpartDetailsSheetView.js";
9
+ import { COUNTERPART_DETAILS_SHEET_LABELS_EN as r } from "../../../../ui/dist/index2.js";
10
+ import { CounterpartDetailsSheet as i } from "../../../../ui/dist/index4.js";
11
+ import "../../../../ui/dist/index.js";
12
+ import { useMemo as a } from "react";
13
+ import { jsx as o } from "react/jsx-runtime";
14
+ //#region ../../libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsContainer.js
15
+ function s({ counterpartId: s, counterpartType: c, onClose: l, labels: u }) {
16
+ let { initResponse: d } = e(), f = t(d?.scopes).canRead, p = a(() => ({
17
+ ...r,
18
+ ...u
19
+ }), [u]), { details: m, detailsSheetView: h } = n({
20
+ selectedId: s,
21
+ isCustomer: c === "customer",
22
+ enabled: f,
23
+ detailsText: p
24
+ });
25
+ return /* @__PURE__ */ o(i, {
26
+ open: f && s !== void 0,
27
+ onOpenChange: (e) => {
28
+ e || l();
29
+ },
30
+ privacyResetKey: s,
31
+ mode: c,
32
+ counterpart: h,
33
+ isLoading: m.isLoading,
34
+ isError: m.isError,
35
+ canEdit: !1,
36
+ canDelete: !1,
37
+ onEdit: () => void 0,
38
+ onDelete: () => void 0,
39
+ onClose: l,
40
+ labels: u
41
+ });
42
+ }
43
+ //#endregion
44
+ export { s as CounterpartDetailsContainer };
@@ -0,0 +1,97 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { buildAnalyticsMap as e, formatMoney as t } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
6
+ import { useCounterpartDetails as n } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
7
+ import "../../../../../shared/counterpart-management/feature/dist/index.js";
8
+ import { PAYABLES_BILLED_STATUSES as r, PAYABLES_OWED_STATUSES as i, PAYABLES_REJECTED_STATUSES as a, RECEIVABLES_BILLED_STATUSES as o, RECEIVABLES_DUE_STATUSES as s } from "./constants.js";
9
+ import { usePayablesAnalyticsByCounterpartQuery as c, useReceivablesAnalyticsByCounterpartQuery as l } from "../../../../data-access/dist/index2.js";
10
+ import { useRecentPayablesByCounterpartQuery as u, useRecentReceivablesByCounterpartQuery as d } from "../../../../data-access/dist/index3.js";
11
+ import "../../../../data-access/dist/index.js";
12
+ import { buildPaymentMethodView as f, buildRecentDocumentRows as p, maskTaxId as m } from "./viewModels.js";
13
+ import { useMemo as h } from "react";
14
+ //#region ../../libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsSheetView.js
15
+ function g({ selectedId: g, isCustomer: _, enabled: v, detailsText: y }) {
16
+ let b = n({
17
+ selectedId: g,
18
+ enabled: v
19
+ }), x = h(() => g ? [g] : [], [g]), S = x.length > 0, C = l({
20
+ type: "invoice",
21
+ statusIn: [...o],
22
+ counterpartIdIn: x,
23
+ enabled: v && _ && S
24
+ }), w = l({
25
+ metric: "amount_due",
26
+ type: "invoice",
27
+ statusIn: [...s],
28
+ counterpartIdIn: x,
29
+ enabled: v && _ && S
30
+ }), T = c({
31
+ statusIn: [...r],
32
+ counterpartIdIn: x,
33
+ enabled: v && !_ && S
34
+ }), E = c({
35
+ metric: "amount_due",
36
+ statusIn: [...i],
37
+ counterpartIdIn: x,
38
+ enabled: v && !_ && S
39
+ }), D = c({
40
+ statusIn: [...a],
41
+ counterpartIdIn: x,
42
+ enabled: v && !_ && S
43
+ }), O = d({
44
+ counterpartId: g,
45
+ enabled: v && _ && S
46
+ }), k = u({
47
+ counterpartId: g,
48
+ enabled: v && !_ && S
49
+ });
50
+ return {
51
+ details: b,
52
+ detailsSheetView: h(() => {
53
+ if (!b.detailsView || !g) return;
54
+ let n = e(_ ? C.data?.data : T.data?.data), r = e(_ ? w.data?.data : E.data?.data), i = n.get(g) ?? 0, a = r.get(g) ?? 0, o = i - a, s = _ ? C.isLoading : T.isLoading, c = _ ? w.isLoading : E.isLoading, l = e(D.data?.data), u = _ ? 0 : l.get(g) ?? 0, d = _ ? O.data?.data : k.data?.data, h = f(b.bankAccounts?.[0], y.paymentMethodTitle), v = _ ? y.customerSubtitleLabel : y.vendorSubtitleLabel;
55
+ return {
56
+ ...b.detailsView,
57
+ subtitle: y.subtitleTemplate.replace("{type}", v).replace("{date}", b.detailsView.createdAtLabel),
58
+ entityTypeLabel: b.detailsView.entityType === "individual" ? y.entityTypePersonLabel : y.entityTypeBusinessLabel,
59
+ taxIdMasked: m(b.detailsView.taxId),
60
+ remindersLabel: b.counterpart?.reminders_enabled ? y.remindersEnabledLabel : y.remindersDisabledLabel,
61
+ summary: {
62
+ primaryAmountLabel: t(a),
63
+ billedAmountLabel: t(i),
64
+ receivedOrPaidAmountLabel: t(o),
65
+ rejectedAmountLabel: _ ? void 0 : t(u),
66
+ isPrimaryAmountLoading: c,
67
+ isBilledAmountLoading: s,
68
+ isReceivedOrPaidAmountLoading: s || c,
69
+ isRejectedAmountLoading: _ ? void 0 : D.isLoading
70
+ },
71
+ recentDocuments: p(d),
72
+ paymentMethod: h
73
+ };
74
+ }, [
75
+ b.detailsView,
76
+ b.bankAccounts,
77
+ b.counterpart?.reminders_enabled,
78
+ g,
79
+ _,
80
+ y,
81
+ C.data,
82
+ C.isLoading,
83
+ T.data,
84
+ T.isLoading,
85
+ w.data,
86
+ w.isLoading,
87
+ E.data,
88
+ E.isLoading,
89
+ D.data,
90
+ D.isLoading,
91
+ O.data,
92
+ k.data
93
+ ])
94
+ };
95
+ }
96
+ //#endregion
97
+ export { g as useCounterpartDetailsSheetView };
@@ -6,162 +6,88 @@ import { getStateOptions as e } from "../../../../../shared/util/dist/lib/usStat
6
6
  import { useWidgetConfig as t, useWidgetError as n, useWidgetLoading as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
7
7
  import "../../../../../shared/feature/dist/index.js";
8
8
  import { COUNTERPART_MESSAGE_LABELS_EN as i } from "../../../../../shared/counterpart-management/feature/dist/lib/labels.js";
9
- import { buildAnalyticsMap as a, formatMoney as o, hasSelectedText as s } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
10
- import { useAddressForm as c } from "../../../../../shared/counterpart-management/feature/dist/lib/useAddressForm.js";
11
- import { useCounterpartDetails as l } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
12
- import { useCounterpartForm as u } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
13
- import { useDeleteController as d } from "../../../../../shared/counterpart-management/feature/dist/lib/useDeleteController.js";
14
- import { useBankAccountForm as f } from "../../../../../shared/counterpart-management/feature/dist/lib/subEntityForms.js";
9
+ import { hasSelectedText as a } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
10
+ import { useAddressForm as o } from "../../../../../shared/counterpart-management/feature/dist/lib/useAddressForm.js";
11
+ import { useCounterpartForm as s } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
12
+ import { useDeleteController as c } from "../../../../../shared/counterpart-management/feature/dist/lib/useDeleteController.js";
13
+ import { useBankAccountForm as l } from "../../../../../shared/counterpart-management/feature/dist/lib/subEntityForms.js";
15
14
  import "../../../../../shared/counterpart-management/feature/dist/index.js";
16
- import { PAYABLES_BILLED_STATUSES as p, PAYABLES_OWED_STATUSES as ee, PAYABLES_REJECTED_STATUSES as te, RECEIVABLES_BILLED_STATUSES as ne, RECEIVABLES_DUE_STATUSES as re } from "./constants.js";
17
- import { usePayablesAnalyticsByCounterpartQuery as m, useReceivablesAnalyticsByCounterpartQuery as h } from "../../../../data-access/dist/index2.js";
18
- import { useRecentPayablesByCounterpartQuery as ie, useRecentReceivablesByCounterpartQuery as g } from "../../../../data-access/dist/index3.js";
19
- import "../../../../data-access/dist/index.js";
20
- import { useCounterpartsTable as ae } from "./useCounterpartsTable.js";
21
- import { getCounterpartPermissions as _ } from "./permissions.js";
22
- import { buildPaymentMethodView as v, buildRecentDocumentRows as y, maskTaxId as oe } from "./viewModels.js";
23
- import { COUNTERPART_DETAILS_SHEET_LABELS_EN as se } from "../../../../ui/dist/index2.js";
15
+ import { getCounterpartPermissions as u } from "./permissions.js";
16
+ import { useCounterpartsTable as d } from "./useCounterpartsTable.js";
17
+ import { useCounterpartDetailsSheetView as f } from "./useCounterpartDetailsSheetView.js";
18
+ import { COUNTERPART_DETAILS_SHEET_LABELS_EN as p } from "../../../../ui/dist/index2.js";
24
19
  import "../../../../ui/dist/index.js";
25
- import { useCallback as b, useEffect as x, useMemo as S, useState as C } from "react";
20
+ import { useCallback as m, useEffect as h, useMemo as g, useState as _ } from "react";
26
21
  //#region ../../libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js
27
- function w({ counterpartType: w, detailsLabels: T, messageLabels: E }) {
28
- let { initResponse: D, widgetToken: O } = t(), k = r(), A = n(), j = S(() => ({
22
+ function v({ counterpartType: v, detailsLabels: y, messageLabels: b }) {
23
+ let { initResponse: x, widgetToken: S } = t(), C = r(), w = n(), T = g(() => ({
29
24
  ...i,
30
- ...E
31
- }), [E]), M = S(() => ({
32
- ...se,
33
- ...T
34
- }), [T]), N = w === "customer", ce = S(() => e(), []), P = S(() => _(D?.scopes), [D?.scopes]), F = !(!O || D || A) || k && !D, [I, L] = C(), [R, z] = C("none"), B = P.canRead ? I : void 0;
35
- x(() => {
36
- P.canRead || (L(void 0), z("none"));
37
- }, [P.canRead]);
38
- let V = ae({
39
- isCustomer: N,
40
- enabled: P.canRead,
41
- messages: j
42
- }), H = l({
43
- selectedId: B,
44
- enabled: P.canRead
45
- }), U = S(() => B ? [B] : [], [B]), W = U.length > 0, G = h({
46
- type: "invoice",
47
- statusIn: [...ne],
48
- counterpartIdIn: U,
49
- enabled: P.canRead && N && W
50
- }), K = h({
51
- metric: "amount_due",
52
- type: "invoice",
53
- statusIn: [...re],
54
- counterpartIdIn: U,
55
- enabled: P.canRead && N && W
56
- }), q = m({
57
- statusIn: [...p],
58
- counterpartIdIn: U,
59
- enabled: P.canRead && !N && W
60
- }), J = m({
61
- metric: "amount_due",
62
- statusIn: [...ee],
63
- counterpartIdIn: U,
64
- enabled: P.canRead && !N && W
65
- }), Y = m({
66
- statusIn: [...te],
67
- counterpartIdIn: U,
68
- enabled: P.canRead && !N && W
69
- }), X = g({
70
- counterpartId: B,
71
- enabled: P.canRead && N && W
72
- }), Z = ie({
73
- counterpartId: B,
74
- enabled: P.canRead && !N && W
75
- }), Q = u({
76
- view: R,
77
- setView: z,
78
- selectedId: B,
79
- setSelectedId: L,
80
- messages: j,
81
- counterpartType: w,
82
- counterpart: H.counterpart,
83
- primaryAddress: H.primaryAddress,
84
- bankAccounts: H.bankAccounts,
85
- isBankAccountsLoading: H.isBankAccountsLoading,
86
- isBankAccountsError: H.isBankAccountsError
87
- }), le = f({
88
- items: H.bankAccounts,
89
- selectedId: B,
90
- messages: j
91
- }), $ = c({
92
- selectedId: B,
93
- primaryAddress: H.primaryAddress,
94
- messages: j
95
- }), ue = d({
96
- selectedId: B,
97
- setSelectedId: L,
98
- detailsView: H.detailsView,
99
- messages: j
25
+ ...b
26
+ }), [b]), E = g(() => ({
27
+ ...p,
28
+ ...y
29
+ }), [y]), D = v === "customer", O = g(() => e(), []), k = g(() => u(x?.scopes), [x?.scopes]), A = !(!S || x || w) || C && !x, [j, M] = _(), [N, P] = _("none"), F = k.canRead ? j : void 0;
30
+ h(() => {
31
+ k.canRead || (M(void 0), P("none"));
32
+ }, [k.canRead]);
33
+ let I = d({
34
+ isCustomer: D,
35
+ enabled: k.canRead,
36
+ messages: T
37
+ }), { details: L, detailsSheetView: R } = f({
38
+ selectedId: F,
39
+ isCustomer: D,
40
+ enabled: k.canRead,
41
+ detailsText: E
42
+ }), z = s({
43
+ view: N,
44
+ setView: P,
45
+ selectedId: F,
46
+ setSelectedId: M,
47
+ messages: T,
48
+ counterpartType: v,
49
+ counterpart: L.counterpart,
50
+ primaryAddress: L.primaryAddress,
51
+ bankAccounts: L.bankAccounts,
52
+ isBankAccountsLoading: L.isBankAccountsLoading,
53
+ isBankAccountsError: L.isBankAccountsError
54
+ }), B = l({
55
+ items: L.bankAccounts,
56
+ selectedId: F,
57
+ messages: T
58
+ }), V = o({
59
+ selectedId: F,
60
+ primaryAddress: L.primaryAddress,
61
+ messages: T
100
62
  });
101
63
  return {
102
- stateOptions: ce,
103
- selectedId: B,
104
- view: R,
105
- table: V,
106
- details: H,
107
- detailsSheetView: S(() => {
108
- if (!H.detailsView || !B) return;
109
- let e = a(N ? G.data?.data : q.data?.data), t = a(N ? K.data?.data : J.data?.data), n = e.get(B) ?? 0, r = t.get(B) ?? 0, i = n - r, s = N ? G.isLoading : q.isLoading, c = N ? K.isLoading : J.isLoading, l = a(Y.data?.data), u = N ? 0 : l.get(B) ?? 0, d = N ? X.data?.data : Z.data?.data, f = v(H.bankAccounts?.[0], M.paymentMethodTitle), p = N ? M.customerSubtitleLabel : M.vendorSubtitleLabel;
110
- return {
111
- ...H.detailsView,
112
- subtitle: M.subtitleTemplate.replace("{type}", p).replace("{date}", H.detailsView.createdAtLabel),
113
- entityTypeLabel: H.detailsView.entityType === "individual" ? M.entityTypePersonLabel : M.entityTypeBusinessLabel,
114
- taxIdMasked: oe(H.detailsView.taxId),
115
- remindersLabel: H.counterpart?.reminders_enabled ? M.remindersEnabledLabel : M.remindersDisabledLabel,
116
- summary: {
117
- primaryAmountLabel: o(r),
118
- billedAmountLabel: o(n),
119
- receivedOrPaidAmountLabel: o(i),
120
- rejectedAmountLabel: N ? void 0 : o(u),
121
- isPrimaryAmountLoading: c,
122
- isBilledAmountLoading: s,
123
- isReceivedOrPaidAmountLoading: s || c,
124
- isRejectedAmountLoading: N ? void 0 : Y.isLoading
125
- },
126
- recentDocuments: y(d),
127
- paymentMethod: f
128
- };
129
- }, [
130
- H.detailsView,
131
- H.bankAccounts,
132
- H.counterpart?.reminders_enabled,
133
- B,
134
- N,
135
- M,
136
- G.data,
137
- G.isLoading,
138
- q.data,
139
- q.isLoading,
140
- K.data,
141
- K.isLoading,
142
- J.data,
143
- J.isLoading,
144
- Y.data,
145
- Y.isLoading,
146
- X.data,
147
- Z.data
148
- ]),
149
- permissions: P,
150
- isPermissionLoading: F,
151
- form: Q,
152
- bank: le,
153
- address: $,
154
- del: ue,
155
- handleRowClick: b((e) => {
156
- P.canRead && !s() && ($.close(), L(e.id), z("none"));
157
- }, [P.canRead, $.close]),
158
- closeDetails: b(() => {
159
- $.close(), L(void 0);
160
- }, [$.close]),
161
- handleEditProfile: b(() => {
162
- $.close(), Q.openEdit();
163
- }, [$.close, Q.openEdit])
64
+ stateOptions: O,
65
+ selectedId: F,
66
+ view: N,
67
+ table: I,
68
+ details: L,
69
+ detailsSheetView: R,
70
+ permissions: k,
71
+ isPermissionLoading: A,
72
+ form: z,
73
+ bank: B,
74
+ address: V,
75
+ del: c({
76
+ selectedId: F,
77
+ setSelectedId: M,
78
+ detailsView: L.detailsView,
79
+ messages: T
80
+ }),
81
+ handleRowClick: m((e) => {
82
+ k.canRead && !a() && (V.close(), M(e.id), P("none"));
83
+ }, [k.canRead, V.close]),
84
+ closeDetails: m(() => {
85
+ V.close(), M(void 0);
86
+ }, [V.close]),
87
+ handleEditProfile: m(() => {
88
+ V.close(), z.openEdit();
89
+ }, [V.close, z.openEdit])
164
90
  };
165
91
  }
166
92
  //#endregion
167
- export { w as useCounterpartsWidget };
93
+ export { v as useCounterpartsWidget };