@tesouro/embedded-components-react 0.5.225 → 0.5.227

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 (142) hide show
  1. package/README.md +21 -21
  2. package/dist/index.d.ts +23 -2
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +23 -2
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index3.js +41 -39
  7. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index12.js +2 -2
  8. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/data-access/dist/index2.js +2 -2
  9. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/data-access/dist/index3.js +2 -2
  10. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/data-access/dist/index4.js +2 -2
  11. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index9.js +150 -147
  12. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/data-access/dist/index5.js +46 -51
  13. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index7.js +130 -128
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index18.js +31 -32
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index19.js +2 -2
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index2.js +2 -2
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index21.js +2 -2
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index22.js +2 -2
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index3.js +2 -2
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index4.js +36 -37
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/data-access/dist/index2.js +2 -2
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/feature/dist/index4.js +2 -2
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index2.js +6 -10
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index3.js +2 -2
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index4.js +2 -2
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index5.js +2 -2
  27. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index6.js +2 -2
  28. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index7.js +2 -2
  29. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index8.js +2 -2
  30. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index13.js +154 -150
  31. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/data-access/dist/index7.js +2 -2
  32. package/dist/libs/tesouro-embedded-components-react/cards-widget/data-access/dist/index2.js +2 -2
  33. package/dist/libs/tesouro-embedded-components-react/cards-widget/data-access/dist/index3.js +2 -2
  34. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +151 -149
  35. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/data-access/dist/index2.js +4 -4
  36. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/data-access/dist/index3.js +4 -4
  37. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index15.js +2 -2
  38. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index17.js +2 -2
  39. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index18.js +2 -2
  40. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index19.js +2 -2
  41. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index2.js +2 -2
  42. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index3.js +2 -2
  43. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index4.js +2 -2
  44. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index5.js +2 -2
  45. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index6.js +2 -2
  46. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index8.js +2 -2
  47. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index9.js +2 -2
  48. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index24.js +1 -0
  49. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index27.js +89 -87
  50. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index5.js +133 -130
  51. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index8.js +36 -34
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +4 -4
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +50 -36
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +6 -6
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +2 -2
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +40 -39
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +51 -32
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +20 -1
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +17 -202
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +220 -31
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +32 -145
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +126 -44
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +145 -117
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +46 -58
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +113 -87
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +58 -116
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +98 -225
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +111 -27
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +225 -462
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +34 -41
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +627 -34
  73. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +39 -77
  74. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +34 -112
  75. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +75 -310
  76. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +124 -0
  77. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +324 -0
  78. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +20 -15
  79. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +56 -53
  80. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +33 -29
  81. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +184 -162
  82. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +1 -3
  83. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +78 -69
  84. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/data-access/dist/index4.js +2 -2
  85. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index9.js +209 -207
  86. package/dist/libs/tesouro-embedded-components-react/remote-check-capture/data-access/dist/index4.js +10 -5
  87. package/dist/libs/tesouro-embedded-components-react/remote-check-capture/data-access/dist/index5.js +10 -5
  88. package/dist/libs/tesouro-embedded-components-react/remote-check-capture/data-access/dist/index6.js +11 -6
  89. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index2.js +2 -2
  90. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index3.js +2 -2
  91. package/dist/libs/tesouro-embedded-components-react/settings-widget/profile/data-access/dist/index2.js +2 -2
  92. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index12.js +2 -2
  93. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index13.js +2 -2
  94. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index14.js +30 -28
  95. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index17.js +28 -26
  96. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index18.js +37 -34
  97. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index21.js +28 -26
  98. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index22.js +37 -34
  99. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index17.js +294 -292
  100. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index5.js +58 -58
  101. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/data-access/dist/lib/approvalPoliciesApi.js +47 -48
  102. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index3.js +4 -4
  103. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index5.js +2 -2
  104. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index7.js +4 -4
  105. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/CounterpartSelector.js +7 -6
  106. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +20 -19
  107. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -39
  108. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/EmbedApiContext.js +14 -13
  109. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/allPages.js +1 -1
  110. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/applicationStatusQueryOptions.js +16 -15
  111. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js +7 -5
  112. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/debit-card/useAllDebitCardsQuery.js +7 -5
  113. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/disclosures/useDisclosuresQuery.js +2 -2
  114. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/external-bank-account/useAllExternalBankAccountsQuery.js +7 -5
  115. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/merchant-category-group/useAllMerchantCategoryGroupsQuery.js +28 -29
  116. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/organizationStatus.js +10 -0
  117. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/reference-data/useLedgerAccountsQuery.js +26 -27
  118. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js +2 -2
  119. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +210 -199
  120. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +60 -52
  121. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js +31 -32
  122. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/role/useRolePermissionsQueries.js +2 -2
  123. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useCurrentUserQuery.js +2 -2
  124. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useGetUserDataQuery.js +2 -2
  125. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useMailboxAddress.js +2 -2
  126. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useMyEntityQuery.js +2 -2
  127. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js +33 -34
  128. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/withAuthEpoch.js +33 -22
  129. package/dist/libs/tesouro-embedded-components-react/shared/expense-requirements/data-access/dist/index3.js +2 -2
  130. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/RootWidgetProvider.js +43 -32
  131. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/WidgetProvider.js +138 -127
  132. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/deriveOrganizationStatus.js +6 -0
  133. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/useWidgetFetch.js +1 -1
  134. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  135. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index10.js +2 -2
  136. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index2.js +2 -2
  137. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index3.js +2 -2
  138. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index4.js +2 -2
  139. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index9.js +2 -2
  140. package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index6.js +2 -2
  141. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index6.js +60 -58
  142. package/package.json +1 -1
