@tesouro/embedded-components-react 0.3.11 → 0.3.13
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 +12 -0
- package/dist/index.js +1 -1
- package/dist/lib/BillPayWidget.js +1 -1
- package/dist/lib/CardsWidget.d.ts +12 -0
- package/dist/lib/CreateCardWidget.d.ts +12 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +8 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +13 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +7 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +54 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +24 -52
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +61 -113
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +123 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +11 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +40 -50
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +51 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +5 -72
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +71 -48
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +48 -79
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +91 -33
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +33 -137
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +138 -67
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +63 -200
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +194 -184
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +180 -50
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +64 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +12 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +46 -30
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +26 -158
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +159 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +32 -98
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +102 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +13 -241
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +244 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +4 -29
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +28 -81
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +77 -130
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +145 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +2 -43
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +45 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +1 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +6 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +9 -92
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +94 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +3 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +7 -20
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +14 -51
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +59 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +3 -110
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +107 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +8 -40
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +38 -15
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +18 -98
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +92 -173
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +180 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +5 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +6 -112
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +114 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +0 -24
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +25 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +56 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +4 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index47.js +75 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index52.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index53.js +120 -115
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index5.js +1 -2
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index5.js +19 -12
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index6.js +22 -0
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index4.js +4 -1
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index5.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index6.js +22 -37
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js +167 -110
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +18 -18
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +111 -104
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +144 -128
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js +20 -18
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +1998 -1935
- package/package.json +1 -1
|
@@ -1,38 +1,166 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import "../../../shared/ui/dist/index.js";
|
|
7
|
+
import { useReplacePayableLineItemsMutation as t } from "../../data-access/dist/index7.js";
|
|
8
|
+
import { useCreatePayableMutation as n, useSubmitPayableForApprovalMutation as r, useUpdatePayableMutation as i, useValidatePayableMutation as a } from "../../data-access/dist/index10.js";
|
|
9
|
+
import "../../data-access/dist/index.js";
|
|
10
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as o } from "./index28.js";
|
|
11
|
+
import { encodeFileToBase64 as s } from "./index33.js";
|
|
12
|
+
import { mapBillFormToPayload as c, mapLineItemsToPayload as l } from "./index34.js";
|
|
13
|
+
import { validateBillCompleteness as u, validateBillTotals as d, validateLineItems as f } from "./index35.js";
|
|
14
|
+
import { useCallback as p, useRef as m, useState as h } from "react";
|
|
1
15
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
16
|
+
var g = {
|
|
17
|
+
document_id: "invoiceNumber",
|
|
18
|
+
issued_at: "invoiceDate",
|
|
19
|
+
due_date: "dueDate",
|
|
20
|
+
counterpart_id: "vendor"
|
|
21
|
+
};
|
|
22
|
+
function _(e) {
|
|
23
|
+
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
11
24
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
25
|
+
function v(e, t = o) {
|
|
26
|
+
let n = {}, r = [];
|
|
27
|
+
for (let i of e) {
|
|
28
|
+
let e = i.loc[0] ?? t.unknownValidationField, a = g[e], o = _(i) ? t.requiredField : i.msg;
|
|
29
|
+
a ? n[a] = o : r.push(t.unmappedValidationError(e, o));
|
|
30
|
+
}
|
|
31
|
+
return r.length && (n.form = r.join(" ")), n;
|
|
32
|
+
}
|
|
33
|
+
function y(e, t) {
|
|
34
|
+
if (!e && !t) return;
|
|
35
|
+
let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
36
|
+
for (let i of r) n[i] = {
|
|
37
|
+
...e?.[i],
|
|
38
|
+
...t?.[i]
|
|
39
|
+
};
|
|
40
|
+
return n;
|
|
14
41
|
}
|
|
15
|
-
function
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
function b({ payableId: g, form: _, counterpartId: b, clearCounterpart: x, prepareVendorForSave: S, onSaved: C, onPayableCreated: w, onDraftSaved: T, onFinalized: E, labels: D }) {
|
|
43
|
+
let O = {
|
|
44
|
+
...o,
|
|
45
|
+
...D
|
|
46
|
+
}, [k, A] = h(), j = g ?? k, [M, N] = h(), P = p(() => N(void 0), []), [F, I] = h(), L = m(!1), R = n(), z = i(), B = t(), V = a(), H = r(), U = p(() => {
|
|
47
|
+
let t = f(_.lineItems, O), n = d(_.discount, _.tax, _.totalOverride, O);
|
|
48
|
+
return _.setLineItemErrors(t), !t && !n || (t ? (_.setErrors(void 0), e.error(O.lineItemsNeedAttention)) : _.setErrors(n), !1);
|
|
49
|
+
}, [_, O]), W = p(async () => {
|
|
50
|
+
let e = !j && M ? {
|
|
51
|
+
base64EncodedFile: await s(M),
|
|
52
|
+
fileName: M.name
|
|
53
|
+
} : void 0, t = c({
|
|
54
|
+
values: _.values,
|
|
55
|
+
counterpartId: b,
|
|
56
|
+
clearCounterpart: x,
|
|
57
|
+
editedTotals: _.isTotalsDirty ? {
|
|
58
|
+
discount: _.discount,
|
|
59
|
+
tax: _.tax,
|
|
60
|
+
total: _.totalOverride
|
|
61
|
+
} : void 0,
|
|
62
|
+
document: e
|
|
63
|
+
}), n = j;
|
|
64
|
+
if (n ? await z.mutateAsync({
|
|
65
|
+
path: { payable_id: n },
|
|
66
|
+
body: t
|
|
67
|
+
}) : (n = (await R.mutateAsync({ body: t }))?.id, n && (A(n), w?.(n), e && N(void 0))), !n) throw Error("Payable was created without an id");
|
|
68
|
+
return await B.mutateAsync({
|
|
69
|
+
path: { payable_id: n },
|
|
70
|
+
body: { data: l(_.lineItems) }
|
|
71
|
+
}), n;
|
|
72
|
+
}, [
|
|
73
|
+
b,
|
|
74
|
+
x,
|
|
75
|
+
R,
|
|
76
|
+
_.discount,
|
|
77
|
+
_.isTotalsDirty,
|
|
78
|
+
_.lineItems,
|
|
79
|
+
_.tax,
|
|
80
|
+
_.totalOverride,
|
|
81
|
+
_.values,
|
|
82
|
+
w,
|
|
83
|
+
j,
|
|
84
|
+
B,
|
|
85
|
+
M,
|
|
86
|
+
z
|
|
87
|
+
]);
|
|
29
88
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
89
|
+
saveDraft: p(async () => {
|
|
90
|
+
if (!L.current && U()) {
|
|
91
|
+
L.current = !0, I("draft");
|
|
92
|
+
try {
|
|
93
|
+
if (await S?.() === !1) return;
|
|
94
|
+
let t = await W();
|
|
95
|
+
_.setErrors(void 0), C?.(t), T?.(t), e.success(O.draftSaved);
|
|
96
|
+
} catch {
|
|
97
|
+
_.setErrors({ form: O.saveFailed });
|
|
98
|
+
} finally {
|
|
99
|
+
I(void 0), L.current = !1;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, [
|
|
103
|
+
_,
|
|
104
|
+
U,
|
|
105
|
+
O.draftSaved,
|
|
106
|
+
O.saveFailed,
|
|
107
|
+
T,
|
|
108
|
+
C,
|
|
109
|
+
S,
|
|
110
|
+
W
|
|
111
|
+
]),
|
|
112
|
+
finalize: p(async () => {
|
|
113
|
+
if (L.current) return;
|
|
114
|
+
let t = f(_.lineItems, O), n = d(_.discount, _.tax, _.totalOverride, O), { formErrors: r, lineItemErrors: i } = u(_.values, b, _.lineItems, O), a = y(i, t);
|
|
115
|
+
_.setLineItemErrors(a);
|
|
116
|
+
let o = {
|
|
117
|
+
...r,
|
|
118
|
+
...n
|
|
119
|
+
};
|
|
120
|
+
if (_.setErrors(Object.keys(o).length ? o : void 0), t && e.error(O.lineItemsNeedAttention), !(a || Object.keys(o).length)) {
|
|
121
|
+
L.current = !0, I("finalize");
|
|
122
|
+
try {
|
|
123
|
+
let t;
|
|
124
|
+
try {
|
|
125
|
+
if (await S?.() === !1) return;
|
|
126
|
+
t = await W();
|
|
127
|
+
} catch {
|
|
128
|
+
_.setErrors({ form: O.saveFailed });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
C?.(t);
|
|
132
|
+
try {
|
|
133
|
+
let n = await V.mutateAsync({ path: { payable_id: t } });
|
|
134
|
+
if (n.validation_errors.length) {
|
|
135
|
+
_.setErrors(v(n.validation_errors, O));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
await H.mutateAsync({ path: { payable_id: t } }), _.setErrors(void 0), E?.(t), e.success(O.billFinalized);
|
|
139
|
+
} catch {
|
|
140
|
+
_.setErrors({ form: O.finalizeFailed });
|
|
141
|
+
}
|
|
142
|
+
} finally {
|
|
143
|
+
I(void 0), L.current = !1;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, [
|
|
147
|
+
b,
|
|
148
|
+
_,
|
|
149
|
+
O,
|
|
150
|
+
E,
|
|
151
|
+
C,
|
|
152
|
+
S,
|
|
153
|
+
W,
|
|
154
|
+
H,
|
|
155
|
+
V
|
|
156
|
+
]),
|
|
157
|
+
payableId: j,
|
|
158
|
+
isSavingDraft: F === "draft",
|
|
159
|
+
isFinalizing: F === "finalize",
|
|
160
|
+
stagedFile: M,
|
|
161
|
+
stageFile: N,
|
|
162
|
+
clearStagedFile: P
|
|
35
163
|
};
|
|
36
164
|
}
|
|
37
165
|
//#endregion
|
|
38
|
-
export {
|
|
166
|
+
export { v as mapValidationErrorsToForm, b as useBillCreateController };
|
|
@@ -1,104 +1,38 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { calculateTotal as e, displayLineAmount as t, parseMoneyToMinorUnits as n } from "./index33.js";
|
|
6
|
-
import { emptyLineItem as r, mapPayableToBillForm as i } from "./index36.js";
|
|
7
|
-
import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
|
|
8
1
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js
|
|
9
|
-
function
|
|
10
|
-
return
|
|
2
|
+
function e() {
|
|
3
|
+
return {
|
|
4
|
+
id: crypto.randomUUID(),
|
|
5
|
+
description: "",
|
|
6
|
+
glCode: "",
|
|
7
|
+
quantity: "1",
|
|
8
|
+
price: "",
|
|
9
|
+
amount: ""
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function t(e) {
|
|
13
|
+
return typeof e == "number" ? (e / 100).toFixed(2) : "";
|
|
11
14
|
}
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
...t,
|
|
27
|
-
...e
|
|
28
|
-
})), E(!0);
|
|
29
|
-
}, []), M = a((e) => {
|
|
30
|
-
w((t) => {
|
|
31
|
-
if (!t?.[e]) return t;
|
|
32
|
-
let n = { ...t };
|
|
33
|
-
return delete n[e], Object.keys(n).length ? n : void 0;
|
|
34
|
-
});
|
|
35
|
-
}, []), N = a((e, t) => {
|
|
36
|
-
M(e), m((n) => n.map((n) => {
|
|
37
|
-
if (n.id !== e) return n;
|
|
38
|
-
let r = {
|
|
39
|
-
...n,
|
|
40
|
-
...t
|
|
41
|
-
};
|
|
42
|
-
return "amount" in t ? r : {
|
|
43
|
-
...r,
|
|
44
|
-
amount: l(r.quantity, r.price, r.amount)
|
|
45
|
-
};
|
|
46
|
-
})), O(!0), b(void 0);
|
|
47
|
-
}, [M]), P = a((e, t) => {
|
|
48
|
-
M(e), m((n) => n.map((n) => {
|
|
49
|
-
if (n.id !== e) return n;
|
|
50
|
-
let r = Number.parseFloat(n.quantity), i = String(Math.max(1, (Number.isFinite(r) ? r : 1) + t));
|
|
51
|
-
return {
|
|
52
|
-
...n,
|
|
53
|
-
quantity: i,
|
|
54
|
-
amount: l(i, n.price, n.amount)
|
|
55
|
-
};
|
|
56
|
-
})), O(!0), b(void 0);
|
|
57
|
-
}, [M]), F = a((e) => {
|
|
58
|
-
M(e), m((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), O(!0), b(void 0);
|
|
59
|
-
}, [M]), I = a(() => {
|
|
60
|
-
m((e) => [...e, r()]), O(!0), b(void 0);
|
|
61
|
-
}, []), L = a((e) => {
|
|
62
|
-
g(e), A(!0), b(void 0);
|
|
63
|
-
}, []), R = a((e) => {
|
|
64
|
-
v(e), A(!0), b(void 0);
|
|
65
|
-
}, []), z = a((e) => {
|
|
66
|
-
b(e), A(!0);
|
|
67
|
-
}, []), B = s(() => p.map((e) => ({
|
|
68
|
-
...e,
|
|
69
|
-
onChange: (t) => N(e.id, t),
|
|
70
|
-
onQuantityStep: (t) => P(e.id, t),
|
|
71
|
-
onRemove: () => F(e.id)
|
|
72
|
-
})), [
|
|
73
|
-
p,
|
|
74
|
-
N,
|
|
75
|
-
F,
|
|
76
|
-
P
|
|
77
|
-
]), V = s(() => e(p, _, h), [
|
|
78
|
-
p,
|
|
79
|
-
_,
|
|
80
|
-
h
|
|
81
|
-
]);
|
|
15
|
+
function n({ payable: n, lineItems: r }) {
|
|
16
|
+
let i = {
|
|
17
|
+
invoiceNumber: n.document_id ?? "",
|
|
18
|
+
invoiceDate: n.issued_at ?? "",
|
|
19
|
+
dueDate: n.due_date ?? "",
|
|
20
|
+
poNumber: ""
|
|
21
|
+
}, a = r.map((e) => ({
|
|
22
|
+
id: e.id,
|
|
23
|
+
description: e.name ?? "",
|
|
24
|
+
glCode: e.ledger_account_id ?? "",
|
|
25
|
+
quantity: e.quantity == null ? "" : String(e.quantity),
|
|
26
|
+
price: t(e.unit_price),
|
|
27
|
+
amount: t(e.subtotal)
|
|
28
|
+
}));
|
|
82
29
|
return {
|
|
83
|
-
values:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
onChange: j,
|
|
89
|
-
lineItems: p,
|
|
90
|
-
lineItemRows: B,
|
|
91
|
-
discount: h,
|
|
92
|
-
onDiscountChange: L,
|
|
93
|
-
tax: _,
|
|
94
|
-
onTaxChange: R,
|
|
95
|
-
total: y ?? V,
|
|
96
|
-
totalOverride: y,
|
|
97
|
-
onTotalChange: z,
|
|
98
|
-
onAddLineItem: I,
|
|
99
|
-
isTotalsDirty: k,
|
|
100
|
-
isDirty: T || D || k
|
|
30
|
+
values: i,
|
|
31
|
+
lineItems: a.length ? a : [e()],
|
|
32
|
+
discount: t(n.discount),
|
|
33
|
+
tax: t(n.tax_amount),
|
|
34
|
+
total: t(n.total_amount)
|
|
101
35
|
};
|
|
102
36
|
}
|
|
103
37
|
//#endregion
|
|
104
|
-
export {
|
|
38
|
+
export { e as emptyLineItem, n as mapPayableToBillForm };
|
|
@@ -1,15 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { calculateTotal as e, displayLineAmount as t, parseMoneyToMinorUnits as n } from "./index34.js";
|
|
6
|
+
import { emptyLineItem as r, mapPayableToBillForm as i } from "./index37.js";
|
|
7
|
+
import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
|
|
1
8
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
function l(e, r, i) {
|
|
10
|
+
return n(r) === null ? i : t(e, r);
|
|
11
|
+
}
|
|
12
|
+
function u({ payable: t, lineItems: n } = {}) {
|
|
13
|
+
let u = s(() => i({
|
|
14
|
+
payable: t ?? {},
|
|
15
|
+
lineItems: n ?? []
|
|
16
|
+
}), [t, n]), [d, f] = c(u.values), [p, m] = c(u.lineItems), [h, g] = c(u.discount), [_, v] = c(u.tax), [y, b] = c(u.total || void 0), [x, S] = c(), [C, w] = c(), [T, E] = c(!1), [D, O] = c(!1), [k, A] = c(!1);
|
|
17
|
+
o(() => {
|
|
18
|
+
T || f(u.values);
|
|
19
|
+
}, [u]), o(() => {
|
|
20
|
+
D || m(u.lineItems);
|
|
21
|
+
}, [u]), o(() => {
|
|
22
|
+
k || (g(u.discount), v(u.tax), b(u.total || void 0));
|
|
23
|
+
}, [u]);
|
|
24
|
+
let j = a((e) => {
|
|
25
|
+
f((t) => ({
|
|
26
|
+
...t,
|
|
27
|
+
...e
|
|
28
|
+
})), E(!0);
|
|
29
|
+
}, []), M = a((e) => {
|
|
30
|
+
w((t) => {
|
|
31
|
+
if (!t?.[e]) return t;
|
|
32
|
+
let n = { ...t };
|
|
33
|
+
return delete n[e], Object.keys(n).length ? n : void 0;
|
|
34
|
+
});
|
|
35
|
+
}, []), N = a((e, t) => {
|
|
36
|
+
M(e), m((n) => n.map((n) => {
|
|
37
|
+
if (n.id !== e) return n;
|
|
38
|
+
let r = {
|
|
39
|
+
...n,
|
|
40
|
+
...t
|
|
41
|
+
};
|
|
42
|
+
return "amount" in t ? r : {
|
|
43
|
+
...r,
|
|
44
|
+
amount: l(r.quantity, r.price, r.amount)
|
|
45
|
+
};
|
|
46
|
+
})), O(!0), b(void 0);
|
|
47
|
+
}, [M]), P = a((e, t) => {
|
|
48
|
+
M(e), m((n) => n.map((n) => {
|
|
49
|
+
if (n.id !== e) return n;
|
|
50
|
+
let r = Number.parseFloat(n.quantity), i = String(Math.max(1, (Number.isFinite(r) ? r : 1) + t));
|
|
51
|
+
return {
|
|
52
|
+
...n,
|
|
53
|
+
quantity: i,
|
|
54
|
+
amount: l(i, n.price, n.amount)
|
|
55
|
+
};
|
|
56
|
+
})), O(!0), b(void 0);
|
|
57
|
+
}, [M]), F = a((e) => {
|
|
58
|
+
M(e), m((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), O(!0), b(void 0);
|
|
59
|
+
}, [M]), I = a(() => {
|
|
60
|
+
m((e) => [...e, r()]), O(!0), b(void 0);
|
|
61
|
+
}, []), L = a((e) => {
|
|
62
|
+
g(e), A(!0), b(void 0);
|
|
63
|
+
}, []), R = a((e) => {
|
|
64
|
+
v(e), A(!0), b(void 0);
|
|
65
|
+
}, []), z = a((e) => {
|
|
66
|
+
b(e), A(!0);
|
|
67
|
+
}, []), B = s(() => p.map((e) => ({
|
|
68
|
+
...e,
|
|
69
|
+
onChange: (t) => N(e.id, t),
|
|
70
|
+
onQuantityStep: (t) => P(e.id, t),
|
|
71
|
+
onRemove: () => F(e.id)
|
|
72
|
+
})), [
|
|
73
|
+
p,
|
|
74
|
+
N,
|
|
75
|
+
F,
|
|
76
|
+
P
|
|
77
|
+
]), V = s(() => e(p, _, h), [
|
|
78
|
+
p,
|
|
79
|
+
_,
|
|
80
|
+
h
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
values: d,
|
|
84
|
+
errors: x,
|
|
85
|
+
setErrors: S,
|
|
86
|
+
lineItemErrors: C,
|
|
87
|
+
setLineItemErrors: w,
|
|
88
|
+
onChange: j,
|
|
89
|
+
lineItems: p,
|
|
90
|
+
lineItemRows: B,
|
|
91
|
+
discount: h,
|
|
92
|
+
onDiscountChange: L,
|
|
93
|
+
tax: _,
|
|
94
|
+
onTaxChange: R,
|
|
95
|
+
total: y ?? V,
|
|
96
|
+
totalOverride: y,
|
|
97
|
+
onTotalChange: z,
|
|
98
|
+
onAddLineItem: I,
|
|
99
|
+
isTotalsDirty: k,
|
|
100
|
+
isDirty: T || D || k
|
|
101
|
+
};
|
|
102
|
+
}
|
|
14
103
|
//#endregion
|
|
15
|
-
export {
|
|
104
|
+
export { u as useBillForm };
|