@tesouro/embedded-components-react 0.5.243 → 0.5.245
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.
- package/dist/index.d.ts +2 -0
- package/dist/lib/ReceivablesWidget.d.ts +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +253 -251
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +84 -80
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/permissions.js +13 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +28 -26
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +16 -16
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +60 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +188 -115
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +222 -219
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -3,144 +3,217 @@
|
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
5
|
import { useAnalyticsTrack as e } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
6
|
+
import { useRefetchWidget as t, useWidgetConfig as n, useWidgetError as r, useWidgetInitStaleForToken as ee, useWidgetLoading as te } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
6
7
|
import "../../../../../shared/feature/dist/index.js";
|
|
7
|
-
import { ReceivablesWidgetAnalyticsEvent as
|
|
8
|
-
import { RECEIVABLE_STATUS_BADGE_LABELS_EN as
|
|
8
|
+
import { ReceivablesWidgetAnalyticsEvent as ne } from "./analytics/events.js";
|
|
9
|
+
import { RECEIVABLE_STATUS_BADGE_LABELS_EN as re } from "../../../../ui/dist/index13.js";
|
|
9
10
|
import "../../../../ui/dist/index.js";
|
|
10
|
-
import { hasSelectedText as
|
|
11
|
+
import { hasSelectedText as ie } from "../../../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
11
12
|
import "../../../../../shared/product-catalog/feature/dist/index.js";
|
|
12
|
-
import { getCreateFollowUp as
|
|
13
|
-
import { coerceEnabledTabs as
|
|
14
|
-
import { RECEIVABLE_MESSAGE_LABELS_EN as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
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, useState as l } from "react";
|
|
21
23
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js
|
|
22
|
-
function
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, [
|
|
27
|
-
let
|
|
28
|
-
...
|
|
29
|
-
...
|
|
30
|
-
}), [
|
|
31
|
-
...
|
|
32
|
-
...
|
|
33
|
-
}), [
|
|
34
|
-
defaultTab:
|
|
35
|
-
enabledTabs:
|
|
36
|
-
})), [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
defaultTab:
|
|
40
|
-
enabledTabs:
|
|
24
|
+
function u({ auditHistoryLabels: u, counterpartMessageLabels: ge, defaultTab: f, embeddedBankName: _e, enabledTabs: ve, filterLabels: ye, initialCounterpartId: be, messageLabels: p, onReceivableCreated: m, onReceivableOpened: h, screenLabels: xe }) {
|
|
25
|
+
let g = e();
|
|
26
|
+
s(() => {
|
|
27
|
+
g(ne.Mounted);
|
|
28
|
+
}, [g]);
|
|
29
|
+
let { initResponse: _, widgetToken: Se } = n(), v = te(), Ce = r(), we = t(), y = ee(), b = !!_ && !y, x = c(() => ue(_?.scopes), [_?.scopes]), Te = !!_ && y, S = !!_ && x.canRead, C = !!_ && x.canWrite, w = b && x.canRead, T = b && x.canWrite, E = !!Ce && !b && !v, D = !b && !E && !!(Se || v), O = c(() => ({
|
|
30
|
+
...le,
|
|
31
|
+
...p
|
|
32
|
+
}), [p]), k = xe?.statusBadge, A = c(() => ({
|
|
33
|
+
...re,
|
|
34
|
+
...k
|
|
35
|
+
}), [k]), j = c(() => oe(ve), [ve]), [M, N] = l(() => i({
|
|
36
|
+
defaultTab: f,
|
|
37
|
+
enabledTabs: j
|
|
38
|
+
})), [Ee, P] = l(), [F, I] = l(!1), [L, R] = l(!1), De = o(() => R(!0), []), z = o(() => R(!1), []);
|
|
39
|
+
s(() => {
|
|
40
|
+
j.includes(M) || N(i({
|
|
41
|
+
defaultTab: f,
|
|
42
|
+
enabledTabs: j
|
|
41
43
|
}));
|
|
42
44
|
}, [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
M,
|
|
46
|
+
f,
|
|
47
|
+
j
|
|
46
48
|
]);
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
}, [
|
|
50
|
-
|
|
51
|
-
let r =
|
|
52
|
-
r.openDetails && (
|
|
49
|
+
let Oe = o((e, t) => {
|
|
50
|
+
N(a(t)), P(e), I(!0), m?.(e, t);
|
|
51
|
+
}, [m]), B = fe({ messages: O }), V = B.open, ke = o((e, t, n) => {
|
|
52
|
+
N(a(t));
|
|
53
|
+
let r = ae(n);
|
|
54
|
+
r.openDetails && (P(e), I(!0)), r.actionsModal && V({
|
|
53
55
|
action: n.mode,
|
|
54
56
|
receivableId: e,
|
|
55
57
|
counterpartId: n.counterpartId,
|
|
56
58
|
inlineItems: n.inlineItems,
|
|
57
59
|
showEmailStep: r.actionsModal.showEmailStep
|
|
58
|
-
}),
|
|
59
|
-
}, [
|
|
60
|
-
activeTab:
|
|
61
|
-
initialCounterpartId:
|
|
62
|
-
messages:
|
|
63
|
-
statusLabels:
|
|
64
|
-
filterLabels:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
60
|
+
}), m?.(e, t);
|
|
61
|
+
}, [m, V]), H = he({
|
|
62
|
+
activeTab: M,
|
|
63
|
+
initialCounterpartId: be,
|
|
64
|
+
messages: O,
|
|
65
|
+
statusLabels: A,
|
|
66
|
+
filterLabels: ye,
|
|
67
|
+
enabled: w,
|
|
68
|
+
visible: S
|
|
69
|
+
}), Ae = o((e) => {
|
|
70
|
+
P(e), I(!0), h?.(e, "invoice");
|
|
71
|
+
}, [h]), U = pe({
|
|
72
|
+
selectedReceivableId: Ee,
|
|
73
|
+
enabled: F && w,
|
|
74
|
+
canWrite: C,
|
|
75
|
+
messages: O,
|
|
76
|
+
statusLabels: A,
|
|
77
|
+
auditHistoryLabels: u,
|
|
78
|
+
onOpenReceivable: Ae
|
|
79
|
+
}), W = me({
|
|
80
|
+
messages: O,
|
|
81
|
+
counterpartMessageLabels: ge,
|
|
82
|
+
embeddedBankName: _e,
|
|
83
|
+
onCreated: ke
|
|
84
|
+
}), je = o(() => {
|
|
85
|
+
if (!T) return;
|
|
86
|
+
let e = ce(M);
|
|
87
|
+
W.openCreate(e === "quote" ? "quote" : "invoice");
|
|
88
|
+
}, [
|
|
89
|
+
M,
|
|
90
|
+
T,
|
|
91
|
+
W.openCreate
|
|
92
|
+
]), G = de({
|
|
93
|
+
selectedReceivable: U.receivable,
|
|
94
|
+
selectedRecurrence: U.recurrence,
|
|
95
|
+
messages: O,
|
|
96
|
+
onCreated: Oe,
|
|
87
97
|
onDeleted: (e) => {
|
|
88
|
-
e ===
|
|
98
|
+
e === Ee && (P(void 0), I(!1));
|
|
89
99
|
},
|
|
90
100
|
onCompleteBeforeIssue: (e) => {
|
|
91
|
-
|
|
101
|
+
W.openEdit(e, { highlightForIssue: !0 }), I(!1);
|
|
92
102
|
}
|
|
93
|
-
}), Q =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
z(t.id), V(!0);
|
|
103
|
+
}), K = b && !x.canWrite, q = W.open || W.counterpartView !== "none" || !!G.actionTarget || G.sendOpen || G.paymentOpen || B.isOpen || L, J = W.close, Y = W.counterpartForm.close, { closeAction: X, closeSend: Z, closePayment: Q } = G, $ = B.close;
|
|
104
|
+
s(() => {
|
|
105
|
+
K && q && (J(), Y(), X(), Z(), Q(), $(), z());
|
|
106
|
+
}, [
|
|
107
|
+
X,
|
|
108
|
+
$,
|
|
109
|
+
Y,
|
|
110
|
+
J,
|
|
111
|
+
z,
|
|
112
|
+
Q,
|
|
113
|
+
Z,
|
|
114
|
+
q,
|
|
115
|
+
K
|
|
116
|
+
]);
|
|
117
|
+
let Me = o((e) => {
|
|
118
|
+
ie() || (P(e.id), I(!0), h?.(e.id, e.type));
|
|
119
|
+
}, [h]), Ne = o(() => {
|
|
120
|
+
I(!1), P(void 0);
|
|
121
|
+
}, []), Pe = o((e, t) => {
|
|
122
|
+
if (!T) return;
|
|
123
|
+
let n = H.getReceivableById(t.id);
|
|
124
|
+
if (e === "edit") {
|
|
125
|
+
if (n) {
|
|
126
|
+
W.openEdit(n);
|
|
119
127
|
return;
|
|
120
128
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
P(t.id), I(!0);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
P(t.id), G.openAction(e, t, n ?? null);
|
|
133
|
+
}, [
|
|
134
|
+
G,
|
|
135
|
+
T,
|
|
136
|
+
W.openEdit,
|
|
137
|
+
H.getReceivableById
|
|
138
|
+
]), Fe = o((e, t) => {
|
|
139
|
+
if (T) {
|
|
128
140
|
if (e === "edit") {
|
|
129
|
-
|
|
141
|
+
U.receivable && (W.openEdit(U.receivable), I(!1));
|
|
130
142
|
return;
|
|
131
143
|
}
|
|
132
|
-
|
|
144
|
+
G.openAction(e, {
|
|
133
145
|
id: t.id,
|
|
134
|
-
title:
|
|
146
|
+
title: U.receivable ? se(U.receivable, O) : t.title,
|
|
135
147
|
type: t.type
|
|
136
|
-
},
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
}, U.receivable ?? null);
|
|
149
|
+
}
|
|
150
|
+
}, [
|
|
151
|
+
G,
|
|
152
|
+
T,
|
|
153
|
+
U.receivable,
|
|
154
|
+
W.openEdit,
|
|
155
|
+
O
|
|
156
|
+
]);
|
|
157
|
+
return {
|
|
158
|
+
activeTab: M,
|
|
159
|
+
enabledTabs: j,
|
|
160
|
+
setActiveTab: N,
|
|
161
|
+
canWrite: C,
|
|
162
|
+
actionsSuspended: Te,
|
|
163
|
+
isAccessRestricted: b && !x.canRead,
|
|
164
|
+
table: S ? H : {
|
|
165
|
+
...H,
|
|
166
|
+
rows: [],
|
|
167
|
+
statusCards: void 0,
|
|
168
|
+
isError: !1
|
|
169
|
+
},
|
|
170
|
+
isTableLoading: S ? H.isLoading || D && H.rows.length === 0 : D,
|
|
171
|
+
isError: E || S && H.isError,
|
|
172
|
+
onRetry: E ? we : H.onRetry,
|
|
173
|
+
details: U,
|
|
174
|
+
detailsOpen: F && S,
|
|
175
|
+
closeDetails: Ne,
|
|
176
|
+
form: {
|
|
177
|
+
...W,
|
|
178
|
+
open: C && W.open,
|
|
179
|
+
counterpartView: C ? W.counterpartView : "none",
|
|
180
|
+
counterpartForm: {
|
|
181
|
+
...W.counterpartForm,
|
|
182
|
+
submit: d(T, W.counterpartForm.submit)
|
|
183
|
+
},
|
|
184
|
+
submit: d(T, W.submit),
|
|
185
|
+
submitDraft: d(T, W.submitDraft),
|
|
186
|
+
submitPrimary: d(T, W.submitPrimary)
|
|
187
|
+
},
|
|
188
|
+
openCreate: je,
|
|
189
|
+
measureUnitsOpen: C && L,
|
|
190
|
+
openMeasureUnits: De,
|
|
191
|
+
closeMeasureUnits: z,
|
|
192
|
+
actions: {
|
|
193
|
+
...G,
|
|
194
|
+
actionDialog: C ? G.actionDialog : void 0,
|
|
195
|
+
sendOpen: C && G.sendOpen,
|
|
196
|
+
paymentOpen: C && G.paymentOpen,
|
|
197
|
+
openAction: d(T, G.openAction),
|
|
198
|
+
confirmAction: d(T, G.confirmAction),
|
|
199
|
+
submitSend: d(T, G.submitSend),
|
|
200
|
+
submitPayment: d(T, G.submitPayment)
|
|
201
|
+
},
|
|
202
|
+
actionsModal: {
|
|
203
|
+
...B,
|
|
204
|
+
isOpen: C && B.isOpen,
|
|
205
|
+
send: d(T, B.send),
|
|
206
|
+
saveItems: d(T, B.saveItems)
|
|
207
|
+
},
|
|
208
|
+
handleRowClick: Me,
|
|
209
|
+
handleActionClick: Pe,
|
|
210
|
+
handleDetailsActionClick: Fe
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function d(e, t) {
|
|
214
|
+
return (...n) => {
|
|
215
|
+
e && t(...n);
|
|
143
216
|
};
|
|
144
217
|
}
|
|
145
218
|
//#endregion
|
|
146
|
-
export {
|
|
219
|
+
export { u as useReceivablesWidget };
|
|
@@ -59,6 +59,8 @@ var r = {
|
|
|
59
59
|
errorTitle: "Failed to load receivables",
|
|
60
60
|
errorDescription: "Something went wrong while fetching receivables. Please try again.",
|
|
61
61
|
errorRetry: "Try again",
|
|
62
|
+
accessRestrictedTitle: "Access Restricted",
|
|
63
|
+
accessRestrictedDescription: "You don’t have permissions to view this page. Contact your system administrator for details.",
|
|
62
64
|
statusBadge: r
|
|
63
65
|
}, o = {
|
|
64
66
|
...e,
|