@@ -2,212 +2,27 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
7
- import "../../../shared/ui/dist/index.js";
8
- import { useCounterpartQuery as n } from "../../../shared/counterpart-management/data-access/dist/index3.js";
5
+ import { useMyEntityQuery as e } from "../../../shared/data-access/dist/lib/useMyEntityQuery.js";
6
+ import "../../../shared/data-access/dist/index.js";
7
+ import { useCounterpartQuery as t } from "../../../shared/counterpart-management/data-access/dist/index3.js";
9
8
  import "../../../shared/counterpart-management/feature/dist/index.js";
10
- import { defaultPaymentValues as r, defaultSendValues as i, fromMajorUnits as a, hasPaymentErrors as o, hasSendErrors as s, splitEmailList as c, validatePaymentValues as l, validateSendValues as ee } from "./index12.js";
11
- import { getIssueReminderBlocker as te, hasSelectedReminder as u } from "./index14.js";
12
- import { useSendReceivableEmailMutation as d } from "../../data-access/dist/index5.js";
13
- import { useAcceptReceivableMutation as f, useCancelReceivableMutation as p, useCloneReceivableMutation as m, useDeclineReceivableMutation as ne, useDeleteReceivableMutation as re, useIssueReceivableMutation as ie } from "../../data-access/dist/index7.js";
14
- import { useMarkReceivablePaidMutation as h, useMarkReceivablePartiallyPaidMutation as g, useMarkReceivableUncollectibleMutation as _ } from "../../data-access/dist/index9.js";
9
+ import { useReceivableRequiredFieldsQuery as n } from "../../data-access/dist/index10.js";
15
10
  import "../../data-access/dist/index.js";
