@tesouro/embedded-components-react 0.5.205 → 0.5.207
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/README.md +1 -1
- package/dist/index.d.ts +51 -4
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +51 -4
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +84 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +31 -25
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +109 -193
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +154 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +193 -135
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +37 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +140 -86
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +42 -47
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +58 -313
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +91 -65
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +108 -102
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +48 -249
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +365 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +75 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +115 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +285 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +93 -407
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +430 -86
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +17 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +92 -16
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +24 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +0 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +3 -264
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +16 -70
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +1 -424
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +4 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +12 -93
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +5 -179
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +1 -344
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +264 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +72 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +402 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +106 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +249 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +344 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +195 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +29 -202
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +183 -137
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +157 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +16 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +25 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +220 -198
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +124 -84
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js
CHANGED
|
@@ -1,318 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"use client";
|
|
5
|
-
import { getStateOptions as e } from "../../../shared/util/dist/lib/usStates.js";
|
|
6
|
-
import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
-
import { usePaymentTermsQuery as n } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
|
|
8
|
-
import { COUNTERPART_MESSAGE_LABELS_EN as r } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
9
|
-
import { useCounterpartAddressesQuery as i } from "../../../shared/counterpart-management/data-access/dist/index7.js";
|
|
10
|
-
import { useCounterpartForm as a } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
11
|
-
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
12
|
-
import { buildLineItemControls as ee, commitLineItemField as te, commitTaxRateInput as ne, convertPriceInput as re, createLineItem as o, getCurrencySymbol as ie, isBlankLineItem as ae, lineItemFromProduct as oe, reconcileMeasureUnits as se, sanitizeLineItemPatch as ce, sanitizeTaxRateInput as le, stepLineItemQuantity as ue, stripBlankLineItems as de, summarizeLineItemErrors as fe, toSheetLineItem as pe, validateLineItems as me } from "./index6.js";
|
|
13
|
-
import { buildReceivableAttachmentsView as he } from "./index7.js";
|
|
14
|
-
import { createEmptyReceivableFormValues as s, getPaymentTermOptions as ge, hasReceivableFormErrors as _e, receivableFormValuesToCreatePayload as ve, receivableFormValuesToLineItemChanges as ye, receivableFormValuesToUpdatePayload as be, receivableToFormValues as xe, validateReceivableForm as Se } from "./index8.js";
|
|
15
|
-
import { useCreateReceivableMutation as Ce, useUpdateReceivableMutation as we } from "../../data-access/dist/index6.js";
|
|
16
|
-
import "../../data-access/dist/index.js";
|
|
17
|
-
import { useReceivableAttachmentUploads as Te } from "./index12.js";
|
|
18
|
-
import { useReceivableBankAccount as Ee } from "./index14.js";
|
|
19
|
-
import { calculateInvoiceTotals as De } from "./index15.js";
|
|
20
|
-
import { getCurrencyOptions as Oe } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
21
|
-
import { useMeasureUnitsQuery as ke } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
22
|
-
import { useMeasureUnits as Ae } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
23
|
-
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
24
|
-
import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
1
|
+
import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
|
|
2
|
+
import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
|
|
3
|
+
import "../../../shared/data-access/dist/index.js";
|
|
25
4
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}));
|
|
35
|
-
}, []), H = Te({
|
|
36
|
-
attachments: D.attachments,
|
|
37
|
-
setAttachments: Le,
|
|
38
|
-
receivableId: T
|
|
39
|
-
}), { reset: U, discardUploads: W, commitRemovals: G } = H, Re = D.type === "invoice" ? he({
|
|
40
|
-
attachments: D.attachments,
|
|
41
|
-
pendingUploads: H.pendingUploads,
|
|
42
|
-
isCountLimitReached: H.isCountLimitReached,
|
|
43
|
-
isRecurring: !1,
|
|
44
|
-
messages: p
|
|
45
|
-
}) : void 0, ze = c((e) => {
|
|
46
|
-
O((t) => ({
|
|
47
|
-
...t,
|
|
48
|
-
customerId: e ?? ""
|
|
49
|
-
}));
|
|
50
|
-
}, []), K = a({
|
|
51
|
-
view: A,
|
|
52
|
-
setView: Ne,
|
|
53
|
-
selectedId: D.customerId || void 0,
|
|
54
|
-
setSelectedId: ze,
|
|
55
|
-
messages: Fe,
|
|
56
|
-
counterpartType: "customer",
|
|
57
|
-
counterpart: void 0,
|
|
58
|
-
primaryAddress: Ie
|
|
59
|
-
}), Be = c((e) => O((t) => ({
|
|
60
|
-
...t,
|
|
61
|
-
...e
|
|
62
|
-
})), []), q = Ee({
|
|
63
|
-
open: x,
|
|
64
|
-
bankAccountId: D.bankAccountId,
|
|
65
|
-
embeddedBankName: je,
|
|
66
|
-
messages: p,
|
|
67
|
-
onSelect: Be
|
|
68
|
-
}), J = q.reset, Y = c(() => {
|
|
69
|
-
v.current = [], F(void 0), w("create"), E(void 0), O(s()), k({}), L(!1), U();
|
|
70
|
-
}, [U]), Ve = c((e = "invoice") => {
|
|
71
|
-
J(), v.current = [], F(void 0), w("create"), E(void 0), O({
|
|
72
|
-
...s(),
|
|
73
|
-
type: e
|
|
74
|
-
}), k({}), U(), L(!1), S(!0);
|
|
75
|
-
}, [U, J]), He = c((e) => {
|
|
76
|
-
e.type !== "credit_note" && (J(), v.current = e.line_items, y.current = e.currency, F(void 0), w("edit"), E(e.id), O(xe(e, N)), k({}), L(!1), U(), S(!0));
|
|
77
|
-
}, [
|
|
78
|
-
U,
|
|
79
|
-
J,
|
|
80
|
-
N
|
|
81
|
-
]);
|
|
82
|
-
l(() => {
|
|
83
|
-
N?.length && O((e) => {
|
|
84
|
-
let t = se(e.lineItems, N);
|
|
85
|
-
return t === e.lineItems ? e : {
|
|
86
|
-
...e,
|
|
87
|
-
lineItems: t
|
|
88
|
-
};
|
|
89
|
-
});
|
|
90
|
-
}, [N]);
|
|
91
|
-
let X = H.isUploading, Ue = c(() => {
|
|
92
|
-
X || (W(), S(!1), k({}));
|
|
93
|
-
}, [W, X]), We = c((e) => {
|
|
94
|
-
let t = e.taxRate === void 0 ? e : {
|
|
95
|
-
...e,
|
|
96
|
-
taxRate: le(e.taxRate)
|
|
97
|
-
}, { currency: n, type: r } = t;
|
|
98
|
-
if (r !== void 0 && r !== "invoice" && W(), n === void 0) {
|
|
99
|
-
O((e) => ({
|
|
100
|
-
...e,
|
|
101
|
-
...t
|
|
102
|
-
}));
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
R.current = !0, O((e) => e.currency === n ? {
|
|
106
|
-
...e,
|
|
107
|
-
...t
|
|
108
|
-
} : {
|
|
109
|
-
...e,
|
|
110
|
-
...t,
|
|
111
|
-
lineItems: e.lineItems.map((t) => ({
|
|
112
|
-
...t,
|
|
113
|
-
price: re(t.price, e.currency, n)
|
|
114
|
-
}))
|
|
115
|
-
});
|
|
116
|
-
}, [W]), Ge = c(() => {
|
|
117
|
-
O((e) => {
|
|
118
|
-
let t = ne(e.taxRate);
|
|
119
|
-
return t === e.taxRate ? e : {
|
|
120
|
-
...e,
|
|
121
|
-
taxRate: t
|
|
122
|
-
};
|
|
123
|
-
});
|
|
124
|
-
}, []), Z = c((e, t) => {
|
|
125
|
-
let n = me(e, {
|
|
126
|
-
currency: t,
|
|
127
|
-
messages: p
|
|
128
|
-
});
|
|
129
|
-
k((e) => ({
|
|
130
|
-
...e,
|
|
131
|
-
lineItems: n,
|
|
132
|
-
lineItemsSummary: fe(n)
|
|
133
|
-
}));
|
|
134
|
-
}, [p]), Q = c((e, { validate: t }) => {
|
|
135
|
-
t && (R.current = !0), O((t) => ({
|
|
136
|
-
...t,
|
|
137
|
-
lineItems: e(t.lineItems)
|
|
138
|
-
}));
|
|
139
|
-
}, []);
|
|
140
|
-
l(() => {
|
|
141
|
-
R.current && (R.current = !1, Z(D.lineItems, D.currency));
|
|
142
|
-
}, [
|
|
143
|
-
Z,
|
|
144
|
-
D.currency,
|
|
145
|
-
D.lineItems
|
|
146
|
-
]);
|
|
147
|
-
let Ke = c((e, t) => {
|
|
148
|
-
let { unit: n, ...r } = t, i = ce(r);
|
|
149
|
-
i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), Q((t) => t.map((t) => t.id === e ? {
|
|
150
|
-
...t,
|
|
151
|
-
...i
|
|
152
|
-
} : t), { validate: I });
|
|
153
|
-
}, [Q, I]), qe = c((e, t) => {
|
|
154
|
-
Q((n) => n.map((n) => n.id === e ? {
|
|
155
|
-
...n,
|
|
156
|
-
...oe({
|
|
157
|
-
product: t,
|
|
158
|
-
currency: D.currency,
|
|
159
|
-
unitNamesById: P
|
|
160
|
-
})
|
|
161
|
-
} : n), { validate: !0 });
|
|
162
|
-
}, [
|
|
163
|
-
Q,
|
|
164
|
-
P,
|
|
165
|
-
D.currency
|
|
166
|
-
]), $ = c((e, t) => {
|
|
167
|
-
t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
168
|
-
...n,
|
|
169
|
-
...t.patch
|
|
170
|
-
} : n), { validate: !0 });
|
|
171
|
-
}, [Q]), Je = c((e, t) => {
|
|
172
|
-
let n = D.lineItems.find((t) => t.id === e);
|
|
173
|
-
n && $(e, te({
|
|
174
|
-
lineItem: n,
|
|
175
|
-
field: t,
|
|
176
|
-
rowCount: D.lineItems.length,
|
|
177
|
-
currency: D.currency
|
|
178
|
-
}));
|
|
179
|
-
}, [
|
|
180
|
-
$,
|
|
181
|
-
D.currency,
|
|
182
|
-
D.lineItems
|
|
183
|
-
]), Ye = c((e, t) => {
|
|
184
|
-
let n = D.lineItems.find((t) => t.id === e);
|
|
185
|
-
n && $(e, ue({
|
|
186
|
-
lineItem: n,
|
|
187
|
-
step: t,
|
|
188
|
-
rowCount: D.lineItems.length
|
|
189
|
-
}));
|
|
190
|
-
}, [$, D.lineItems]), Xe = c(() => {
|
|
191
|
-
let e = o(D.currency);
|
|
192
|
-
F(e.id), O((t) => ({
|
|
193
|
-
...t,
|
|
194
|
-
lineItems: [...t.lineItems, e]
|
|
195
|
-
}));
|
|
196
|
-
}, [D.currency]), Ze = c((e) => {
|
|
197
|
-
Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
198
|
-
}, [Q]), Qe = c(async () => {
|
|
199
|
-
if (X) return;
|
|
200
|
-
if (M.isLoading) {
|
|
201
|
-
k({ form: p.lineItemsLoading });
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
let e = de(D.lineItems), n = e.length === D.lineItems.length ? D : {
|
|
205
|
-
...D,
|
|
206
|
-
lineItems: e
|
|
207
|
-
};
|
|
208
|
-
n !== D && O(n);
|
|
209
|
-
let r = Se({
|
|
210
|
-
values: n,
|
|
211
|
-
billingAddressId: V,
|
|
212
|
-
messages: p
|
|
213
|
-
});
|
|
214
|
-
if (_e(r)) {
|
|
215
|
-
k(r), L(!0);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
k({});
|
|
219
|
-
try {
|
|
220
|
-
if (C === "edit" && T) {
|
|
221
|
-
let e = { receivable_id: T };
|
|
222
|
-
await _.mutateAsync({
|
|
223
|
-
path: e,
|
|
224
|
-
body: be({
|
|
225
|
-
values: n,
|
|
226
|
-
billingAddressId: V ?? "",
|
|
227
|
-
lineItemChanges: ye({
|
|
228
|
-
values: n,
|
|
229
|
-
originalLineItems: v.current,
|
|
230
|
-
originalCurrency: y.current,
|
|
231
|
-
unitNamesById: P,
|
|
232
|
-
units: N
|
|
233
|
-
})
|
|
234
|
-
})
|
|
235
|
-
}), G(), S(!1), Y();
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
let e = await g.mutateAsync({ body: ve({
|
|
239
|
-
values: n,
|
|
240
|
-
billingAddressId: V ?? "",
|
|
241
|
-
unitNamesById: P
|
|
242
|
-
}) });
|
|
243
|
-
S(!1), Y(), e?.id && h?.(e.id, e.type);
|
|
244
|
-
} catch (e) {
|
|
245
|
-
k({ form: t(e) ?? p.genericError });
|
|
246
|
-
}
|
|
247
|
-
}, [
|
|
248
|
-
V,
|
|
249
|
-
G,
|
|
250
|
-
g,
|
|
251
|
-
T,
|
|
252
|
-
X,
|
|
253
|
-
p,
|
|
254
|
-
C,
|
|
255
|
-
h,
|
|
256
|
-
Y,
|
|
257
|
-
N,
|
|
258
|
-
P,
|
|
259
|
-
M.isLoading,
|
|
260
|
-
_,
|
|
261
|
-
D
|
|
262
|
-
]), $e = u(() => ({
|
|
263
|
-
...D,
|
|
264
|
-
lineItems: D.lineItems.map(pe)
|
|
265
|
-
}), [D]), et = u(() => ee(D.lineItems), [D.lineItems]), tt = u(() => De({
|
|
266
|
-
lineItems: D.lineItems.filter((e) => !ae(e)),
|
|
267
|
-
currency: D.currency,
|
|
268
|
-
taxRate: Number(D.taxRate) || void 0
|
|
269
|
-
}), [
|
|
270
|
-
D.currency,
|
|
271
|
-
D.lineItems,
|
|
272
|
-
D.taxRate
|
|
273
|
-
]);
|
|
5
|
+
var n = {
|
|
6
|
+
routingNumber: "",
|
|
7
|
+
accountNumber: "",
|
|
8
|
+
accountHolderName: "",
|
|
9
|
+
displayName: ""
|
|
10
|
+
};
|
|
11
|
+
function r(n) {
|
|
12
|
+
let r = new Set(n ?? []);
|
|
274
13
|
return {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
14
|
+
canReadEmbedded: e(r, [t.BankAccountReadOrg]),
|
|
15
|
+
canReadExternal: e(r, [t.ExternalBankAccountReadOrg]),
|
|
16
|
+
canAddAccount: e(r, [t.BankAccountWriteOrg])
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function i(e, t) {
|
|
20
|
+
return [e.displayName || t.bankAccountFallbackName, e.accountNumberLast4].filter(Boolean).join(" - ");
|
|
21
|
+
}
|
|
22
|
+
function a(e, t, n) {
|
|
23
|
+
switch (e) {
|
|
24
|
+
case "INTERNAL": return t ? n.bankAccountPoweredBy.replace("{embeddedBankName}", t) : void 0;
|
|
25
|
+
case "EXTERNAL": return n.bankAccountLinked;
|
|
26
|
+
default: return;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function o({ accounts: e, embeddedBankName: t, messages: n }) {
|
|
30
|
+
return e.map((e) => ({
|
|
31
|
+
value: e.id,
|
|
32
|
+
label: i(e, n),
|
|
33
|
+
sourceLabel: a(e.type, t, n)
|
|
34
|
+
})).sort((e, t) => e.label.localeCompare(t.label));
|
|
35
|
+
}
|
|
36
|
+
function s({ options: e, isLoading: t, selectedId: n, isAddingAccount: r, canAddAccount: i, formValues: a, formErrors: o, isSaving: s }) {
|
|
37
|
+
return t ? { kind: "loading" } : e.length > 0 && !r ? {
|
|
38
|
+
kind: "picker",
|
|
39
|
+
options: e,
|
|
40
|
+
selected: e.find((e) => e.value === n),
|
|
41
|
+
canAddAccount: i
|
|
42
|
+
} : i ? {
|
|
43
|
+
kind: "form",
|
|
44
|
+
values: a,
|
|
45
|
+
errors: o,
|
|
46
|
+
canCancel: e.length > 0,
|
|
47
|
+
isSaving: s
|
|
48
|
+
} : { kind: "restricted" };
|
|
49
|
+
}
|
|
50
|
+
function c(e, t) {
|
|
51
|
+
let n = {}, r = e.accountHolderName.trim(), i = e.accountNumber.trim(), a = e.routingNumber.trim();
|
|
52
|
+
return r ? r.length > 255 && (n.accountHolderName = t.bankAccountHolderNameTooLong) : n.accountHolderName = t.bankAccountHolderNameRequired, i ? /^\d+$/.test(i) ? i.length < 4 ? n.accountNumber = t.bankAccountNumberTooShort : i.length > 17 && (n.accountNumber = t.bankAccountNumberTooLong) : n.accountNumber = t.bankAccountNumberDigitsOnly : n.accountNumber = t.bankAccountNumberRequired, a ? /^\d{9}$/.test(a) || (n.routingNumber = t.bankAccountRoutingNumberInvalid) : n.routingNumber = t.bankAccountRoutingNumberRequired, e.displayName.length > 200 && (n.displayName = t.bankAccountNicknameTooLong), n;
|
|
53
|
+
}
|
|
54
|
+
function l(e) {
|
|
55
|
+
return {
|
|
56
|
+
display_name: e.displayName || void 0,
|
|
57
|
+
account_holder_name: e.accountHolderName.trim() || void 0,
|
|
58
|
+
account_number: e.accountNumber.trim() || void 0,
|
|
59
|
+
routing_number: e.routingNumber.trim() || void 0
|
|
315
60
|
};
|
|
316
61
|
}
|
|
317
62
|
//#endregion
|
|
318
|
-
export {
|
|
63
|
+
export { n as EMPTY_BANK_ACCOUNT_FORM_VALUES, l as bankAccountFormToPayload, s as buildBankAccountSectionView, o as buildPaymentAccountOptions, r as getBankAccountPermissions, i as getPaymentAccountLineLabel, a as getPaymentAccountSourceLabel, c as validateBankAccountForm };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js
CHANGED
|
@@ -2,74 +2,100 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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 { useWidgetConfig as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
|
+
import "../../../shared/feature/dist/index.js";
|
|
10
|
+
import { useCreateEntityBankAccountMutation as r, usePaymentAccountsQuery as i } from "../../data-access/dist/index3.js";
|
|
7
11
|
import "../../data-access/dist/index.js";
|
|
8
|
-
import {
|
|
12
|
+
import { EMPTY_BANK_ACCOUNT_FORM_VALUES as a, bankAccountFormToPayload as o, buildBankAccountSectionView as s, buildPaymentAccountOptions as c, getBankAccountPermissions as l, validateBankAccountForm as u } from "./index16.js";
|
|
13
|
+
import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
9
14
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
|
|
39
|
-
}, []),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
15
|
+
function g({ open: g, bankAccountId: _, embeddedBankName: v, messages: y, onSelect: b }) {
|
|
16
|
+
let { initResponse: x } = n(), S = p(() => l(x?.scopes), [x?.scopes]), { paymentAccounts: C, isLoading: w, isIncomplete: T } = i({
|
|
17
|
+
enabled: g,
|
|
18
|
+
canReadEmbedded: S.canReadEmbedded,
|
|
19
|
+
canReadExternal: S.canReadExternal
|
|
20
|
+
}), E = r(), [D, O] = h(!1), [k, A] = h(a), [j, M] = h({}), N = m(!1), P = d(() => {
|
|
21
|
+
N.current = !1, O(!1), A(a), M({});
|
|
22
|
+
}, []);
|
|
23
|
+
f(() => {
|
|
24
|
+
if (!g || T || N.current || C.length !== 1) return;
|
|
25
|
+
let [e] = C;
|
|
26
|
+
N.current = !0, b({
|
|
27
|
+
bankAccountId: e.id,
|
|
28
|
+
bankAccountType: e.type
|
|
29
|
+
});
|
|
30
|
+
}, [
|
|
31
|
+
T,
|
|
32
|
+
b,
|
|
33
|
+
g,
|
|
34
|
+
C
|
|
35
|
+
]);
|
|
36
|
+
let F = d((e) => {
|
|
37
|
+
let t = C.find((t) => t.id === e);
|
|
38
|
+
t && b({
|
|
39
|
+
bankAccountId: t.id,
|
|
40
|
+
bankAccountType: t.type
|
|
41
|
+
});
|
|
42
|
+
}, [b, C]), I = d(() => O(!0), []), L = d(() => {
|
|
43
|
+
O(!1), A(a), M({});
|
|
44
|
+
}, []), R = d((e) => A((t) => ({
|
|
45
|
+
...t,
|
|
46
|
+
...e
|
|
47
|
+
})), []), z = d(async () => {
|
|
48
|
+
let n = u(k, y);
|
|
49
|
+
if (M(n), !(Object.keys(n).length > 0)) try {
|
|
50
|
+
let t = await E.mutateAsync({ body: o(k) });
|
|
51
|
+
O(!1), A(a), b({
|
|
52
|
+
bankAccountId: t.id,
|
|
53
|
+
bankAccountType: "BANK_DETAILS"
|
|
54
|
+
}), e.success(y.bankAccountCreated.replace("{name}", t.display_name ?? ""));
|
|
55
|
+
} catch (n) {
|
|
56
|
+
e.error(t(n) ?? y.bankAccountCreateFailed);
|
|
57
|
+
}
|
|
58
|
+
}, [
|
|
59
|
+
E,
|
|
60
|
+
k,
|
|
61
|
+
y,
|
|
62
|
+
b
|
|
63
|
+
]), B = p(() => c({
|
|
64
|
+
accounts: C,
|
|
65
|
+
embeddedBankName: v,
|
|
66
|
+
messages: y
|
|
67
|
+
}), [
|
|
68
|
+
v,
|
|
69
|
+
y,
|
|
70
|
+
C
|
|
71
|
+
]);
|
|
44
72
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
view: p(() => s({
|
|
74
|
+
options: B,
|
|
75
|
+
isLoading: w,
|
|
76
|
+
selectedId: _,
|
|
77
|
+
isAddingAccount: D,
|
|
78
|
+
canAddAccount: S.canAddAccount,
|
|
79
|
+
formValues: k,
|
|
80
|
+
formErrors: j,
|
|
81
|
+
isSaving: E.isPending
|
|
82
|
+
}), [
|
|
83
|
+
_,
|
|
84
|
+
E.isPending,
|
|
85
|
+
j,
|
|
86
|
+
k,
|
|
87
|
+
D,
|
|
88
|
+
w,
|
|
89
|
+
B,
|
|
90
|
+
S.canAddAccount
|
|
91
|
+
]),
|
|
92
|
+
reset: P,
|
|
93
|
+
selectAccount: F,
|
|
94
|
+
openAddAccount: I,
|
|
95
|
+
cancelAddAccount: L,
|
|
96
|
+
updateAccountForm: R,
|
|
97
|
+
saveAccount: z
|
|
64
98
|
};
|
|
65
99
|
}
|
|
66
|
-
var u = {
|
|
67
|
-
documentLabel: "document_id",
|
|
68
|
-
customerLabel: "counterpart_name",
|
|
69
|
-
status: "status",
|
|
70
|
-
issueDateLabel: "issue_date",
|
|
71
|
-
dueDateLabel: "due_date",
|
|
72
|
-
totalLabel: "total_amount"
|
|
73
|
-
};
|
|
74
100
|
//#endregion
|
|
75
|
-
export {
|
|
101
|
+
export { g as useReceivableBankAccount };
|