@tesouro/embedded-components-react 0.7.46 → 0.7.47
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 +4 -0
- package/dist/lib/CounterpartsWidget.d.ts +4 -0
- package/dist/lib/CounterpartsWidgetPublic.d.ts +4 -0
- package/dist/lib/CustomersWidget.d.ts +2 -0
- package/dist/lib/ReceivablesWidget.d.ts +2 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +40 -42
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +1 -3
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index3.js +44 -44
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +13 -13
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +85 -84
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index10.js +238 -241
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index11.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +6 -5
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index5.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
5
|
import { extractApiErrorMessage as e } from "../../../../util/dist/lib/apiErrors.js";
|
|
6
|
-
import { addressFormToCreatePayload as t, addressFormToUpdatePayload as n, addressResponseToFormValues as r, bankAccountToAchFormValues as i, counterpartFormBankAccountToCreatePayload as a, counterpartFormBankAccountToUpdatePayload as o, counterpartFormToCreatePayload as s, counterpartFormToUpdatePayload as
|
|
7
|
-
import { useCreateCounterpartMutation as _, useUpdateCounterpartMutation as
|
|
8
|
-
import { useCreateCounterpartBankAccountMutation as
|
|
6
|
+
import { addressFormToCreatePayload as t, addressFormToUpdatePayload as n, addressResponseToFormValues as r, bankAccountToAchFormValues as i, counterpartFormBankAccountToCreatePayload as a, counterpartFormBankAccountToUpdatePayload as o, counterpartFormToCreatePayload as s, counterpartFormToUpdatePayload as c, counterpartToFormValues as l, emptyCounterpartFormValues as u, getAchInstructions as d, hasCounterpartFormAddressValues as f, hasCounterpartFormBankAccountValues as p, hasCounterpartFormErrors as m, resolveCounterpartBankAccountWrite as h, validateCounterpartForm as g, withoutUnchangedContactErrors as ee } from "./helpers.js";
|
|
7
|
+
import { useCreateCounterpartMutation as _, useUpdateCounterpartMutation as v } from "../../../data-access/dist/index3.js";
|
|
8
|
+
import { useCreateCounterpartBankAccountMutation as y, useUpdateCounterpartBankAccountMutation as te } from "../../../data-access/dist/index4.js";
|
|
9
9
|
import { useCreateCounterpartAddressMutation as ne, useUpdateCounterpartAddressMutation as re } from "../../../data-access/dist/index5.js";
|
|
10
10
|
import "../../../data-access/dist/index.js";
|
|
11
|
-
import { useCallback as b, useLayoutEffect as
|
|
11
|
+
import { useCallback as b, useLayoutEffect as x, useState as S } from "react";
|
|
12
12
|
//#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js
|
|
13
|
-
function
|
|
14
|
-
if (!t) return
|
|
13
|
+
function C(e, t) {
|
|
14
|
+
if (!t) return f(e);
|
|
15
15
|
let n = r(t);
|
|
16
16
|
return e.address.line1.trim() !== n.line1.trim() || e.address.line2.trim() !== n.line2.trim() || e.address.city.trim() !== n.city.trim() || e.address.state.trim() !== n.state.trim() || e.address.postalCode.trim() !== n.postalCode.trim();
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
if (!t) return
|
|
18
|
+
function w(e, t) {
|
|
19
|
+
if (!t) return p(e);
|
|
20
20
|
let n = i(t);
|
|
21
21
|
return e.bankAccount.accountHolderName.trim() !== n.accountHolderName.trim() || e.bankAccount.routingNumber.trim() !== n.routingNumber.trim() || e.bankAccount.accountNumber.trim() !== n.accountNumber.trim();
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function T(e, t) {
|
|
24
24
|
let n = { ...e };
|
|
25
25
|
if ([
|
|
26
26
|
"legalName",
|
|
@@ -45,146 +45,147 @@ function C(e, t) {
|
|
|
45
45
|
}
|
|
46
46
|
return JSON.stringify(n) === JSON.stringify(e) ? e : n;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
let
|
|
48
|
+
function E({ view: r, setView: E, selectedId: D, setSelectedId: O, messages: k, counterpartType: A, counterpart: j, primaryAddress: M, bankAccounts: N, isBankAccountsLoading: P, isBankAccountsError: F, includeBankAccount: I = !0 }) {
|
|
49
|
+
let L = A === "vendor" && I, R = _(), z = ne(), B = y(), V = v(), H = re(), U = te(), [W, G] = S(() => u()), [ie, K] = S({}), [ae, q] = S({
|
|
50
50
|
address: !1,
|
|
51
51
|
bankAccount: !1
|
|
52
|
-
}), [J, Y] =
|
|
53
|
-
|
|
54
|
-
address:
|
|
52
|
+
}), [J, Y] = S(), [X, Z] = S(), oe = R.isPending || z.isPending || B.isPending || U.isPending || V.isPending || H.isPending, se = b(() => {
|
|
53
|
+
O(void 0), Z(void 0), Y(void 0), q({
|
|
54
|
+
address: A === "vendor",
|
|
55
55
|
bankAccount: !1
|
|
56
|
-
}),
|
|
56
|
+
}), G(u("organization", A)), K({}), E("create");
|
|
57
57
|
}, [
|
|
58
|
+
A,
|
|
58
59
|
O,
|
|
59
|
-
E
|
|
60
|
-
w
|
|
60
|
+
E
|
|
61
61
|
]), ce = b(() => {
|
|
62
|
-
if (!
|
|
63
|
-
let e =
|
|
62
|
+
if (!j || L && (P || F)) return;
|
|
63
|
+
let e = L ? d(N) : void 0, t = l(j, M);
|
|
64
64
|
Z(void 0), Y(e?.id), q({
|
|
65
|
-
address:
|
|
65
|
+
address: A === "vendor" || f(t),
|
|
66
66
|
bankAccount: !1
|
|
67
|
-
}),
|
|
67
|
+
}), G({
|
|
68
68
|
...t,
|
|
69
69
|
...e ? { bankAccount: i(e) } : {}
|
|
70
|
-
}),
|
|
70
|
+
}), K({}), E("edit");
|
|
71
71
|
}, [
|
|
72
|
-
j,
|
|
73
|
-
k,
|
|
74
72
|
N,
|
|
75
|
-
|
|
73
|
+
j,
|
|
76
74
|
A,
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
F,
|
|
76
|
+
P,
|
|
77
|
+
M,
|
|
78
|
+
E,
|
|
79
|
+
L
|
|
79
80
|
]), le = b(() => {
|
|
80
|
-
|
|
81
|
-
}, [
|
|
81
|
+
E("none");
|
|
82
|
+
}, [E]), ue = b(() => {
|
|
82
83
|
q((e) => ({
|
|
83
84
|
...e,
|
|
84
85
|
address: !0
|
|
85
86
|
}));
|
|
86
|
-
}, []), [Q, $] =
|
|
87
|
-
return
|
|
88
|
-
let e = r === "edit" ? "edit" : "create"
|
|
87
|
+
}, []), [Q, $] = S(!1), de = b(() => $(!0), []);
|
|
88
|
+
return x(() => {
|
|
89
|
+
let e = g(W, k, A, (r === "edit" ? "edit" : "create") == "edit" && L && !!J);
|
|
89
90
|
if (Q) {
|
|
90
|
-
$(!1),
|
|
91
|
+
$(!1), K(e);
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
K((t) => m(t) ? T(t, e) : t);
|
|
94
95
|
}, [
|
|
95
96
|
J,
|
|
96
|
-
|
|
97
|
+
A,
|
|
97
98
|
Q,
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
k,
|
|
100
|
+
W,
|
|
100
101
|
r,
|
|
101
|
-
|
|
102
|
+
L
|
|
102
103
|
]), {
|
|
103
|
-
values:
|
|
104
|
-
errors:
|
|
105
|
-
setValues:
|
|
104
|
+
values: W,
|
|
105
|
+
errors: ie,
|
|
106
|
+
setValues: G,
|
|
106
107
|
isSubmitting: oe,
|
|
107
|
-
sectionsToExpand:
|
|
108
|
+
sectionsToExpand: ae,
|
|
108
109
|
expandAddress: ue,
|
|
109
110
|
openCreate: se,
|
|
110
111
|
openEdit: ce,
|
|
111
112
|
close: le,
|
|
112
113
|
submit: b(async () => {
|
|
113
|
-
let i = r === "edit" ? "edit" : "create",
|
|
114
|
-
if (
|
|
115
|
-
address: e.address || !!
|
|
116
|
-
bankAccount: e.bankAccount || !!
|
|
114
|
+
let i = r === "edit" ? "edit" : "create", u = ee(g(W, k, A, i === "edit" && L && !!J), W, i === "edit" && j ? l(j, M) : void 0);
|
|
115
|
+
if (m(u)) return K(u), q((e) => ({
|
|
116
|
+
address: e.address || !!u.address,
|
|
117
|
+
bankAccount: e.bankAccount || !!u.bankAccount
|
|
117
118
|
})), { ok: !1 };
|
|
118
|
-
|
|
119
|
+
K({}), q({
|
|
119
120
|
address: !1,
|
|
120
121
|
bankAccount: !1
|
|
121
122
|
});
|
|
122
123
|
let _ = X;
|
|
123
124
|
try {
|
|
124
|
-
if (r === "edit" &&
|
|
125
|
-
Z(void 0), await
|
|
126
|
-
path: { counterpart_id:
|
|
127
|
-
body:
|
|
125
|
+
if (r === "edit" && D) {
|
|
126
|
+
Z(void 0), await V.mutateAsync({
|
|
127
|
+
path: { counterpart_id: D },
|
|
128
|
+
body: c(W, A)
|
|
128
129
|
});
|
|
129
|
-
let e =
|
|
130
|
+
let e = M ? C(W, M) ? H.mutateAsync({
|
|
130
131
|
path: {
|
|
131
|
-
counterpart_id:
|
|
132
|
-
address_id:
|
|
132
|
+
counterpart_id: D,
|
|
133
|
+
address_id: M.id
|
|
133
134
|
},
|
|
134
|
-
body: n(
|
|
135
|
-
}) : void 0 :
|
|
136
|
-
path: { counterpart_id:
|
|
137
|
-
body: t(
|
|
138
|
-
}) : void 0, r =
|
|
135
|
+
body: n(W.address)
|
|
136
|
+
}) : void 0 : f(W) ? z.mutateAsync({
|
|
137
|
+
path: { counterpart_id: D },
|
|
138
|
+
body: t(W.address)
|
|
139
|
+
}) : void 0, r = L && w(W, d(N)) ? h(N, J) : void 0, i = r?.kind === "update" ? U.mutateAsync({
|
|
139
140
|
path: {
|
|
140
|
-
counterpart_id:
|
|
141
|
+
counterpart_id: D,
|
|
141
142
|
bank_account_id: r.bankAccountId
|
|
142
143
|
},
|
|
143
|
-
body: o(
|
|
144
|
-
}) : r?.kind === "create" ?
|
|
145
|
-
path: { counterpart_id:
|
|
146
|
-
body: a(
|
|
147
|
-
}) : void 0, [s,
|
|
148
|
-
if (r?.kind === "create" &&
|
|
149
|
-
if (
|
|
150
|
-
return
|
|
144
|
+
body: o(W.bankAccount, { includeAchDefaults: r.includeAchDefaults })
|
|
145
|
+
}) : r?.kind === "create" ? B.mutateAsync({
|
|
146
|
+
path: { counterpart_id: D },
|
|
147
|
+
body: a(W.bankAccount, { isDefaultForCurrency: r.isDefaultForCurrency })
|
|
148
|
+
}) : void 0, [s, l] = await Promise.allSettled([e, i]);
|
|
149
|
+
if (r?.kind === "create" && l.status === "fulfilled" && Y(l.value?.id), s.status === "rejected") throw s.reason;
|
|
150
|
+
if (l.status === "rejected") throw l.reason;
|
|
151
|
+
return E("none"), {
|
|
151
152
|
ok: !0,
|
|
152
|
-
counterpartId:
|
|
153
|
+
counterpartId: D
|
|
153
154
|
};
|
|
154
155
|
}
|
|
155
|
-
return _ ||= (await
|
|
156
|
+
return _ ||= (await R.mutateAsync({ body: s(W, A) }))?.id, _ && L && p(W) && (Z(_), await B.mutateAsync({
|
|
156
157
|
path: { counterpart_id: _ },
|
|
157
|
-
body: a(
|
|
158
|
-
})), Z(void 0),
|
|
158
|
+
body: a(W.bankAccount)
|
|
159
|
+
})), Z(void 0), E("none"), _ && O(_), {
|
|
159
160
|
ok: !0,
|
|
160
161
|
counterpartId: _
|
|
161
162
|
};
|
|
162
163
|
} catch (t) {
|
|
163
|
-
return _ && (Z(_),
|
|
164
|
+
return _ && (Z(_), O(_)), K({ form: e(t) ?? k.genericError }), { ok: !1 };
|
|
164
165
|
}
|
|
165
166
|
}, [
|
|
166
167
|
r,
|
|
167
|
-
|
|
168
|
-
T,
|
|
169
|
-
X,
|
|
168
|
+
W,
|
|
170
169
|
D,
|
|
171
|
-
|
|
170
|
+
X,
|
|
172
171
|
k,
|
|
173
172
|
A,
|
|
174
173
|
j,
|
|
174
|
+
M,
|
|
175
|
+
N,
|
|
175
176
|
J,
|
|
176
|
-
|
|
177
|
-
R,
|
|
178
|
-
I,
|
|
177
|
+
z,
|
|
179
178
|
B,
|
|
179
|
+
R,
|
|
180
|
+
H,
|
|
181
|
+
U,
|
|
180
182
|
V,
|
|
181
|
-
z,
|
|
182
|
-
w,
|
|
183
183
|
E,
|
|
184
|
-
|
|
184
|
+
O,
|
|
185
|
+
L
|
|
185
186
|
]),
|
|
186
187
|
revealErrors: de
|
|
187
188
|
};
|
|
188
189
|
}
|
|
189
190
|
//#endregion
|
|
190
|
-
export {
|
|
191
|
+
export { E as useCounterpartForm };
|