16
- import { useCallback as v, useState as y } from "react";
17
11
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js
18
- function b({ selectedReceivable: b, messages: S, onCreated: C, onDeleted: w }) {
19
- let T = ie(), E = p(), D = m(), O = f(), k = ne(), A = re(), j = d(), M = h(), N = g(), P = _(), [F, I] = y(), [ae, L] = y(), [R, z] = y(), [B, V] = y(() => i(void 0, S)), [H, U] = y({}), [W, G] = y(), [K, q] = y(() => r()), [J, Y] = y({}), X = n(F?.reminderCounterpartId), Z = !!F?.reminderCounterpartId && X.isLoading, oe = v((e, t, n) => {
20
- let a = "documentLabel" in t ? t.documentLabel : t.title, o = {
21
- id: t.id,
22
- type: t.type,
23
- title: a,
24
- action: e
25
- }, s = n === void 0 ? b : n ?? void 0;
26
- if (e === "send") {
27
- z(o), V(i(s, S)), U({});
28
- return;
29
- }
30
- if (e === "recordPayment") {
31
- G({
32
- ...o,
33
- currency: s?.currency
34
- }), q(r()), Y({});
35
- return;
36
- }
37
- L(void 0), I({
38
- ...o,
39
- reminderCounterpartId: e === "issue" && s && u(s) ? s.counterpart_id : void 0
40
- });
41
- }, [S, b]), se = v(() => {
42
- I(void 0), L(void 0);
43
- }, []), Q = v(() => {
44
- z(void 0), U({});
45
- }, []), $ = v(() => {
46
- G(void 0), Y({});
47
- }, []), ce = v(async () => {
48
- if (!F) return;
49
- let n = { receivable_id: F.id };
50
- if (F.reminderCounterpartId) {
51
- if (Z) return;
52
- let t = te(X.data, S);
53
- if (t) {
54
- e.error(t), I(void 0);
55
- return;
56
- }
57
- }
58
- try {
59
- if (F.action === "issue") await T.mutateAsync({ path: n });
60
- else if (F.action === "cancel") await E.mutateAsync({ path: n });
61
- else if (F.action === "clone") {
62
- let e = await D.mutateAsync({ path: n });
63
- e?.id && C?.(e.id, e.type);
64
- } else F.action === "accept" ? await O.mutateAsync({ path: n }) : F.action === "decline" ? await k.mutateAsync({ path: n }) : F.action === "delete" ? (await A.mutateAsync({ path: n }), w?.(F.id)) : F.action === "markPaid" ? await M.mutateAsync({
65
- path: n,
66
- body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
67
- }) : F.action === "markUncollectible" && await P.mutateAsync({ path: n });
68
- I(void 0), L(void 0);
69
- } catch (e) {
70
- L(t(e) ?? S.genericError);
71
- }
72
- }, [
73
- O,
74
- F,
75
- E,
76
- D,
77
- k,
78
- A,
79
- Z,
80
- T,
81
- M,
82
- S,
83
- C,
84
- w,
85
- X.data,
86
- P
87
- ]), le = v(async () => {
88
- if (!R) return;
89
- let e = ee(B, S);
90
- if (s(e)) {
91
- U(e);
92
- return;
93
- }
94
- try {
95
- await j.mutateAsync({
96
- path: { receivable_id: R.id },
97
- body: {
98
- body_text: B.body,
99
- subject_text: B.subject,
100
- recipients: {
101
- to: c(B.to),
102
- cc: c(B.cc),
103
- bcc: c(B.bcc)
104
- }
105
- }
106
- }), Q();
107
- } catch (e) {
108
- U({ form: t(e) ?? S.genericError });
109
- }
110
- }, [
111
- Q,
112
- S,
113
- j,
114
- R,
115
- B
116
- ]), ue = v(async () => {
117
- if (!W) return;
118
- let e = l(K, S, W.currency);
119
- if (o(e)) {
120
- Y(e);
121
- return;
122
- }
123
- try {
124
- let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
125
- K.mode === "full" ? await M.mutateAsync({
126
- path: e,
127
- body: {
128
- comment: K.comment || void 0,
129
- paid_at: t
130
- }
131
- }) : await N.mutateAsync({
132
- path: e,
133
- body: {
134
- amount_paid: a(K.amountPaid, W.currency) ?? 0,
135
- comment: K.comment || void 0
136
- }
137
- }), $();
138
- } catch (e) {
139
- Y({ form: t(e) ?? S.genericError });
140
- }
141
- }, [
142
- $,
143
- M,
144
- S,
145
- N,
146
- W,
147
- K
148
- ]);
12
+ function r({ counterpartId: r, billingAddressId: i, billingCountry: a }) {
13
+ let o = e(), s = t(r || void 0), c = s.data?.id === r ? s.data : void 0, l = n({
14
+ counterpart_id: r || void 0,
15
+ counterpart_billing_address_id: i || void 0,
16
+ counterpart_country: a,
17
+ counterpart_type: c?.type,
18
+ enabled: !!(r && i)
19
+ }), u = !!l.data?.entity?.tax_id?.required;
149
20
  return {
150
- actionTarget: F,
151
- actionDialog: F ? x(F.action, S) : void 0,
152
- actionError: ae,
153
- actionInProgress: Z || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || A.isPending || M.isPending || P.isPending,
154
- openAction: oe,
155
- closeAction: se,
156
- confirmAction: ce,
157
- sendOpen: !!R,
158
- sendValues: B,
159
- sendErrors: H,
160
- sendInProgress: j.isPending,
161
- setSendValues: V,
162
- closeSend: Q,
163
- submitSend: le,
164
- paymentOpen: !!W,
165
- paymentValues: K,
166
- paymentErrors: J,
167
- paymentInProgress: M.isPending || N.isPending,
168
- setPaymentValues: q,
169
- closePayment: $,
170
- submitPayment: ue
171
- };
172
- }
173
- function x(e, t) {
174
- return e === "issue" ? {
175
- title: t.issueTitle,
176
- description: t.issueDescription,
177
- confirmLabel: t.issueConfirm
178
- } : e === "accept" ? {
179
- title: t.acceptTitle,
180
- description: t.acceptDescription,
181
- confirmLabel: t.acceptConfirm
182
- } : e === "decline" ? {
183
- title: t.declineTitle,
184
- description: t.declineDescription,
185
- confirmLabel: t.declineConfirm,
186
- destructive: !0
187
- } : e === "cancel" ? {
188
- title: t.cancelTitle,
189
- description: t.cancelDescription,
190
- confirmLabel: t.cancelConfirm,
191
- destructive: !0
192
- } : e === "clone" ? {
193
- title: t.cloneTitle,
194
- description: t.cloneDescription,
195
- confirmLabel: t.cloneConfirm
196
- } : e === "delete" ? {
197
- title: t.deleteTitle,
198
- description: t.deleteDescription,
199
- confirmLabel: t.deleteConfirm,
200
- destructive: !0
201
- } : e === "markPaid" ? {
202
- title: t.markPaidTitle,
203
- description: t.markPaidDescription,
204
- confirmLabel: t.markPaidConfirm
205
- } : {
206
- title: t.markUncollectibleTitle,
207
- description: t.markUncollectibleDescription,
208
- confirmLabel: t.markUncollectibleConfirm,
209
- destructive: !0
21
+ counterpart: c,
22
+ isCounterpartLoading: !!r && (s.isLoading || s.isFetching),
23
+ isLoading: o.isLoading || o.isFetching || l.isLoading || l.isFetching || !!r && (s.isLoading || s.isFetching),
24
+ isTaxIdMissing: u && !o.data?.tax_id
210
25
  };
211
26
  }
212
27
  //#endregion
213
- export { b as useReceivableActions };
28
+ export { r as useReceivableIssuePreflight };
@@ -2,41 +2,230 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { buildReceivableDetailsView as e } from "./index12.js";
6
- import { useReceivableHistoryQuery as t, useReceivableMailsQuery as n, useReceivablePdfLinkQuery as r, useReceivableQuery as i } from "../../data-access/dist/index10.js";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
7
+ import "../../../shared/ui/dist/index.js";
8
+ import { defaultPaymentValues as n, defaultSendValues as r, fromMajorUnits as i, hasPaymentErrors as a, hasSendErrors as o, isReceivableReadyToIssue as s, splitEmailList as c, validatePaymentValues as l, validateSendValues as u } from "./index12.js";
9
+ import { getIssueReminderBlocker as d, hasSelectedReminder as ee } from "./index14.js";
10
+ import { useSendReceivableEmailMutation as te } from "../../data-access/dist/index5.js";
11
+ import { useAcceptReceivableMutation as f, useCancelReceivableMutation as p, useCloneReceivableMutation as m, useDeclineReceivableMutation as h, useDeleteReceivableMutation as ne, useIssueReceivableMutation as re } from "../../data-access/dist/index7.js";
12
+ import { useMarkReceivablePaidMutation as ie, useMarkReceivablePartiallyPaidMutation as ae, useMarkReceivableUncollectibleMutation as oe } from "../../data-access/dist/index9.js";
7
13
  import "../../data-access/dist/index.js";
8
- import { useMemo as a } from "react";
14
+ import { useReceivableIssuePreflight as g } from "./index15.js";
15
+ import { useCallback as _, useState as v } from "react";
9
16
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js
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
17
+ function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C, onCompleteBeforeIssue: w }) {
18
+ let T = re(), E = p(), D = m(), O = f(), k = h(), A = ne(), j = te(), M = ie(), N = ae(), P = oe(), [F, I] = v(), [se, L] = v(), [R, z] = v(), [B, V] = v(() => r(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => n()), [ce, J] = v({}), Y = F?.issueCheck, X = g({
19
+ counterpartId: Y?.counterpartId,
20
+ billingAddressId: Y?.billingAddressId,
21
+ billingCountry: Y?.billingCountry
22
+ }), Z = !!Y && X.isLoading, le = _((e, t, i) => {
23
+ let a = "documentLabel" in t ? t.documentLabel : t.title, o = {
24
+ id: t.id,
25
+ type: t.type,
26
+ title: a,
27
+ action: e
28
+ }, c = i === void 0 ? y : i ?? void 0;
29
+ if (e === "send") {
30
+ z(o), V(r(c, x)), U({});
31
+ return;
32
+ }
33
+ if (e === "recordPayment") {
34
+ G({
35
+ ...o,
36
+ currency: c?.currency
37
+ }), q(n()), J({});
38
+ return;
39
+ }
40
+ let l = e === "issue" && c?.type === "invoice" ? c : void 0;
41
+ if (l && w && !s(l, x)) {
42
+ w(l);
43
+ return;
44
+ }
45
+ L(void 0), I({
46
+ ...o,
47
+ issueCheck: l ? {
48
+ counterpartId: l.counterpart_id,
49
+ billingAddressId: l.counterpart_billing_address?.id ?? void 0,
50
+ billingCountry: l.counterpart_billing_address?.country,
51
+ hasReminder: ee(l)
52
+ } : void 0
53
+ });
54
+ }, [
55
+ x,
56
+ w,
57
+ y
58
+ ]), ue = _(() => {
59
+ I(void 0), L(void 0);
60
+ }, []), Q = _(() => {
61
+ z(void 0), U({});
62
+ }, []), $ = _(() => {
63
+ G(void 0), J({});
64
+ }, []), de = _(async () => {
65
+ if (!F) return;
66
+ let n = { receivable_id: F.id };
67
+ if (F.issueCheck) {
68
+ if (Z) return;
69
+ let t = X.isTaxIdMissing ? x.issueTaxIdRequired : F.issueCheck.hasReminder ? d(X.counterpart, x) : void 0;
70
+ if (t) {
71
+ e.error(t), I(void 0);
72
+ return;
73
+ }
74
+ }
75
+ try {
76
+ if (F.action === "issue") await T.mutateAsync({ path: n });
77
+ else if (F.action === "cancel") await E.mutateAsync({ path: n });
78
+ else if (F.action === "clone") {
79
+ let e = await D.mutateAsync({ path: n });
80
+ e?.id && S?.(e.id, e.type);
81
+ } else F.action === "accept" ? await O.mutateAsync({ path: n }) : F.action === "decline" ? await k.mutateAsync({ path: n }) : F.action === "delete" ? (await A.mutateAsync({ path: n }), C?.(F.id)) : F.action === "markPaid" ? await M.mutateAsync({
82
+ path: n,
83
+ body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
84
+ }) : F.action === "markUncollectible" && await P.mutateAsync({ path: n });
85
+ I(void 0), L(void 0);
86
+ } catch (e) {
87
+ L(t(e) ?? x.genericError);
88
+ }
89
+ }, [
90
+ O,
91
+ F,
92
+ E,
93
+ D,
94
+ k,
95
+ A,
96
+ Z,
97
+ T,
98
+ M,
99
+ x,
100
+ S,
101
+ C,
102
+ X.counterpart,
103
+ X.isTaxIdMissing,
104
+ P
105
+ ]), fe = _(async () => {
106
+ if (!R) return;
107
+ let e = u(B, x);
108
+ if (o(e)) {
109
+ U(e);
110
+ return;
111
+ }
112
+ try {
113
+ await j.mutateAsync({
114
+ path: { receivable_id: R.id },
115
+ body: {
116
+ body_text: B.body,
117
+ subject_text: B.subject,
118
+ recipients: {
119
+ to: c(B.to),
120
+ cc: c(B.cc),
121
+ bcc: c(B.bcc)
122
+ }
123
+ }
124
+ }), Q();
125
+ } catch (e) {
126
+ U({ form: t(e) ?? x.genericError });
127
+ }
128
+ }, [
129
+ Q,
130
+ x,
131
+ j,
132
+ R,
133
+ B
134
+ ]), pe = _(async () => {
135
+ if (!W) return;
136
+ let e = l(K, x, W.currency);
137
+ if (a(e)) {
138
+ J(e);
139
+ return;
140
+ }
141
+ try {
142
+ let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
143
+ K.mode === "full" ? await M.mutateAsync({
144
+ path: e,
145
+ body: {
146
+ comment: K.comment || void 0,
147
+ paid_at: t
148
+ }
149
+ }) : await N.mutateAsync({
150
+ path: e,
151
+ body: {
152
+ amount_paid: i(K.amountPaid, W.currency) ?? 0,
153
+ comment: K.comment || void 0
154
+ }
155
+ }), $();
156
+ } catch (e) {
157
+ J({ form: t(e) ?? x.genericError });
158
+ }
159
+ }, [
160
+ $,
161
+ M,
162
+ x,
163
+ N,
164
+ W,
165
+ K
33
166
  ]);
34
167
  return {
35
- receivable: l.data,
36
- detailsView: p,
37
- isLoading: l.isLoading || u.isLoading || d.isLoading || f.isLoading,
38
- isError: l.isError
168
+ actionTarget: F,
169
+ actionDialog: F ? b(F.action, x) : void 0,
170
+ actionError: se,
171
+ actionInProgress: Z || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || A.isPending || M.isPending || P.isPending,
172
+ openAction: le,
173
+ closeAction: ue,
174
+ confirmAction: de,
175
+ sendOpen: !!R,
176
+ sendValues: B,
177
+ sendErrors: H,
178
+ sendInProgress: j.isPending,
179
+ setSendValues: V,
180
+ closeSend: Q,
181
+ submitSend: fe,
182
+ paymentOpen: !!W,
183
+ paymentValues: K,
184
+ paymentErrors: ce,
185
+ paymentInProgress: M.isPending || N.isPending,
186
+ setPaymentValues: q,
187
+ closePayment: $,
188
+ submitPayment: pe
189
+ };
190
+ }
191
+ function b(e, t) {
192
+ return e === "issue" ? {
193
+ title: t.issueTitle,
194
+ description: t.issueDescription,
195
+ confirmLabel: t.issueConfirm
196
+ } : e === "accept" ? {
197
+ title: t.acceptTitle,
198
+ description: t.acceptDescription,
199
+ confirmLabel: t.acceptConfirm
200
+ } : e === "decline" ? {
201
+ title: t.declineTitle,
202
+ description: t.declineDescription,
203
+ confirmLabel: t.declineConfirm,
204
+ destructive: !0
205
+ } : e === "cancel" ? {
206
+ title: t.cancelTitle,
207
+ description: t.cancelDescription,
208
+ confirmLabel: t.cancelConfirm,
209
+ destructive: !0
210
+ } : e === "clone" ? {
211
+ title: t.cloneTitle,
212
+ description: t.cloneDescription,
213
+ confirmLabel: t.cloneConfirm
214
+ } : e === "delete" ? {
215
+ title: t.deleteTitle,
216
+ description: t.deleteDescription,
217
+ confirmLabel: t.deleteConfirm,
218
+ destructive: !0
219
+ } : e === "markPaid" ? {
220
+ title: t.markPaidTitle,
221
+ description: t.markPaidDescription,
222
+ confirmLabel: t.markPaidConfirm
223
+ } : {
224
+ title: t.markUncollectibleTitle,
225
+ description: t.markUncollectibleDescription,
226
+ confirmLabel: t.markUncollectibleConfirm,
227
+ destructive: !0
39
228
  };
40
229
  }
41
230
  //#endregion
42
- export { o as useReceivableDetails };
231
+ export { y as useReceivableActions };
@@ -2,154 +2,41 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { toFileArray as e, validateAttachmentFile as t } from "./index7.js";
6
- import { useDeleteReceivableAttachmentMutation as n, useUploadReceivableAttachmentMutation as r } from "../../data-access/dist/index4.js";
5
+ import { buildReceivableDetailsView as e } from "./index12.js";
6
+ import { useReceivableHistoryQuery as t, useReceivableMailsQuery as n, useReceivablePdfLinkQuery as r, useReceivableQuery as i } from "../../data-access/dist/index10.js";
7
7
  import "../../data-access/dist/index.js";
8
- import { useCallback as i, useEffect as a, useRef 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/index17.js
10
- function c({ attachments: c, setAttachments: l, receivableId: u }) {
11
- let { mutateAsync: d } = r(), { mutate: f } = n(), [p, m] = s([]), [h, g] = s(!1), _ = o(0), v = o(/* @__PURE__ */ new Set()), y = o(/* @__PURE__ */ new Set()), b = o(/* @__PURE__ */ new Set()), x = o(0), S = o(!1), C = o({
12
- deleteFile: f,
13
- receivableId: u
14
- });
15
- a(() => {
16
- C.current = {
17
- deleteFile: f,
18
- receivableId: u
19
- };
20
- }, [f, u]), a(() => {
21
- S.current = !1;
22
- let e = y.current;
23
- return () => {
24
- S.current = !0;
25
- let { deleteFile: t, receivableId: n } = C.current;
26
- for (let r of e) t({
27
- path: { file_id: r },
28
- receivableId: n
29
- });
30
- e.clear();
31
- };
32
- }, []);
33
- let w = i(async (e, t) => {
34
- let n = x.current, r = () => S.current || x.current !== n;
35
- try {
36
- let n = await d({
37
- file: t,
38
- receivableId: u
39
- });
40
- if (r() || v.current.delete(e)) {
41
- f({
42
- path: { file_id: n.id },
43
- receivableId: u
44
- });
45
- return;
46
- }
47
- y.current.add(n.id), m((t) => t.filter((t) => t.id !== e)), l((e) => [...e, {
48
- id: n.id,
49
- includeInEmail: !0,
50
- name: n.name,
51
- size: n.size
52
- }]);
53
- } catch {
54
- let t = v.current.delete(e);
55
- if (r() || t) return;
56
- m((t) => t.map((t) => t.id === e ? {
57
- ...t,
58
- status: "upload_failed"
59
- } : t));
60
- }
61
- }, [
62
- f,
63
- u,
64
- l,
65
- d
66
- ]), T = i((n) => {
67
- let r = e(n);
68
- if (r.length === 0) return;
69
- let i = p.filter((e) => e.status === "uploading").length, a = 10 - c.length - i, o = [], s = !1;
70
- for (let e of r) {
71
- _.current += 1;
72
- let n = `pending-attachment-${_.current}`, r = t(e);
73
- if (r) {
74
- o.push({
75
- id: n,
76
- name: e.name,
77
- status: r
78
- });
79
- continue;
80
- }
81
- if (a <= 0) {
82
- s = !0;
83
- continue;
84
- }
85
- --a, o.push({
86
- id: n,
87
- name: e.name,
88
- status: "uploading"
89
- }), w(n, e);
90
- }
91
- o.length > 0 && m((e) => [...e, ...o]), g(s);
92
- }, [
93
- c.length,
94
- p,
95
- w
96
- ]), E = i((e, t) => {
97
- l((n) => n.map((n) => n.id === e ? {
98
- ...n,
99
- includeInEmail: t
100
- } : n));
101
- }, [l]), D = i((e) => {
102
- g(!1);
103
- let t = p.find((t) => t.id === e);
104
- if (t) {
105
- t.status === "uploading" && v.current.add(e), m((t) => t.filter((t) => t.id !== e));
106
- return;
107
- }
108
- if (l((t) => t.filter((t) => t.id !== e)), !y.current.delete(e)) {
109
- b.current.add(e);
110
- return;
111
- }
112
- f({
113
- path: { file_id: e },
114
- receivableId: u
115
- });
116
- }, [
117
- f,
118
- p,
119
- u,
120
- l
121
- ]), O = i(() => {
122
- x.current += 1, v.current.clear(), y.current.clear(), b.current.clear(), m([]), g(!1);
123
- }, []), k = i(() => {
124
- let e = new Set(y.current);
125
- for (let t of e) f({
126
- path: { file_id: t },
127
- receivableId: u
128
- });
129
- l((t) => t.filter(({ id: t }) => !e.has(t))), O();
130
- }, [
131
- f,
132
- u,
133
- O,
134
- l
135
- ]), A = i(() => {
136
- for (let e of b.current) f({
137
- path: { file_id: e },
138
- receivableId: u
139
- });
140
- b.current.clear();
141
- }, [f, u]);
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
+ ]);
142
34
  return {
143
- pendingUploads: p,
144
- isUploading: p.some((e) => e.status === "uploading"),
145
- isCountLimitReached: h,
146
- selectFiles: T,
147
- setIncludeInEmail: E,
148
- remove: D,
149
- reset: O,
150
- discardUploads: k,
151
- commitRemovals: A
35
+ receivable: l.data,
36
+ detailsView: p,
37
+ isLoading: l.isLoading || u.isLoading || d.isLoading || f.isLoading,
38
+ isError: l.isError
152
39
  };
153
40
  }
154
41
  //#endregion
155
- export { c as useReceivableAttachmentUploads };
42
+ export { o as useReceivableDetails };