@tesouro/embedded-components-react 0.5.263 → 0.5.266

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.
@@ -11,222 +11,180 @@ import "../../../../ui/dist/index.js";
11
11
  import { hasSelectedText as ie } from "../../../../../shared/product-catalog/feature/dist/lib/helpers.js";
12
12
  import "../../../../../shared/product-catalog/feature/dist/index.js";
13
13
  import { getCreateFollowUp as ae } from "./actionsModal.js";
14
- import { coerceEnabledTabs as oe, getDocumentTitle as se, resolveInitialTab as i, tabForType as a, typeForTab as ce } from "./helpers.js";
15
- import { RECEIVABLE_MESSAGE_LABELS_EN as le } from "./labels.js";
16
- import { getReceivablePermissions as ue } from "./permissions.js";
17
- import { useReceivableActions as de } from "./useReceivableActions.js";
18
- import { useReceivableActionsModal as fe } from "./useReceivableActionsModal.js";
19
- import { useReceivableDetails as pe } from "./useReceivableDetails.js";
20
- import { useReceivableForm as me } from "./useReceivableForm.js";
21
- import { useReceivablesTable as he } from "./useReceivablesTable.js";
22
- import { useCallback as o, useEffect as s, useMemo as c, useRef as ge, useState as l } from "react";
14
+ import { getDocumentTitle as oe } from "./helpers.js";
15
+ import { RECEIVABLE_MESSAGE_LABELS_EN as i } from "./labels.js";
16
+ import { getReceivablePermissions as se } from "./permissions.js";
17
+ import { useReceivableActions as ce } from "./useReceivableActions.js";
18
+ import { useReceivableActionsModal as le } from "./useReceivableActionsModal.js";
19
+ import { useReceivableDetails as ue } from "./useReceivableDetails.js";
20
+ import { useReceivableForm as de } from "./useReceivableForm.js";
21
+ import { useReceivablesTable as fe } from "./useReceivablesTable.js";
22
+ import { useCallback as a, useEffect as o, useMemo as s, useRef as pe, useState as c } from "react";
23
23
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js
24
- function u({ auditHistoryLabels: u, counterpartMessageLabels: _e, defaultTab: f, embeddedBankName: ve, enabledTabs: p, filterLabels: ye, initialCounterpartId: m, initialView: h, messageLabels: g, onReceivableCreated: _, onReceivableOpened: v, screenLabels: be }) {
25
- let y = e();
26
- s(() => {
27
- y(ne.Mounted);
28
- }, [y]);
29
- let { initResponse: b, widgetToken: xe } = n(), x = te(), Se = r(), Ce = t(), S = ee(), C = !!b && !S, w = c(() => ue(b?.scopes), [b?.scopes]), we = !!b && S, T = !!b && w.canRead, E = !!b && w.canWrite, D = C && w.canRead, O = C && w.canWrite, k = !!Se && !C && !x, A = !C && !k && !!(xe || x), j = c(() => ({
30
- ...le,
31
- ...g
32
- }), [g]), M = be?.statusBadge, N = c(() => ({
24
+ function l({ auditHistoryLabels: l, counterpartMessageLabels: me, embeddedBankName: he, filterLabels: ge, initialCounterpartId: d, initialView: f, messageLabels: p, onReceivableCreated: m, onReceivableOpened: h, screenLabels: _e }) {
25
+ let g = e();
26
+ o(() => {
27
+ g(ne.Mounted);
28
+ }, [g]);
29
+ let { initResponse: _, widgetToken: ve } = n(), v = te(), ye = r(), y = t(), b = ee(), x = !!_ && !b, S = s(() => se(_?.scopes), [_?.scopes]), be = !!_ && b, C = !!_ && S.canRead, w = !!_ && S.canWrite, T = x && S.canRead, E = x && S.canWrite, D = !!ye && !x && !v, O = !x && !D && !!(ve || v), k = s(() => ({
30
+ ...i,
31
+ ...p
32
+ }), [p]), A = _e?.statusBadge, j = s(() => ({
33
33
  ...re,
34
- ...M
35
- }), [M]), P = c(() => oe(p), [p]), [F, I] = l(() => i({
36
- defaultTab: f,
37
- enabledTabs: P
38
- })), [Te, L] = l(), [R, z] = l(!1), [B, V] = l(!1), Ee = o(() => V(!0), []), H = o(() => V(!1), []);
39
- s(() => {
40
- P.includes(F) || I(i({
41
- defaultTab: f,
42
- enabledTabs: P
43
- }));
44
- }, [
45
- F,
46
- f,
47
- P
48
- ]);
49
- let De = o((e, t) => {
50
- I(a(t)), L(e), z(!0), _?.(e, t);
51
- }, [_]), U = fe({ messages: j }), W = U.open, Oe = o((e, t, n) => {
52
- I(a(t));
34
+ ...A
35
+ }), [A]), [M, N] = c(), [P, F] = c(!1), [I, L] = c(!1), xe = a(() => L(!0), []), R = a(() => L(!1), []), Se = a((e, t) => {
36
+ N(e), F(!0), m?.(e, t);
37
+ }, [m]), z = le({ messages: k }), B = z.open, Ce = a((e, t, n) => {
53
38
  let r = ae(n);
54
- r.openDetails && (L(e), z(!0)), r.actionsModal && W({
39
+ r.openDetails && (N(e), F(!0)), r.actionsModal && B({
55
40
  action: n.mode,
56
41
  receivableId: e,
57
42
  counterpartId: n.counterpartId,
58
43
  inlineItems: n.inlineItems,
59
44
  showEmailStep: r.actionsModal.showEmailStep
60
- }), _?.(e, t);
61
- }, [_, W]), G = he({
62
- activeTab: F,
63
- initialCounterpartId: h === "create" ? void 0 : m,
64
- messages: j,
65
- statusLabels: N,
66
- filterLabels: ye,
67
- enabled: D,
68
- visible: T
69
- }), ke = o((e) => {
70
- L(e), z(!0), v?.(e, "invoice");
71
- }, [v]), K = pe({
72
- selectedReceivableId: Te,
73
- enabled: R && D,
74
- canWrite: E,
75
- messages: j,
76
- statusLabels: N,
77
- auditHistoryLabels: u,
78
- onOpenReceivable: ke
79
- }), q = me({
80
- messages: j,
81
- counterpartMessageLabels: _e,
82
- embeddedBankName: ve,
83
- onCreated: Oe
84
- }), Ae = o(() => {
85
- if (!O) return;
86
- let e = ce(F);
87
- q.openCreate(e === "quote" ? "quote" : "invoice");
45
+ }), m?.(e, t);
46
+ }, [m, B]), V = fe({
47
+ initialCounterpartId: f === "create" ? void 0 : d,
48
+ messages: k,
49
+ statusLabels: j,
50
+ filterLabels: ge,
51
+ enabled: T,
52
+ visible: C
53
+ }), we = a((e) => {
54
+ N(e), F(!0), h?.(e, "invoice");
55
+ }, [h]), H = ue({
56
+ selectedReceivableId: M,
57
+ enabled: P && T,
58
+ canWrite: w,
59
+ messages: k,
60
+ statusLabels: j,
61
+ auditHistoryLabels: l,
62
+ onOpenReceivable: we
63
+ }), U = de({
64
+ messages: k,
65
+ counterpartMessageLabels: me,
66
+ embeddedBankName: he,
67
+ onCreated: Ce
68
+ }), Te = a(() => {
69
+ E && U.openCreate("invoice");
70
+ }, [E, U.openCreate]), W = pe(!1);
71
+ o(() => {
72
+ W.current || f === "create" && E && (W.current = !0, U.openCreate("invoice", { customerId: d }));
88
73
  }, [
89
- F,
90
- O,
91
- q.openCreate
92
- ]), J = ge(!1);
93
- s(() => {
94
- J.current || h === "create" && O && (J.current = !0, q.openCreate("invoice", { customerId: m }));
95
- }, [
96
- O,
97
- q.openCreate,
98
- m,
99
- h
74
+ E,
75
+ U.openCreate,
76
+ d,
77
+ f
100
78
  ]);
101
- let Y = de({
102
- selectedReceivable: K.receivable,
103
- selectedRecurrence: K.recurrence,
104
- messages: j,
105
- onCreated: De,
79
+ let G = ce({
80
+ selectedReceivable: H.receivable,
81
+ selectedRecurrence: H.recurrence,
82
+ messages: k,
83
+ onCreated: Se,
106
84
  onDeleted: (e) => {
107
- e === Te && (L(void 0), z(!1));
85
+ e === M && (N(void 0), F(!1));
108
86
  },
109
87
  onCompleteBeforeIssue: (e) => {
110
- q.openEdit(e, { highlightForIssue: !0 }), z(!1);
88
+ U.openEdit(e, { highlightForIssue: !0 }), F(!1);
111
89
  }
112
- }), X = C && !w.canWrite, Z = q.open || q.counterpartView !== "none" || !!Y.actionTarget || Y.sendOpen || Y.payment.isOpen || U.isOpen || B, je = q.close, Q = q.counterpartForm.close, { closeAction: Me, closeSend: Ne } = Y, Pe = Y.payment.close, $ = U.close;
113
- s(() => {
114
- X && Z && (je(), Q(), Me(), Ne(), Pe(), $(), H());
90
+ }), K = x && !S.canWrite, q = U.open || U.counterpartView !== "none" || !!G.actionTarget || G.sendOpen || G.payment.isOpen || z.isOpen || I, J = U.close, Y = U.counterpartForm.close, { closeAction: X, closeSend: Z } = G, Q = G.payment.close, $ = z.close;
91
+ o(() => {
92
+ K && q && (J(), Y(), X(), Z(), Q(), $(), R());
115
93
  }, [
116
- Me,
94
+ X,
117
95
  $,
96
+ Y,
97
+ J,
98
+ R,
118
99
  Q,
119
- je,
120
- H,
121
- Pe,
122
- Ne,
123
100
  Z,
124
- X
101
+ q,
102
+ K
125
103
  ]);
126
- let Fe = o((e) => {
127
- ie() || (L(e.id), z(!0), v?.(e.id, e.type));
128
- }, [v]), Ie = o(() => {
129
- z(!1), L(void 0);
130
- }, []), Le = o((e, t) => {
131
- if (!O) return;
132
- let n = G.getReceivableById(t.id);
133
- if (e === "edit") {
134
- if (n) {
135
- q.openEdit(n);
136
- return;
137
- }
138
- L(t.id), z(!0);
139
- return;
140
- }
141
- L(t.id), Y.openAction(e, t, n ?? null);
142
- }, [
143
- Y,
144
- O,
145
- q.openEdit,
146
- G.getReceivableById
147
- ]), Re = o((e, t) => {
148
- if (O) {
104
+ let Ee = a((e) => {
105
+ ie() || (N(e.id), F(!0), h?.(e.id, e.type));
106
+ }, [h]), De = a(() => {
107
+ F(!1), N(void 0);
108
+ }, []), Oe = a((e, t) => {
109
+ if (E) {
149
110
  if (e === "edit") {
150
- K.receivable && (q.openEdit(K.receivable), z(!1));
111
+ H.receivable && (U.openEdit(H.receivable), F(!1));
151
112
  return;
152
113
  }
153
- Y.openAction(e, {
114
+ G.openAction(e, {
154
115
  id: t.id,
155
- title: K.receivable ? se(K.receivable, j) : t.title,
116
+ title: H.receivable ? oe(H.receivable, k) : t.title,
156
117
  type: t.type
157
- }, K.receivable ?? null);
118
+ }, H.receivable ?? null);
158
119
  }
159
120
  }, [
160
- Y,
161
- O,
162
- K.receivable,
163
- q.openEdit,
164
- j
121
+ G,
122
+ E,
123
+ H.receivable,
124
+ U.openEdit,
125
+ k
165
126
  ]);
166
127
  return {
167
- activeTab: F,
168
- enabledTabs: P,
169
- setActiveTab: I,
170
- canWrite: E,
171
- actionsSuspended: we,
172
- isAccessRestricted: C && !w.canRead,
173
- table: T ? G : {
174
- ...G,
128
+ canWrite: w,
129
+ canEditSettings: C && S.canEditSettings,
130
+ actionsSuspended: be,
131
+ isAccessRestricted: x && !S.canRead,
132
+ table: C ? V : {
133
+ ...V,
175
134
  rows: [],
176
135
  statusCards: void 0,
177
136
  isError: !1
178
137
  },
179
- isTableLoading: T ? G.isLoading || A && G.rows.length === 0 : A,
180
- isError: k || T && G.isError,
181
- onRetry: k ? Ce : G.onRetry,
182
- details: K,
183
- detailsOpen: R && T,
184
- closeDetails: Ie,
138
+ isTableLoading: C ? V.isLoading || O && V.rows.length === 0 : O,
139
+ isError: D || C && V.isError,
140
+ onRetry: D ? y : V.onRetry,
141
+ details: H,
142
+ detailsOpen: P && C,
143
+ closeDetails: De,
185
144
  form: {
186
- ...q,
187
- open: E && q.open,
188
- counterpartView: E ? q.counterpartView : "none",
145
+ ...U,
146
+ open: w && U.open,
147
+ counterpartView: w ? U.counterpartView : "none",
189
148
  counterpartForm: {
190
- ...q.counterpartForm,
191
- submit: d(O, q.counterpartForm.submit)
149
+ ...U.counterpartForm,
150
+ submit: u(E, U.counterpartForm.submit)
192
151
  },
193
- submit: d(O, q.submit),
194
- submitDraft: d(O, q.submitDraft),
195
- submitPrimary: d(O, q.submitPrimary)
152
+ submit: u(E, U.submit),
153
+ submitDraft: u(E, U.submitDraft),
154
+ submitPrimary: u(E, U.submitPrimary)
196
155
  },
197
- openCreate: Ae,
198
- measureUnitsOpen: E && B,
199
- openMeasureUnits: Ee,
200
- closeMeasureUnits: H,
156
+ openCreate: Te,
157
+ measureUnitsOpen: w && I,
158
+ openMeasureUnits: xe,
159
+ closeMeasureUnits: R,
201
160
  actions: {
202
- ...Y,
203
- actionDialog: E ? Y.actionDialog : void 0,
204
- sendOpen: E && Y.sendOpen,
205
- openAction: d(O, Y.openAction),
206
- confirmAction: d(O, Y.confirmAction),
207
- submitSend: d(O, Y.submitSend),
161
+ ...G,
162
+ actionDialog: w ? G.actionDialog : void 0,
163
+ sendOpen: w && G.sendOpen,
164
+ openAction: u(E, G.openAction),
165
+ confirmAction: u(E, G.confirmAction),
166
+ submitSend: u(E, G.submitSend),
208
167
  payment: {
209
- ...Y.payment,
210
- isOpen: E && Y.payment.isOpen,
211
- save: d(O, Y.payment.save),
212
- confirm: d(O, Y.payment.confirm)
168
+ ...G.payment,
169
+ isOpen: w && G.payment.isOpen,
170
+ save: u(E, G.payment.save),
171
+ confirm: u(E, G.payment.confirm)
213
172
  }
214
173
  },
215
174
  actionsModal: {
216
- ...U,
217
- isOpen: E && U.isOpen,
218
- send: d(O, U.send),
219
- saveItems: d(O, U.saveItems)
175
+ ...z,
176
+ isOpen: w && z.isOpen,
177
+ send: u(E, z.send),
178
+ saveItems: u(E, z.saveItems)
220
179
  },
221
- handleRowClick: Fe,
222
- handleActionClick: Le,
223
- handleDetailsActionClick: Re
180
+ handleRowClick: Ee,
181
+ handleDetailsActionClick: Oe
224
182
  };
225
183
  }
226
- function d(e, t) {
184
+ function u(e, t) {
227
185
  return (...n) => {
228
186
  e && t(...n);
229
187
  };
230
188
  }
231
189
  //#endregion
232
- export { u as useReceivablesWidget };
190
+ export { l as useReceivablesWidget };
@@ -18,47 +18,28 @@ var r = {
18
18
  deleted: "Deleted",
19
19
  unknown: "Unknown"
20
20
  }, i = { all: "All invoices" }, a = {
21
- createButton: "Create",
22
- templateSettingsButton: "Template settings",
23
- searchPlaceholder: "Search by number or customer",
24
- statusFilterAll: "All statuses",
21
+ createInvoiceButton: "Create Invoice",
22
+ settingsButton: "Invoice settings",
23
+ bankAttributionPrefix: "Business Banking provided by",
25
24
  statusCardsAll: i.all,
26
- tabInvoices: "Invoices",
27
- tabQuotes: "Quotes",
28
- tabCreditNotes: "Credit notes",
29
- columnDocument: "Document",
30
- columnCustomer: "Customer",
25
+ columnDueDate: "Due date",
31
26
  columnStatus: "Status",
32
- columnIssueDate: "Issued",
33
- columnDueDate: "Due",
34
- columnTotal: "Total",
35
- columnAmountDue: "Amount due",
36
- columnActions: "Actions",
37
- openRow: (e) => `View document — ${e}`,
38
- sortByDocument: "Sort by document",
27
+ columnNumber: "Number",
28
+ columnCustomer: "Customer",
29
+ columnIssueDate: "Issue date",
30
+ columnAmount: "Amount",
31
+ openRow: (e) => `View invoice — ${e}`,
32
+ sortByDueDate: "Sort by due date",
39
33
  sortByStatus: "Sort by status",
34
+ sortByNumber: "Sort by number",
40
35
  sortByIssueDate: "Sort by issue date",
41
- sortByDueDate: "Sort by due date",
42
- sortByTotal: "Sort by total",
43
- actionEdit: "Edit",
44
- actionIssue: "Issue",
45
- actionSend: "Send",
46
- actionRecordPayment: "Record payment",
47
- actionMarkPaid: "Mark as paid",
48
- actionMarkUncollectible: "Mark uncollectible",
49
- actionAccept: "Accept",
50
- actionDecline: "Decline",
51
- actionCancel: "Cancel",
52
- actionClone: "Clone",
53
- actionDelete: "Delete",
54
- emptyTitle: "No receivables yet",
55
- emptyDescription: "Create your first invoice or quote.",
56
- emptyAction: "Create receivable",
57
- filterEmptyTitle: "No receivables found",
58
- filterEmptyDescription: "Try adjusting your search or filters.",
59
- errorTitle: "Failed to load receivables",
60
- errorDescription: "Something went wrong while fetching receivables. Please try again.",
61
- errorRetry: "Try again",
36
+ sortByAmount: "Sort by amount",
37
+ emptyTitle: "No Invoices",
38
+ emptyDescription: "You don’t have any invoices yet.",
39
+ filterEmptyTitle: "No Invoices Found",
40
+ errorTitle: "Failed to load Invoices",
41
+ errorDescription: "There was an error loading invoices.",
42
+ errorRetry: "Reload",
62
43
  accessRestrictedTitle: "Access Restricted",
63
44
  accessRestrictedDescription: "You don’t have permissions to view this page. Contact your system administrator for details.",
64
45
  statusBadge: r