@tesouro/embedded-components-react 0.5.8 → 0.5.11
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/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +4 -78
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +84 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +4 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +5 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +3 -32
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +30 -39
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +37 -166
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +164 -39
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +48 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +1 -50
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +45 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +13 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +8 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +7 -59
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +64 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +8 -24
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +18 -139
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +144 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +24 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +26 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +102 -98
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +91 -84
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +92 -87
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +133 -129
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index40.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -9,27 +9,27 @@ import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/
|
|
|
9
9
|
import { useCreatePayableMutation as r, useDeletePayableFileMutation as i, useSubmitPayableForApprovalMutation as a, useUpdatePayableMutation as o, useValidatePayableMutation as s } from "../../data-access/dist/index13.js";
|
|
10
10
|
import "../../data-access/dist/index.js";
|
|
11
11
|
import { BILL_CREATE_MESSAGE_LABELS_EN as c } from "./index47.js";
|
|
12
|
-
import { encodeFileToBase64 as
|
|
13
|
-
import { mapBillFormToPayload as
|
|
14
|
-
import { validateBillCompleteness as
|
|
15
|
-
import { useCallback as
|
|
12
|
+
import { encodeFileToBase64 as l } from "./index53.js";
|
|
13
|
+
import { mapBillFormToPayload as u, mapLineItemsToPayload as d } from "./index54.js";
|
|
14
|
+
import { validateBillCompleteness as f, validateBillTotalIsPayable as p, validateBillTotals as m, validateLineItems as h, validateStoredAmountDue as ee } from "./index55.js";
|
|
15
|
+
import { useCallback as g, useRef as _, useState as v } from "react";
|
|
16
16
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
|
|
17
|
-
var
|
|
17
|
+
var y = {
|
|
18
18
|
document_id: "invoiceNumber",
|
|
19
19
|
issued_at: "invoiceDate",
|
|
20
20
|
due_date: "dueDate",
|
|
21
21
|
counterpart_id: "vendor"
|
|
22
|
-
},
|
|
23
|
-
function
|
|
22
|
+
}, b = { tax_amount: "tax" };
|
|
23
|
+
function x(e) {
|
|
24
24
|
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function S(e) {
|
|
27
27
|
return !!t(e)?.includes("line_items_enabled");
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function C(e, t = c) {
|
|
30
30
|
let n = {}, r = {}, i = [];
|
|
31
31
|
for (let a of e) {
|
|
32
|
-
let e = a.loc[0] ?? t.unknownValidationField, o =
|
|
32
|
+
let e = a.loc[0] ?? t.unknownValidationField, o = y[e], s = b[e], c = x(a) ? t.requiredField : a.msg;
|
|
33
33
|
o ? n[o] = c : s ? r[s] = c : i.push(t.unmappedValidationError(e, c));
|
|
34
34
|
}
|
|
35
35
|
return i.length && (n.form = i.join(" ")), {
|
|
@@ -37,7 +37,7 @@ function x(e, t = c) {
|
|
|
37
37
|
totalsErrors: Object.keys(r).length ? r : void 0
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function te(e, t) {
|
|
41
41
|
if (!e && !t) return;
|
|
42
42
|
let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
43
43
|
for (let i of r) n[i] = {
|
|
@@ -46,161 +46,165 @@ function S(e, t) {
|
|
|
46
46
|
};
|
|
47
47
|
return n;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
let
|
|
49
|
+
function w({ payableId: t, form: y, counterpartId: b, clearCounterpart: x, prepareVendorForSave: w, onSaved: T, onPayableCreated: E, readSavedStatus: D, onDraftSaved: O, onFinalized: k, labels: A }) {
|
|
50
|
+
let j = {
|
|
51
51
|
...c,
|
|
52
|
-
...
|
|
53
|
-
}, [
|
|
54
|
-
let t =
|
|
55
|
-
return
|
|
52
|
+
...A
|
|
53
|
+
}, [M, N] = v(), P = t ?? M, [F, I] = v(), L = g(() => I(void 0), []), [R, z] = v(!1), B = g(() => z(!0), []), [V, H] = v(), U = _(!1), [ne, re] = v(0), W = g(() => re((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = g(() => y.isTotalsDirty ? m(y.discount, y.tax, y.totalOverride, j) : void 0, [y, j]), Q = g(() => {
|
|
54
|
+
let t = h(y.lineItems, j), n = Z();
|
|
55
|
+
return y.setLineItemErrors(t), y.setTotalsErrors(n), !t && !n || (y.setErrors(void 0), t && e.error(j.lineItemsNeedAttention), W(), !1);
|
|
56
56
|
}, [
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
y,
|
|
58
|
+
j,
|
|
59
59
|
W,
|
|
60
60
|
Z
|
|
61
|
-
]), $ =
|
|
62
|
-
let t = !
|
|
63
|
-
base64EncodedFile: await
|
|
64
|
-
fileName:
|
|
65
|
-
} : void 0, n =
|
|
66
|
-
values:
|
|
67
|
-
counterpartId:
|
|
68
|
-
clearCounterpart:
|
|
61
|
+
]), $ = g(async (e) => {
|
|
62
|
+
let t = !P && F ? {
|
|
63
|
+
base64EncodedFile: await l(F),
|
|
64
|
+
fileName: F.name
|
|
65
|
+
} : void 0, n = u({
|
|
66
|
+
values: y.values,
|
|
67
|
+
counterpartId: b,
|
|
68
|
+
clearCounterpart: x,
|
|
69
69
|
counterpartBankAccountId: e,
|
|
70
|
-
editedTotals:
|
|
71
|
-
discount:
|
|
72
|
-
tax:
|
|
73
|
-
total:
|
|
70
|
+
editedTotals: y.isTotalsDirty ? {
|
|
71
|
+
discount: y.discount,
|
|
72
|
+
tax: y.tax,
|
|
73
|
+
total: y.totalOverride
|
|
74
74
|
} : void 0,
|
|
75
75
|
document: t
|
|
76
|
-
}), r =
|
|
76
|
+
}), r = P;
|
|
77
77
|
if (r ? await q.mutateAsync({
|
|
78
78
|
path: { payable_id: r },
|
|
79
79
|
body: n
|
|
80
|
-
}) : (r = (await G.mutateAsync({ body: n }))?.id, r && (
|
|
81
|
-
if (
|
|
80
|
+
}) : (r = (await G.mutateAsync({ body: n }))?.id, r && (N(r), E?.(r), t && I(void 0))), !r) throw Error("Payable was created without an id");
|
|
81
|
+
if (R) {
|
|
82
82
|
try {
|
|
83
83
|
await K.mutateAsync({ path: { payable_id: r } });
|
|
84
84
|
} catch {}
|
|
85
|
-
|
|
85
|
+
z(!1);
|
|
86
86
|
}
|
|
87
87
|
return await J.mutateAsync({
|
|
88
88
|
path: { payable_id: r },
|
|
89
|
-
body: { data:
|
|
89
|
+
body: { data: d(y.lineItems) }
|
|
90
90
|
}), r;
|
|
91
91
|
}, [
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
b,
|
|
93
|
+
x,
|
|
94
94
|
G,
|
|
95
95
|
K,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
N,
|
|
105
|
-
J,
|
|
96
|
+
R,
|
|
97
|
+
y.discount,
|
|
98
|
+
y.isTotalsDirty,
|
|
99
|
+
y.lineItems,
|
|
100
|
+
y.tax,
|
|
101
|
+
y.totalOverride,
|
|
102
|
+
y.values,
|
|
103
|
+
E,
|
|
106
104
|
P,
|
|
105
|
+
J,
|
|
106
|
+
F,
|
|
107
107
|
q
|
|
108
|
-
]),
|
|
109
|
-
|
|
110
|
-
}, [K,
|
|
108
|
+
]), ie = g(async () => {
|
|
109
|
+
P && (await K.mutateAsync({ path: { payable_id: P } }), z(!1));
|
|
110
|
+
}, [K, P]);
|
|
111
111
|
return {
|
|
112
|
-
saveDraft:
|
|
113
|
-
if (!
|
|
114
|
-
|
|
112
|
+
saveDraft: g(async () => {
|
|
113
|
+
if (!U.current && Q()) {
|
|
114
|
+
U.current = !0, H("draft");
|
|
115
115
|
try {
|
|
116
|
-
let t = await
|
|
116
|
+
let t = await w?.();
|
|
117
117
|
if (t && !t.ok) return;
|
|
118
118
|
let n = await $(t?.counterpartBankAccountId);
|
|
119
|
-
|
|
120
|
-
let r = await
|
|
121
|
-
return e.success(r === "draft" ?
|
|
119
|
+
y.setErrors(void 0), T?.(n), O?.(n);
|
|
120
|
+
let r = await D?.();
|
|
121
|
+
return e.success(r === "draft" ? j.submittedDemoted : j.draftSaved), n;
|
|
122
122
|
} catch (e) {
|
|
123
|
-
|
|
123
|
+
y.setSaveFailureMessage(S(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
|
|
124
124
|
return;
|
|
125
125
|
} finally {
|
|
126
|
-
|
|
126
|
+
H(void 0), U.current = !1;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}, [
|
|
130
|
-
|
|
130
|
+
y,
|
|
131
131
|
Q,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
j.discountTaxBlockedByLineItems,
|
|
133
|
+
j.draftSaved,
|
|
134
|
+
j.saveFailed,
|
|
135
|
+
j.submittedDemoted,
|
|
136
|
+
O,
|
|
137
|
+
T,
|
|
136
138
|
D,
|
|
137
139
|
w,
|
|
138
|
-
E,
|
|
139
|
-
C,
|
|
140
140
|
$,
|
|
141
141
|
W
|
|
142
142
|
]),
|
|
143
|
-
finalize:
|
|
144
|
-
if (
|
|
145
|
-
let t =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
finalize: g(async () => {
|
|
144
|
+
if (U.current) return;
|
|
145
|
+
let t = h(y.lineItems, j), n = Z(), r = p(y.total, j), i = y.isTotalsDirty ? ee(y.totalOverride, y.discount, j) : void 0, a = n || r || i ? {
|
|
146
|
+
...i,
|
|
147
|
+
...r,
|
|
148
|
+
...n
|
|
149
|
+
} : void 0, { formErrors: o, lineItemErrors: s } = f(y.values, b, y.lineItems, j), c = te(s, t);
|
|
150
|
+
y.setLineItemErrors(c), y.setTotalsErrors(a);
|
|
151
|
+
let l = o ?? {};
|
|
152
|
+
if (y.setErrors(Object.keys(l).length ? l : void 0), t && e.error(j.lineItemsNeedAttention), c || a || Object.keys(l).length) {
|
|
149
153
|
W();
|
|
150
154
|
return;
|
|
151
155
|
}
|
|
152
|
-
|
|
156
|
+
U.current = !0, H("finalize");
|
|
153
157
|
try {
|
|
154
158
|
let t;
|
|
155
159
|
try {
|
|
156
|
-
let e = await
|
|
160
|
+
let e = await w?.();
|
|
157
161
|
if (e && !e.ok) return;
|
|
158
162
|
t = await $(e?.counterpartBankAccountId);
|
|
159
163
|
} catch (e) {
|
|
160
|
-
|
|
164
|
+
y.setSaveFailureMessage(S(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
|
|
161
165
|
return;
|
|
162
166
|
}
|
|
163
|
-
|
|
167
|
+
T?.(t);
|
|
164
168
|
try {
|
|
165
169
|
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
166
170
|
if (n.validation_errors.length) {
|
|
167
|
-
let e =
|
|
168
|
-
|
|
171
|
+
let e = C(n.validation_errors, j);
|
|
172
|
+
y.setErrors(e.formErrors), y.setTotalsErrors(e.totalsErrors), W();
|
|
169
173
|
return;
|
|
170
174
|
}
|
|
171
|
-
await X.mutateAsync({ path: { payable_id: t } }),
|
|
175
|
+
await X.mutateAsync({ path: { payable_id: t } }), y.setErrors(void 0), k?.(t), e.success(j.billFinalized);
|
|
172
176
|
} catch {
|
|
173
|
-
|
|
177
|
+
y.setSaveFailureMessage(j.finalizeFailed), W();
|
|
174
178
|
}
|
|
175
179
|
} finally {
|
|
176
|
-
|
|
180
|
+
H(void 0), U.current = !1;
|
|
177
181
|
}
|
|
178
182
|
}, [
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
b,
|
|
184
|
+
y,
|
|
185
|
+
j,
|
|
186
|
+
k,
|
|
187
|
+
T,
|
|
183
188
|
w,
|
|
184
|
-
C,
|
|
185
189
|
$,
|
|
186
190
|
W,
|
|
187
191
|
X,
|
|
188
192
|
Z,
|
|
189
193
|
Y
|
|
190
194
|
]),
|
|
191
|
-
payableId:
|
|
192
|
-
isSavingDraft:
|
|
193
|
-
isFinalizing:
|
|
194
|
-
stagedFile:
|
|
195
|
-
stageFile:
|
|
196
|
-
clearStagedFile:
|
|
197
|
-
scrollToErrorToken:
|
|
198
|
-
isFileDeletionPending:
|
|
199
|
-
requestFileDeletion:
|
|
200
|
-
detachFileNow:
|
|
195
|
+
payableId: P,
|
|
196
|
+
isSavingDraft: V === "draft",
|
|
197
|
+
isFinalizing: V === "finalize",
|
|
198
|
+
stagedFile: F,
|
|
199
|
+
stageFile: I,
|
|
200
|
+
clearStagedFile: L,
|
|
201
|
+
scrollToErrorToken: ne,
|
|
202
|
+
isFileDeletionPending: R,
|
|
203
|
+
requestFileDeletion: B,
|
|
204
|
+
detachFileNow: ie,
|
|
201
205
|
isDeletingFile: K.isPending,
|
|
202
206
|
hasFileDeletionFailed: K.isError
|
|
203
207
|
};
|
|
204
208
|
}
|
|
205
209
|
//#endregion
|
|
206
|
-
export {
|
|
210
|
+
export { C as mapValidationErrorsToForm, w as useBillCreateController };
|