@tesouro/embedded-components-react 0.5.205 → 0.5.206

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 (48) hide show
  1. package/dist/index.d.ts +11 -4
  2. package/dist/index.js +1 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +11 -4
  4. package/dist/lib/ReceivablesWidget.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +88 -193
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +184 -31
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +32 -145
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +150 -58
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +35 -89
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +53 -42
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +82 -299
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +47 -70
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +321 -100
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +68 -246
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +115 -0
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +270 -0
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +93 -407
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +422 -86
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +16 -12
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +92 -16
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +3 -1
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +24 -4
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +0 -10
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +2 -0
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +3 -264
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +16 -70
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +1 -424
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +4 -106
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +12 -93
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +5 -179
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +1 -344
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +264 -0
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +72 -0
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +401 -0
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +106 -0
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +93 -0
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +344 -0
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +182 -32
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +29 -202
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +183 -137
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +157 -20
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +16 -1
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +25 -3
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +4 -3
  47. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  48. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4824,6 +4824,15 @@ interface ProductMessageLabels {
4824
4824
  updateMeasureUnitError: string;
4825
4825
  }
4826
4826
 
4827
+ interface ReceivableBillingSectionLabels {
4828
+ billingHeading: string;
4829
+ billingDescription: string;
4830
+ paymentTermsLabel: string;
4831
+ paymentTermsPlaceholder: string;
4832
+ paymentTermsReceiptDue: string;
4833
+ paymentTermsCustomDate: string;
4834
+ }
4835
+
4827
4836
  interface ReceivableStatusBadgeLabels {
4828
4837
  draft: string;
4829
4838
  issuing: string;
@@ -4893,7 +4902,7 @@ interface ReceivablesScreenLabels {
4893
4902
  type ReceivablesScreenLabelOverrides = Partial<Omit<ReceivablesScreenLabels, 'statusBadge'>> & {
4894
4903
  statusBadge?: Partial<ReceivableStatusBadgeLabels>;
4895
4904
  };
4896
- interface ReceivableFormSheetLabels {
4905
+ interface ReceivableFormSheetLabels extends ReceivableBillingSectionLabels {
4897
4906
  createTitle: string;
4898
4907
  editTitle: string;
4899
4908
  hiddenDescription: string;
@@ -4905,9 +4914,6 @@ interface ReceivableFormSheetLabels {
4905
4914
  currencyLabel: string;
4906
4915
  issueDateLabel: string;
4907
4916
  dueDateLabel: string;
4908
- paymentTermsLabel: string;
4909
- paymentTermsPlaceholder: string;
4910
- paymentTermsNone: string;
4911
4917
  lineItemsHeading: string;
4912
4918
  lineItemsDescription: string;
4913
4919
  productLabel: string;
@@ -5040,6 +5046,7 @@ interface ReceivableMessageLabels {
5040
5046
  paymentAmountInvalid: string;
5041
5047
  genericError: string;
5042
5048
  lineItemsLoading: string;
5049
+ paymentTermsCustomDatePlaceholder: string;
5043
5050
  bankAccountFallbackName: string;
5044
5051
  /** `{embeddedBankName}` is replaced with the host's bank name. */
5045
5052
  bankAccountPoweredBy: string;
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import { InsightsWidget as L } from "./libs/tesouro-embedded-components-react/in
27
27
  import { UploadReceiptWidget as R } from "./libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index2.js";
28
28
  import { ExpenseManagementWidget as z } from "./libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index21.js";
29
29
  import { InvoicingWidget as B } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index3.js";
30
- import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js";
30
+ import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js";
31
31
  import { SettingsSection as H } from "./libs/tesouro-embedded-components-react/settings-widget/feature/dist/index4.js";
32
32
  import { HELP_FAQ_EN as U } from "./libs/tesouro-embedded-components-react/settings-widget/help/ui/contract/dist/index3.js";
33
33
  import { SettingsWidget as W } from "./libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js";
@@ -868,6 +868,15 @@ interface ProductMessageLabels {
868
868
  updateMeasureUnitError: string;
869
869
  }
870
870
 
871
+ interface ReceivableBillingSectionLabels {
872
+ billingHeading: string;
873
+ billingDescription: string;
874
+ paymentTermsLabel: string;
875
+ paymentTermsPlaceholder: string;
876
+ paymentTermsReceiptDue: string;
877
+ paymentTermsCustomDate: string;
878
+ }
879
+
871
880
  interface ReceivableStatusBadgeLabels {
872
881
  draft: string;
873
882
  issuing: string;
@@ -937,7 +946,7 @@ interface ReceivablesScreenLabels {
937
946
  type ReceivablesScreenLabelOverrides = Partial<Omit<ReceivablesScreenLabels, 'statusBadge'>> & {
938
947
  statusBadge?: Partial<ReceivableStatusBadgeLabels>;
939
948
  };
940
- interface ReceivableFormSheetLabels {
949
+ interface ReceivableFormSheetLabels extends ReceivableBillingSectionLabels {
941
950
  createTitle: string;
942
951
  editTitle: string;
943
952
  hiddenDescription: string;
@@ -949,9 +958,6 @@ interface ReceivableFormSheetLabels {
949
958
  currencyLabel: string;
950
959
  issueDateLabel: string;
951
960
  dueDateLabel: string;
952
- paymentTermsLabel: string;
953
- paymentTermsPlaceholder: string;
954
- paymentTermsNone: string;
955
961
  lineItemsHeading: string;
956
962
  lineItemsDescription: string;
957
963
  productLabel: string;
@@ -1084,6 +1090,7 @@ interface ReceivableMessageLabels {
1084
1090
  paymentAmountInvalid: string;
1085
1091
  genericError: string;
1086
1092
  lineItemsLoading: string;
1093
+ paymentTermsCustomDatePlaceholder: string;
1087
1094
  bankAccountFallbackName: string;
1088
1095
  /** `{embeddedBankName}` is replaced with the host's bank name. */
1089
1096
  bankAccountPoweredBy: string;
@@ -1,3 +1,3 @@
1
- import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js";
1
+ import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js";
2
2
  import "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js";
3
3
  export { e as ReceivablesWidget };
@@ -1,3 +1,3 @@
1
1
  import { InvoicingWidget as e } from "./index3.js";
2
- import { ReceivablesWidget as t } from "./index19.js";
2
+ import { ReceivablesWidget as t } from "./index21.js";
3
3
  export { e as InvoicingWidget, t as ReceivablesWidget };
@@ -1,195 +1,90 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { extractApiErrorMessage as e } from "../../../shared/util/dist/lib/apiErrors.js";
6
- import { defaultPaymentValues as t, defaultSendValues as n, fromMajorUnits as r, hasPaymentErrors as i, hasSendErrors as a, splitEmailList as o, validatePaymentValues as s, validateSendValues as c } from "./index8.js";
7
- import { useSendReceivableEmailMutation as l } from "../../data-access/dist/index5.js";
8
- import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as te, useCloneReceivableMutation as u, useDeclineReceivableMutation as d, useDeleteReceivableMutation as f, useIssueReceivableMutation as p } from "../../data-access/dist/index6.js";
9
- import { useMarkReceivablePaidMutation as m, useMarkReceivablePartiallyPaidMutation as h, useMarkReceivableUncollectibleMutation as g } from "../../data-access/dist/index8.js";
10
- import "../../data-access/dist/index.js";
11
- import { useCallback as _, useState as v } from "react";
12
1
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js
13
- function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C }) {
14
- let w = p(), T = te(), E = u(), D = ee(), O = d(), k = f(), A = l(), j = m(), M = h(), N = g(), [P, F] = v(), [I, L] = v(), [R, z] = v(), [B, V] = v(() => n(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => t()), [J, Y] = v({}), X = _((e, r, i) => {
15
- let a = "documentLabel" in r ? r.documentLabel : r.title, o = {
16
- id: r.id,
17
- type: r.type,
18
- title: a,
19
- action: e
20
- }, s = i === void 0 ? y : i ?? void 0;
21
- if (e === "send") {
22
- z(o), V(n(s, x)), U({});
23
- return;
24
- }
25
- if (e === "recordPayment") {
26
- G({
27
- ...o,
28
- currency: s?.currency
29
- }), q(t()), Y({});
30
- return;
31
- }
32
- L(void 0), F(o);
33
- }, [x, y]), Z = _(() => {
34
- F(void 0), L(void 0);
35
- }, []), Q = _(() => {
36
- z(void 0), U({});
37
- }, []), $ = _(() => {
38
- G(void 0), Y({});
39
- }, []), ne = _(async () => {
40
- if (!P) return;
41
- let t = { receivable_id: P.id };
42
- try {
43
- if (P.action === "issue") await w.mutateAsync({ path: t });
44
- else if (P.action === "cancel") await T.mutateAsync({ path: t });
45
- else if (P.action === "clone") {
46
- let e = await E.mutateAsync({ path: t });
47
- e?.id && S?.(e.id, e.type);
48
- } else P.action === "accept" ? await D.mutateAsync({ path: t }) : P.action === "decline" ? await O.mutateAsync({ path: t }) : P.action === "delete" ? (await k.mutateAsync({ path: t }), C?.(P.id)) : P.action === "markPaid" ? await j.mutateAsync({
49
- path: t,
50
- body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
51
- }) : P.action === "markUncollectible" && await N.mutateAsync({ path: t });
52
- F(void 0), L(void 0);
53
- } catch (t) {
54
- L(e(t) ?? x.genericError);
55
- }
56
- }, [
57
- D,
58
- P,
59
- T,
60
- E,
61
- O,
62
- k,
63
- w,
64
- j,
65
- x.genericError,
66
- S,
67
- C,
68
- N
69
- ]), re = _(async () => {
70
- if (!R) return;
71
- let t = c(B, x);
72
- if (a(t)) {
73
- U(t);
74
- return;
75
- }
76
- try {
77
- await A.mutateAsync({
78
- path: { receivable_id: R.id },
79
- body: {
80
- body_text: B.body,
81
- subject_text: B.subject,
82
- recipients: {
83
- to: o(B.to),
84
- cc: o(B.cc),
85
- bcc: o(B.bcc)
86
- }
87
- }
88
- }), Q();
89
- } catch (t) {
90
- U({ form: e(t) ?? x.genericError });
91
- }
92
- }, [
93
- Q,
94
- x,
95
- A,
96
- R,
97
- B
98
- ]), ie = _(async () => {
99
- if (!W) return;
100
- let t = s(K, x, W.currency);
101
- if (i(t)) {
102
- Y(t);
103
- return;
104
- }
105
- try {
106
- let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
107
- K.mode === "full" ? await j.mutateAsync({
108
- path: e,
109
- body: {
110
- comment: K.comment || void 0,
111
- paid_at: t
112
- }
113
- }) : await M.mutateAsync({
114
- path: e,
115
- body: {
116
- amount_paid: r(K.amountPaid, W.currency) ?? 0,
117
- comment: K.comment || void 0
118
- }
119
- }), $();
120
- } catch (t) {
121
- Y({ form: e(t) ?? x.genericError });
122
- }
123
- }, [
124
- $,
125
- j,
126
- x,
127
- M,
128
- W,
129
- K
130
- ]);
131
- return {
132
- actionTarget: P,
133
- actionDialog: P ? b(P.action, x) : void 0,
134
- actionError: I,
135
- actionInProgress: w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || N.isPending,
136
- openAction: X,
137
- closeAction: Z,
138
- confirmAction: ne,
139
- sendOpen: !!R,
140
- sendValues: B,
141
- sendErrors: H,
142
- sendInProgress: A.isPending,
143
- setSendValues: V,
144
- closeSend: Q,
145
- submitSend: re,
146
- paymentOpen: !!W,
147
- paymentValues: K,
148
- paymentErrors: J,
149
- paymentInProgress: j.isPending || M.isPending,
150
- setPaymentValues: q,
151
- closePayment: $,
152
- submitPayment: ie
153
- };
154
- }
155
- function b(e, t) {
156
- return e === "issue" ? {
157
- title: t.issueTitle,
158
- description: t.issueDescription,
159
- confirmLabel: t.issueConfirm
160
- } : e === "accept" ? {
161
- title: t.acceptTitle,
162
- description: t.acceptDescription,
163
- confirmLabel: t.acceptConfirm
164
- } : e === "decline" ? {
165
- title: t.declineTitle,
166
- description: t.declineDescription,
167
- confirmLabel: t.declineConfirm,
168
- destructive: !0
169
- } : e === "cancel" ? {
170
- title: t.cancelTitle,
171
- description: t.cancelDescription,
172
- confirmLabel: t.cancelConfirm,
173
- destructive: !0
174
- } : e === "clone" ? {
175
- title: t.cloneTitle,
176
- description: t.cloneDescription,
177
- confirmLabel: t.cloneConfirm
178
- } : e === "delete" ? {
179
- title: t.deleteTitle,
180
- description: t.deleteDescription,
181
- confirmLabel: t.deleteConfirm,
182
- destructive: !0
183
- } : e === "markPaid" ? {
184
- title: t.markPaidTitle,
185
- description: t.markPaidDescription,
186
- confirmLabel: t.markPaidConfirm
187
- } : {
188
- title: t.markUncollectibleTitle,
189
- description: t.markUncollectibleDescription,
190
- confirmLabel: t.markUncollectibleConfirm,
191
- destructive: !0
192
- };
193
- }
2
+ var e = {
3
+ customerRequired: "Customer is required",
4
+ customerAddressRequired: "The selected customer needs a billing address before a receivable can be created.",
5
+ currencyRequired: "Currency is required",
6
+ lineItemNameTooLong: "Product name must be 100 characters or less",
7
+ lineItemPriceTooHigh: "Price must be {maxAmount} or less",
8
+ sendToRequired: "Enter at least one recipient",
9
+ sendSubjectRequired: "Subject is required",
10
+ sendBodyRequired: "Message is required",
11
+ paymentAmountInvalid: "Amount paid must be greater than 0",
12
+ genericError: "Something went wrong. Please try again.",
13
+ lineItemsLoading: "Please wait for invoice details to finish loading.",
14
+ paymentTermsCustomDatePlaceholder: "Mon DD, YYYY",
15
+ bankAccountFallbackName: "Bank Account",
16
+ bankAccountPoweredBy: "Powered by {embeddedBankName}",
17
+ bankAccountLinked: "Linked account",
18
+ bankAccountHolderNameRequired: "Account holder name is required",
19
+ bankAccountHolderNameTooLong: "Account holder name must be 255 characters or less",
20
+ bankAccountNumberRequired: "Account number is required",
21
+ bankAccountNumberDigitsOnly: "Account number must contain only digits",
22
+ bankAccountNumberTooShort: "Account number must be at least 4 digits",
23
+ bankAccountNumberTooLong: "Account number must be at most 17 digits",
24
+ bankAccountRoutingNumberRequired: "Routing number is required",
25
+ bankAccountRoutingNumberInvalid: "Routing number must be 9 digits",
26
+ bankAccountNicknameTooLong: "Display name must be 200 characters or less",
27
+ bankAccountCreated: "Bank Account \"{name}\" has been created.",
28
+ bankAccountCreateFailed: "Failed to create Bank Account.",
29
+ untitledDocument: "Untitled document",
30
+ unknownCustomer: "Unknown customer",
31
+ notAvailable: "Not available",
32
+ invoiceType: "Invoice",
33
+ quoteType: "Quote",
34
+ creditNoteType: "Credit note",
35
+ summaryDocumentType: "Document type",
36
+ summaryDocumentNumber: "Document number",
37
+ summaryCustomer: "Customer",
38
+ summaryIssued: "Issued",
39
+ summaryDue: "Due",
40
+ summaryCreated: "Created",
41
+ summaryUpdated: "Updated",
42
+ summaryTotal: "Total",
43
+ summaryAmountDue: "Amount due",
44
+ activityStatusChanged: "Status changed",
45
+ activityReceivableCreated: "Receivable created",
46
+ activityReceivableUpdated: "Receivable updated",
47
+ activityPaymentReceived: "Payment received",
48
+ activityMailSent: "Email sent",
49
+ activityUnknown: "Activity",
50
+ recipientsNone: "No recipients",
51
+ sendSubjectDefault: "Your receivable document",
52
+ sendBodyDefault: "Please find the receivable document attached.",
53
+ issueTitle: "Issue receivable?",
54
+ issueDescription: "Issuing locks the document and makes it ready to send to the customer.",
55
+ issueConfirm: "Issue",
56
+ acceptTitle: "Accept quote?",
57
+ acceptDescription: "This marks the quote as accepted.",
58
+ acceptConfirm: "Accept",
59
+ declineTitle: "Decline quote?",
60
+ declineDescription: "This marks the quote as declined.",
61
+ declineConfirm: "Decline",
62
+ cancelTitle: "Cancel receivable?",
63
+ cancelDescription: "This cancels the document. You cannot undo this action.",
64
+ cancelConfirm: "Cancel document",
65
+ cloneTitle: "Clone receivable?",
66
+ cloneDescription: "This creates a new draft based on the selected document.",
67
+ cloneConfirm: "Clone",
68
+ deleteTitle: "Delete draft?",
69
+ deleteDescription: "This permanently deletes the draft document. You cannot undo this action.",
70
+ deleteConfirm: "Delete",
71
+ markPaidTitle: "Mark invoice as paid?",
72
+ markPaidDescription: "This records the invoice as fully paid.",
73
+ markPaidConfirm: "Mark paid",
74
+ markUncollectibleTitle: "Mark invoice uncollectible?",
75
+ markUncollectibleDescription: "This records the invoice as uncollectible. You cannot undo this action.",
76
+ markUncollectibleConfirm: "Mark uncollectible",
77
+ attachmentsEmailCaption: "Selected files will be attached to the invoice email sent to the customer.",
78
+ attachmentsRecurringEmailCaption: "Selected files will be attached to every invoice email in the recurring series.",
79
+ attachmentIncludeInEmail: "Include in email:",
80
+ attachmentRemove: "Remove",
81
+ attachmentUploading: "Uploading…",
82
+ attachmentUploadFailed: "Upload failed. Please try again.",
83
+ attachmentTooLarge: "File too large (max 3 MB)",
84
+ attachmentUnsupportedType: "File type not supported. Use PDF, DOC, JPG or PNG",
85
+ attachmentsCountLimit: "You can attach up to 10 files.",
86
+ attachmentIncludedInEmail: "Included in email",
87
+ attachmentNotIncludedInEmail: "Not included in email"
88
+ };
194
89
  //#endregion
195
- export { y as useReceivableActions };
90
+ export { e as RECEIVABLE_MESSAGE_LABELS_EN };
@@ -2,41 +2,194 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { buildReceivableDetailsView as e } from "./index8.js";
6
- import { useReceivableHistoryQuery as t, useReceivableMailsQuery as n, useReceivablePdfLinkQuery as r, useReceivableQuery as i } from "../../data-access/dist/index9.js";
5
+ import { extractApiErrorMessage as e } from "../../../shared/util/dist/lib/apiErrors.js";
6
+ import { defaultPaymentValues as t, defaultSendValues as n, fromMajorUnits as r, hasPaymentErrors as i, hasSendErrors as a, splitEmailList as o, validatePaymentValues as s, validateSendValues as c } from "./index9.js";
7
+ import { useSendReceivableEmailMutation as l } from "../../data-access/dist/index5.js";
8
+ import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as te, useCloneReceivableMutation as u, useDeclineReceivableMutation as d, useDeleteReceivableMutation as f, useIssueReceivableMutation as p } from "../../data-access/dist/index6.js";
9
+ import { useMarkReceivablePaidMutation as m, useMarkReceivablePartiallyPaidMutation as h, useMarkReceivableUncollectibleMutation as g } from "../../data-access/dist/index8.js";
7
10
  import "../../data-access/dist/index.js";
8
- import { useMemo as a } from "react";
11
+ import { useCallback as _, useState as v } from "react";
9
12
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.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
13
+ function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C }) {
14
+ let w = p(), T = te(), E = u(), D = ee(), O = d(), k = f(), A = l(), j = m(), M = h(), N = g(), [P, F] = v(), [I, L] = v(), [R, z] = v(), [B, V] = v(() => n(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => t()), [J, Y] = v({}), X = _((e, r, i) => {
15
+ let a = "documentLabel" in r ? r.documentLabel : r.title, o = {
16
+ id: r.id,
17
+ type: r.type,
18
+ title: a,
19
+ action: e
20
+ }, s = i === void 0 ? y : i ?? void 0;
21
+ if (e === "send") {
22
+ z(o), V(n(s, x)), U({});
23
+ return;
24
+ }
25
+ if (e === "recordPayment") {
26
+ G({
27
+ ...o,
28
+ currency: s?.currency
29
+ }), q(t()), Y({});
30
+ return;
31
+ }
32
+ L(void 0), F(o);
33
+ }, [x, y]), Z = _(() => {
34
+ F(void 0), L(void 0);
35
+ }, []), Q = _(() => {
36
+ z(void 0), U({});
37
+ }, []), $ = _(() => {
38
+ G(void 0), Y({});
39
+ }, []), ne = _(async () => {
40
+ if (!P) return;
41
+ let t = { receivable_id: P.id };
42
+ try {
43
+ if (P.action === "issue") await w.mutateAsync({ path: t });
44
+ else if (P.action === "cancel") await T.mutateAsync({ path: t });
45
+ else if (P.action === "clone") {
46
+ let e = await E.mutateAsync({ path: t });
47
+ e?.id && S?.(e.id, e.type);
48
+ } else P.action === "accept" ? await D.mutateAsync({ path: t }) : P.action === "decline" ? await O.mutateAsync({ path: t }) : P.action === "delete" ? (await k.mutateAsync({ path: t }), C?.(P.id)) : P.action === "markPaid" ? await j.mutateAsync({
49
+ path: t,
50
+ body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
51
+ }) : P.action === "markUncollectible" && await N.mutateAsync({ path: t });
52
+ F(void 0), L(void 0);
53
+ } catch (t) {
54
+ L(e(t) ?? x.genericError);
55
+ }
56
+ }, [
57
+ D,
58
+ P,
59
+ T,
60
+ E,
61
+ O,
62
+ k,
63
+ w,
64
+ j,
65
+ x.genericError,
66
+ S,
67
+ C,
68
+ N
69
+ ]), re = _(async () => {
70
+ if (!R) return;
71
+ let t = c(B, x);
72
+ if (a(t)) {
73
+ U(t);
74
+ return;
75
+ }
76
+ try {
77
+ await A.mutateAsync({
78
+ path: { receivable_id: R.id },
79
+ body: {
80
+ body_text: B.body,
81
+ subject_text: B.subject,
82
+ recipients: {
83
+ to: o(B.to),
84
+ cc: o(B.cc),
85
+ bcc: o(B.bcc)
86
+ }
87
+ }
88
+ }), Q();
89
+ } catch (t) {
90
+ U({ form: e(t) ?? x.genericError });
91
+ }
92
+ }, [
93
+ Q,
94
+ x,
95
+ A,
96
+ R,
97
+ B
98
+ ]), ie = _(async () => {
99
+ if (!W) return;
100
+ let t = s(K, x, W.currency);
101
+ if (i(t)) {
102
+ Y(t);
103
+ return;
104
+ }
105
+ try {
106
+ let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
107
+ K.mode === "full" ? await j.mutateAsync({
108
+ path: e,
109
+ body: {
110
+ comment: K.comment || void 0,
111
+ paid_at: t
112
+ }
113
+ }) : await M.mutateAsync({
114
+ path: e,
115
+ body: {
116
+ amount_paid: r(K.amountPaid, W.currency) ?? 0,
117
+ comment: K.comment || void 0
118
+ }
119
+ }), $();
120
+ } catch (t) {
121
+ Y({ form: e(t) ?? x.genericError });
122
+ }
123
+ }, [
124
+ $,
125
+ j,
126
+ x,
127
+ M,
128
+ W,
129
+ K
33
130
  ]);
34
131
  return {
35
- receivable: l.data,
36
- detailsView: p,
37
- isLoading: l.isLoading || u.isLoading || d.isLoading || f.isLoading,
38
- isError: l.isError
132
+ actionTarget: P,
133
+ actionDialog: P ? b(P.action, x) : void 0,
134
+ actionError: I,
135
+ actionInProgress: w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || N.isPending,
136
+ openAction: X,
137
+ closeAction: Z,
138
+ confirmAction: ne,
139
+ sendOpen: !!R,
140
+ sendValues: B,
141
+ sendErrors: H,
142
+ sendInProgress: A.isPending,
143
+ setSendValues: V,
144
+ closeSend: Q,
145
+ submitSend: re,
146
+ paymentOpen: !!W,
147
+ paymentValues: K,
148
+ paymentErrors: J,
149
+ paymentInProgress: j.isPending || M.isPending,
150
+ setPaymentValues: q,
151
+ closePayment: $,
152
+ submitPayment: ie
153
+ };
154
+ }
155
+ function b(e, t) {
156
+ return e === "issue" ? {
157
+ title: t.issueTitle,
158
+ description: t.issueDescription,
159
+ confirmLabel: t.issueConfirm
160
+ } : e === "accept" ? {
161
+ title: t.acceptTitle,
162
+ description: t.acceptDescription,
163
+ confirmLabel: t.acceptConfirm
164
+ } : e === "decline" ? {
165
+ title: t.declineTitle,
166
+ description: t.declineDescription,
167
+ confirmLabel: t.declineConfirm,
168
+ destructive: !0
169
+ } : e === "cancel" ? {
170
+ title: t.cancelTitle,
171
+ description: t.cancelDescription,
172
+ confirmLabel: t.cancelConfirm,
173
+ destructive: !0
174
+ } : e === "clone" ? {
175
+ title: t.cloneTitle,
176
+ description: t.cloneDescription,
177
+ confirmLabel: t.cloneConfirm
178
+ } : e === "delete" ? {
179
+ title: t.deleteTitle,
180
+ description: t.deleteDescription,
181
+ confirmLabel: t.deleteConfirm,
182
+ destructive: !0
183
+ } : e === "markPaid" ? {
184
+ title: t.markPaidTitle,
185
+ description: t.markPaidDescription,
186
+ confirmLabel: t.markPaidConfirm
187
+ } : {
188
+ title: t.markUncollectibleTitle,
189
+ description: t.markUncollectibleDescription,
190
+ confirmLabel: t.markUncollectibleConfirm,
191
+ destructive: !0
39
192
  };
40
193
  }
41
194
  //#endregion
42
- export { o as useReceivableDetails };
195
+ export { y as useReceivableActions };