@tesouro/embedded-components-react 0.5.303 → 0.5.305
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/bill-detail/feature/dist/index.js +9 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index12.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +10 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +8 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +7 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +8 -28
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +24 -157
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +20 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +13 -34
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +153 -89
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +17 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +23 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +42 -55
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +93 -107
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +77 -185
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +3 -80
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +55 -72
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +111 -113
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +184 -463
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index3.js +14 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +78 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +61 -74
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +115 -80
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +449 -216
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +116 -42
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +11 -249
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +85 -23
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +80 -648
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +240 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +44 -40
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +38 -15
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +242 -240
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +25 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +538 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +3 -66
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +42 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js +239 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index46.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js +5 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js +67 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index49.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index5.js +227 -38
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index6.js +82 -224
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index7.js +45 -82
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index8.js +4 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index9.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index29.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/BillsTab.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -3,238 +3,471 @@
|
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
5
|
import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { hasAnyScope as t } from "../../../../shared/data-access/dist/lib/hasAnyScope.js";
|
|
7
|
+
import { Scope as ee } from "../../../../shared/data-access/dist/lib/scopes.js";
|
|
8
|
+
import "../../../../shared/data-access/dist/index.js";
|
|
7
9
|
import "../../../../shared/ui/dist/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { useReplacePayableLineItemsMutation as f } from "../../data-access/dist/index4.js";
|
|
13
|
-
import { useCreatePayableMutation as p } from "../../data-access/dist/index8.js";
|
|
14
|
-
import { useDeletePayableFileMutation as m } from "../../data-access/dist/index9.js";
|
|
15
|
-
import { useSubmitPayableForApprovalMutation as h } from "../../data-access/dist/index14.js";
|
|
16
|
-
import { useUpdatePayableMutation as g } from "../../data-access/dist/index15.js";
|
|
17
|
-
import { useValidatePayableMutation as te } from "../../data-access/dist/index16.js";
|
|
10
|
+
import { useWidgetConfig as n } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
11
|
+
import "../../../../shared/feature/dist/index.js";
|
|
12
|
+
import { VENDOR_SECTION_PROPS_LABELS_EN as r } from "./index29.js";
|
|
13
|
+
import { usePayableSuggestionsQuery as i } from "../../data-access/dist/index19.js";
|
|
18
14
|
import "../../data-access/dist/index.js";
|
|
19
|
-
import {
|
|
15
|
+
import { resolvePaymentInstructionsGestures as a } from "./index15.js";
|
|
16
|
+
import { COUNTERPART_MESSAGE_LABELS_EN as o } from "../../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
17
|
+
import { counterpartFormBankAccountToCreatePayload as te, counterpartFormBankAccountToUpdatePayload as ne, getAchInstructions as s, getCounterpartEmail as c, getCounterpartName as re, getPayableAchInstructions as ie, hasCounterpartFormErrors as ae, isAchCompatibleBankAccount as l, resolveCounterpartBankAccountWrite as oe, validateAchFormValues as se, validateCounterpartForm as ce } from "../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
18
|
+
import { useCounterpartsQuery as le } from "../../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
19
|
+
import { useCreateCounterpartBankAccountMutation as ue, useUpdateCounterpartBankAccountMutation as de } from "../../../../shared/counterpart-management/data-access/dist/index5.js";
|
|
20
|
+
import { useCounterpartDetails as fe } from "../../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
|
|
21
|
+
import { useCounterpartForm as pe } from "../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
22
|
+
import "../../../../shared/counterpart-management/feature/dist/index.js";
|
|
23
|
+
import { buildVendorPrefill as me, canAutoCreateVendor as he, toCounterpartRawData as ge } from "./index31.js";
|
|
24
|
+
import { VendorInlineForm as _e } from "./index32.js";
|
|
25
|
+
import { useCallback as u, useEffect as d, useLayoutEffect as ve, useMemo as f, useRef as p, useState as m } from "react";
|
|
26
|
+
import { jsx as ye } from "react/jsx-runtime";
|
|
20
27
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var re = "pending-vendor";
|
|
32
|
-
function S(e) {
|
|
33
|
-
return !!t(e)?.includes("line_items_enabled");
|
|
34
|
-
}
|
|
35
|
-
function ie(e) {
|
|
36
|
-
return !!t(e)?.includes("A vendor could not be linked or created for this payable");
|
|
37
|
-
}
|
|
38
|
-
function C(e, t = n) {
|
|
39
|
-
let r = {}, i = {}, a = [];
|
|
40
|
-
for (let n of e) {
|
|
41
|
-
let e = n.loc[0] ?? t.unknownValidationField, o = y[e], s = b[e], c = x(n) ? t.requiredField : n.msg;
|
|
42
|
-
o ? r[o] = c : s ? i[s] = c : a.push(t.unmappedValidationError(e, c));
|
|
43
|
-
}
|
|
44
|
-
return a.length && (r.form = a.join(" ")), {
|
|
45
|
-
formErrors: r,
|
|
46
|
-
totalsErrors: Object.keys(i).length ? i : void 0
|
|
28
|
+
var be = 10, xe = 300, h = {
|
|
29
|
+
accountHolderName: "",
|
|
30
|
+
routingNumber: "",
|
|
31
|
+
accountNumber: ""
|
|
32
|
+
};
|
|
33
|
+
function Se(e) {
|
|
34
|
+
return {
|
|
35
|
+
accountHolderName: e.account_holder_name ?? "",
|
|
36
|
+
routingNumber: e.routing_number ?? "",
|
|
37
|
+
accountNumber: e.account_number ?? ""
|
|
47
38
|
};
|
|
48
39
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...t?.[i]
|
|
55
|
-
};
|
|
56
|
-
return n;
|
|
40
|
+
function g(e, t) {
|
|
41
|
+
return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
|
|
42
|
+
}
|
|
43
|
+
function Ce(e, t) {
|
|
44
|
+
return e?.find((e) => e.id === t && l(e)) ?? s(e);
|
|
57
45
|
}
|
|
58
|
-
function
|
|
59
|
-
let
|
|
60
|
-
...
|
|
61
|
-
...
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
|
|
46
|
+
function _({ payableId: s, counterpartId: l, payableCounterpartId: _, payableCounterpartBankAccountId: we, isVendorKnown: Te = !0, onCounterpartChange: Ee, requiredError: De, extractedVendor: v, readOnly: y = !1, canEditVendor: b = !0, canEditPaymentInstructions: Oe = !0, canAddPaymentInstructions: ke = !0, confirmDiscard: x = (e) => e(), labels: Ae }) {
|
|
47
|
+
let S = {
|
|
48
|
+
...r,
|
|
49
|
+
...Ae
|
|
50
|
+
}, je = Ae?.messages, C = f(() => ({
|
|
51
|
+
...o,
|
|
52
|
+
...je
|
|
53
|
+
}), [je]), { initResponse: Me } = n(), Ne = t(Me?.scopes, [ee.CounterpartReadOrg]), [w, Pe] = m(""), [T, Fe] = m(""), Ie = p(T), [E, Le] = m(), [Re, ze] = m("none"), [Be, Ve] = m(), [He, D] = m(!1), [O, k] = m(!1), [A, Ue] = m(h), j = p(A);
|
|
54
|
+
j.current = A;
|
|
55
|
+
let M = p(h), [We, N] = m(), [Ge, Ke] = m(), qe = Ge?.bankAccountId, P = p(void 0), Je = p(l), [Ye, Xe] = m(!1), [Ze, Qe] = m(!1), F = p(void 0), I = u(() => {
|
|
56
|
+
k(!1), Ue(h), M.current = h, N(void 0);
|
|
57
|
+
}, []), L = u((e) => {
|
|
58
|
+
Xe(!0), Ee(e);
|
|
59
|
+
}, [Ee]), $e = i(s, { enabled: !y && !!s && !l && !_ }), R = $e.data?.suggested_counterpart?.id, et = v?.name;
|
|
60
|
+
d(() => {
|
|
61
|
+
!y && !Ye && !l && !_ && R && L(R);
|
|
65
62
|
}, [
|
|
63
|
+
l,
|
|
64
|
+
_,
|
|
66
65
|
y,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
]),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
66
|
+
Ye,
|
|
67
|
+
R,
|
|
68
|
+
L
|
|
69
|
+
]), d(() => {
|
|
70
|
+
Je.current !== l && (Je.current = l, I(), Ke((e) => e?.counterpartId === l ? e : void 0));
|
|
71
|
+
}, [l, I]), d(() => {
|
|
72
|
+
let e = setTimeout(() => {
|
|
73
|
+
Fe(w.trim());
|
|
74
|
+
}, xe);
|
|
75
|
+
return () => clearTimeout(e);
|
|
76
|
+
}, [w]);
|
|
77
|
+
let z = f(() => me(v), [v]), B = z?.bankAccount, tt = f(() => he(v), [v]), nt = E === "create" ? !g(A, B ?? h) : O && !g(A, M.current), rt = !y && (E === "edit" || E === "create" && !!z), V = le({
|
|
78
|
+
sort: "counterpart_name",
|
|
79
|
+
order: "asc",
|
|
80
|
+
limit: be,
|
|
81
|
+
counterpart_name__icontains: T || void 0,
|
|
82
|
+
is_vendor: !0,
|
|
83
|
+
enabled: (rt || !y && !E && !l) && Te && Ne
|
|
84
|
+
});
|
|
85
|
+
d(() => {
|
|
86
|
+
V.isPlaceholderData || (Ie.current = T);
|
|
87
|
+
}, [T, V.isPlaceholderData]);
|
|
88
|
+
let it = V.isPlaceholderData && Ie.current !== T, H = fe({
|
|
89
|
+
selectedId: l,
|
|
90
|
+
enabled: Ne
|
|
91
|
+
}), at = ue(), ot = de(), U = pe({
|
|
92
|
+
view: Re,
|
|
93
|
+
setView: ze,
|
|
94
|
+
selectedId: Be,
|
|
95
|
+
setSelectedId: Ve,
|
|
96
|
+
messages: C,
|
|
97
|
+
counterpartType: "vendor",
|
|
98
|
+
counterpart: H.counterpart,
|
|
99
|
+
primaryAddress: H.primaryAddress,
|
|
100
|
+
includeBankAccount: !1
|
|
101
|
+
}), { openCreate: st, openEdit: ct, close: lt, setValues: W, submit: ut, values: dt } = U, G = f(() => {
|
|
102
|
+
let e = H.counterpart;
|
|
103
|
+
if (!e) return;
|
|
104
|
+
if (H.isBankAccountsLoading) return {
|
|
105
|
+
name: re(e),
|
|
106
|
+
email: c(e),
|
|
107
|
+
methodLabel: S.paymentMethodLoading,
|
|
108
|
+
hasPaymentInstructions: !1
|
|
109
|
+
};
|
|
110
|
+
if (H.isBankAccountsError) return {
|
|
111
|
+
name: re(e),
|
|
112
|
+
email: c(e),
|
|
113
|
+
methodLabel: S.paymentMethodUnavailable,
|
|
114
|
+
hasPaymentInstructions: !1
|
|
115
|
+
};
|
|
116
|
+
let t = ie(H.bankAccounts);
|
|
117
|
+
return {
|
|
118
|
+
name: re(e),
|
|
119
|
+
email: c(e),
|
|
120
|
+
methodLabel: t ? S.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : S.noMethod,
|
|
121
|
+
hasPaymentInstructions: !!t
|
|
122
|
+
};
|
|
123
|
+
}, [
|
|
124
|
+
H.bankAccounts,
|
|
125
|
+
H.counterpart,
|
|
126
|
+
H.isBankAccountsError,
|
|
127
|
+
H.isBankAccountsLoading,
|
|
128
|
+
S
|
|
129
|
+
]), K = f(() => {
|
|
130
|
+
let e = et?.trim();
|
|
131
|
+
if (!e || l || E) return;
|
|
132
|
+
let t = B?.accountNumber;
|
|
133
|
+
return {
|
|
134
|
+
name: e,
|
|
135
|
+
email: v?.email ?? "",
|
|
136
|
+
description: tt ? S.pendingVendorDescription : S.pendingVendorIncompleteDescription,
|
|
137
|
+
methodLabel: t ? S.paymentInstructionsValue(t.slice(-4)) : "",
|
|
138
|
+
hasPaymentInstructions: !!t
|
|
139
|
+
};
|
|
140
|
+
}, [
|
|
141
|
+
l,
|
|
142
|
+
B?.accountNumber,
|
|
143
|
+
v?.email,
|
|
144
|
+
et,
|
|
145
|
+
E,
|
|
146
|
+
tt,
|
|
147
|
+
S.paymentInstructionsValue,
|
|
148
|
+
S.pendingVendorDescription,
|
|
149
|
+
S.pendingVendorIncompleteDescription
|
|
150
|
+
]), ft = !!K && !tt, q = l === _ ? we : void 0, J = f(() => Ce(H.bankAccounts, q), [H.bankAccounts, q]), pt = f(() => ie(H.bankAccounts)?.id, [H.bankAccounts]), mt = !H.counterpart || H.isLoading || H.isFetching || H.isError || H.isBankAccountsLoading || H.isBankAccountsFetching || H.isBankAccountsError, ht = mt || H.isAddressesLoading || H.isAddressesFetching || H.isAddressesError, gt = b && !mt && H.isAddressesError ? { onRetry: H.refetchAddresses } : void 0, Y = u(() => {
|
|
151
|
+
lt(), Le(void 0), D(!1), P.current = void 0;
|
|
152
|
+
}, [lt]), X = u((e) => {
|
|
153
|
+
if (D(!1), P.current = void 0, e === "edit") Ve(l), ct();
|
|
154
|
+
else {
|
|
155
|
+
st();
|
|
156
|
+
let e = w.trim();
|
|
157
|
+
W((t) => ({
|
|
158
|
+
...t,
|
|
159
|
+
entityType: "organization",
|
|
160
|
+
legalName: e || z?.legalName || t.legalName,
|
|
161
|
+
email: z?.email || t.email,
|
|
162
|
+
phone: z?.phone || t.phone,
|
|
163
|
+
address: z?.address ?? t.address
|
|
164
|
+
})), Ue(B ?? h), N(void 0), M.current = h;
|
|
105
165
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
166
|
+
Le(e);
|
|
167
|
+
}, [
|
|
168
|
+
l,
|
|
169
|
+
B,
|
|
170
|
+
st,
|
|
171
|
+
ct,
|
|
172
|
+
w,
|
|
173
|
+
W,
|
|
174
|
+
z
|
|
175
|
+
]), _t = U.revealErrors, vt = u(() => {
|
|
176
|
+
Xe(!0), X("create"), _t();
|
|
177
|
+
let e = B ? se(B, C) : {};
|
|
178
|
+
Object.keys(e).length && N(e);
|
|
179
|
+
}, [
|
|
180
|
+
B,
|
|
181
|
+
C,
|
|
182
|
+
X,
|
|
183
|
+
_t
|
|
184
|
+
]), yt = p(!1), bt = !yt.current && !y && b && Te && !_ && !R && !Ye && ft, xt = bt && !$e.isLoading;
|
|
185
|
+
ve(() => {
|
|
186
|
+
xt && (yt.current = !0, vt());
|
|
187
|
+
}, [vt, xt]);
|
|
188
|
+
let St = u(() => {
|
|
189
|
+
let e = J ? Se(J) : h;
|
|
190
|
+
M.current = e, Ue(e), N(void 0), k(!0);
|
|
191
|
+
}, [J]), Ct = u((e) => {
|
|
192
|
+
let t = {
|
|
193
|
+
...j.current,
|
|
194
|
+
...e
|
|
195
|
+
};
|
|
196
|
+
j.current = t, Ue(t);
|
|
197
|
+
let ee = se(t, C);
|
|
198
|
+
N((e) => {
|
|
199
|
+
if (!e) return e;
|
|
200
|
+
let t = { ...e };
|
|
201
|
+
for (let e of Object.keys(t)) ee[e] || delete t[e];
|
|
202
|
+
return Object.keys(t).length ? t : void 0;
|
|
203
|
+
});
|
|
204
|
+
}, [C]), wt = u(() => {
|
|
205
|
+
nt ? x(I) : I();
|
|
116
206
|
}, [
|
|
117
|
-
b,
|
|
118
|
-
T,
|
|
119
|
-
G,
|
|
120
|
-
K,
|
|
121
|
-
z,
|
|
122
|
-
y.discount,
|
|
123
|
-
y.isTotalsDirty,
|
|
124
|
-
y.lineItems,
|
|
125
|
-
y.tax,
|
|
126
|
-
y.totalOverride,
|
|
127
|
-
y.values,
|
|
128
|
-
O,
|
|
129
207
|
I,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
208
|
+
x,
|
|
209
|
+
nt
|
|
210
|
+
]), Z = u(() => {
|
|
211
|
+
Y(), I();
|
|
212
|
+
}, [I, Y]), Q = He || nt, $ = u((e) => {
|
|
213
|
+
let t = () => {
|
|
214
|
+
Z(), e();
|
|
215
|
+
};
|
|
216
|
+
Q ? x(t) : t();
|
|
217
|
+
}, [
|
|
218
|
+
x,
|
|
219
|
+
Z,
|
|
220
|
+
Q
|
|
221
|
+
]), Tt = u(() => {
|
|
222
|
+
Q ? x(Z) : Z();
|
|
223
|
+
}, [
|
|
224
|
+
x,
|
|
225
|
+
Z,
|
|
226
|
+
Q
|
|
227
|
+
]), Et = u(async ({ closeOnSuccess: t = !0, allowIncompleteVendor: ee = !1 } = {}) => {
|
|
228
|
+
if (ee && E === "create" && !P.current) {
|
|
229
|
+
let e = j.current, t = ce({
|
|
230
|
+
...dt,
|
|
231
|
+
bankAccount: e
|
|
232
|
+
}, "create", C, "vendor");
|
|
233
|
+
if (ae(t)) return He || !g(e, B ?? h) ? {
|
|
234
|
+
ok: !0,
|
|
235
|
+
counterpartRawData: ge(dt, e, v)
|
|
236
|
+
} : { ok: !0 };
|
|
237
|
+
}
|
|
238
|
+
let n = l, r = !1, i = j.current;
|
|
239
|
+
if (!g(i, M.current)) {
|
|
240
|
+
let e = se(i, C);
|
|
241
|
+
if (Object.keys(e).length > 0) return N(e), E !== "create" && k(!0), { ok: !1 };
|
|
242
|
+
}
|
|
243
|
+
if (E === "edit" && ht) return { ok: !1 };
|
|
244
|
+
if (E) {
|
|
245
|
+
if (E === "create" && P.current) n = P.current;
|
|
246
|
+
else {
|
|
247
|
+
let e = await ut();
|
|
248
|
+
if (!e.ok) return { ok: !1 };
|
|
249
|
+
E === "create" ? (n = e.counterpartId, P.current = n) : n = e.counterpartId ?? n;
|
|
153
250
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
251
|
+
E === "create" && (r = !0);
|
|
252
|
+
}
|
|
253
|
+
if (!n) return { ok: !0 };
|
|
254
|
+
let a = H.isBankAccountsLoading || H.isBankAccountsFetching || H.isBankAccountsError;
|
|
255
|
+
if (g(i, M.current)) {
|
|
256
|
+
let e = qe ?? q;
|
|
257
|
+
return e ? (t && (k(!1), E && Y()), r && L(n), {
|
|
258
|
+
ok: !0,
|
|
259
|
+
counterpartId: n,
|
|
260
|
+
counterpartBankAccountId: e
|
|
261
|
+
}) : r ? (t && Y(), L(n), {
|
|
262
|
+
ok: !0,
|
|
263
|
+
counterpartId: n
|
|
264
|
+
}) : a ? { ok: !1 } : (t && (k(!1), E && Y()), {
|
|
265
|
+
ok: !0,
|
|
266
|
+
counterpartId: n,
|
|
267
|
+
counterpartBankAccountId: pt
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
if (a) return { ok: !1 };
|
|
271
|
+
N(void 0);
|
|
272
|
+
let o = oe(H.bankAccounts, qe ?? J?.id), s;
|
|
273
|
+
try {
|
|
274
|
+
o.kind === "update" ? (await ot.mutateAsync({
|
|
275
|
+
path: {
|
|
276
|
+
counterpart_id: n,
|
|
277
|
+
bank_account_id: o.bankAccountId
|
|
278
|
+
},
|
|
279
|
+
body: ne(i, { includeAchDefaults: o.includeAchDefaults })
|
|
280
|
+
}), s = o.bankAccountId) : s = (await at.mutateAsync({
|
|
281
|
+
path: { counterpart_id: n },
|
|
282
|
+
body: te(i, { isDefaultForCurrency: o.isDefaultForCurrency })
|
|
283
|
+
}))?.id;
|
|
284
|
+
} catch {
|
|
285
|
+
return e.error(S.bankAccountSaveFailed), {
|
|
286
|
+
ok: !1,
|
|
287
|
+
counterpartId: n
|
|
179
288
|
};
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
289
|
+
}
|
|
290
|
+
return M.current = i, Ke(s ? {
|
|
291
|
+
counterpartId: n,
|
|
292
|
+
bankAccountId: s
|
|
293
|
+
} : void 0), t && (k(!1), E && Y()), r && L(n), {
|
|
294
|
+
ok: !0,
|
|
295
|
+
counterpartId: n,
|
|
296
|
+
counterpartBankAccountId: s
|
|
297
|
+
};
|
|
298
|
+
}, [
|
|
299
|
+
Y,
|
|
300
|
+
l,
|
|
301
|
+
at,
|
|
302
|
+
H.bankAccounts,
|
|
303
|
+
H.isBankAccountsError,
|
|
304
|
+
H.isBankAccountsFetching,
|
|
305
|
+
H.isBankAccountsLoading,
|
|
306
|
+
B,
|
|
307
|
+
v,
|
|
308
|
+
E,
|
|
309
|
+
dt,
|
|
310
|
+
He,
|
|
311
|
+
ht,
|
|
312
|
+
q,
|
|
313
|
+
C,
|
|
314
|
+
pt,
|
|
315
|
+
L,
|
|
316
|
+
J,
|
|
317
|
+
ut,
|
|
318
|
+
ot,
|
|
319
|
+
qe
|
|
320
|
+
]), Dt = u((e) => {
|
|
321
|
+
if (F.current) return F.current;
|
|
322
|
+
let t = (async () => {
|
|
323
|
+
Qe(!0);
|
|
185
324
|
try {
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
let e = await E?.();
|
|
189
|
-
if (e && !e.ok) return;
|
|
190
|
-
t = await $(e?.counterpartBankAccountId, e?.counterpartId);
|
|
191
|
-
} catch (e) {
|
|
192
|
-
y.setSaveFailureMessage(S(e) ? N.discountTaxBlockedByLineItems : N.saveFailed), W();
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
D?.(t);
|
|
196
|
-
try {
|
|
197
|
-
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
198
|
-
if (n.validation_errors.length) {
|
|
199
|
-
let e = C(n.validation_errors, N);
|
|
200
|
-
y.setErrors(e.formErrors), y.setTotalsErrors(e.totalsErrors), W();
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
await X.mutateAsync({ path: { payable_id: t } }), y.setErrors(void 0), j?.(t), e.success(N.billFinalized);
|
|
204
|
-
} catch (e) {
|
|
205
|
-
ie(e) ? y.setErrors({ vendor: N.vendorResolutionFailed }) : y.setSaveFailureMessage(N.finalizeFailed), W();
|
|
206
|
-
}
|
|
325
|
+
return await Et(e);
|
|
207
326
|
} finally {
|
|
208
|
-
|
|
327
|
+
F.current = void 0, Qe(!1);
|
|
328
|
+
}
|
|
329
|
+
})();
|
|
330
|
+
return F.current = t, t;
|
|
331
|
+
}, [Et]), Ot = u(() => {
|
|
332
|
+
k(!1), E && Y();
|
|
333
|
+
}, [E, Y]), kt = f(() => (V.data?.data ?? []).map((e) => ({
|
|
334
|
+
name: re(e),
|
|
335
|
+
email: c(e),
|
|
336
|
+
onSelect: () => {
|
|
337
|
+
$(() => L(e.id));
|
|
338
|
+
}
|
|
339
|
+
})), [
|
|
340
|
+
V.data,
|
|
341
|
+
$,
|
|
342
|
+
L
|
|
343
|
+
]), At = u((e) => {
|
|
344
|
+
D(!0), W((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
|
|
345
|
+
...t,
|
|
346
|
+
...e,
|
|
347
|
+
firstName: t.firstName || t.legalName,
|
|
348
|
+
legalName: t.legalName
|
|
349
|
+
} : e.entityType === "organization" && t.entityType !== "organization" ? {
|
|
350
|
+
...t,
|
|
351
|
+
...e,
|
|
352
|
+
legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
|
|
353
|
+
} : {
|
|
354
|
+
...t,
|
|
355
|
+
...e
|
|
356
|
+
});
|
|
357
|
+
}, [W]), jt = u((e) => {
|
|
358
|
+
D(!0), W((t) => ({
|
|
359
|
+
...t,
|
|
360
|
+
address: {
|
|
361
|
+
...t.address,
|
|
362
|
+
...e
|
|
363
|
+
}
|
|
364
|
+
}));
|
|
365
|
+
}, [W]), Mt = {
|
|
366
|
+
query: w,
|
|
367
|
+
onQueryChange: Pe,
|
|
368
|
+
isLoading: bt || !Te || !Me || !!l && H.isLoading || V.isLoading || V.isFetching && it,
|
|
369
|
+
onAddVendor: () => {
|
|
370
|
+
if (E === "create") {
|
|
371
|
+
let e = w.trim(), [t, ...ee] = e.split(/\s+/);
|
|
372
|
+
W((n) => n.entityType === "individual" ? {
|
|
373
|
+
...n,
|
|
374
|
+
firstName: t,
|
|
375
|
+
lastName: ee.join(" ")
|
|
376
|
+
} : {
|
|
377
|
+
...n,
|
|
378
|
+
legalName: e
|
|
379
|
+
}), D(!0);
|
|
380
|
+
return;
|
|
209
381
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
382
|
+
$(() => X("create"));
|
|
383
|
+
},
|
|
384
|
+
results: kt
|
|
385
|
+
}, Nt = ke && (E === "create" || !mt) ? {
|
|
386
|
+
isOpen: O,
|
|
387
|
+
values: A,
|
|
388
|
+
errors: We,
|
|
389
|
+
onOpen: St,
|
|
390
|
+
onCancel: wt,
|
|
391
|
+
onChange: Ct
|
|
392
|
+
} : void 0, Pt = E !== "create" && Nt ? {
|
|
393
|
+
...Nt,
|
|
394
|
+
onOpen: E === "edit" ? () => $(St) : Nt.onOpen,
|
|
395
|
+
canEditExisting: Oe
|
|
396
|
+
} : void 0, Ft = U.isSubmitting || at.isPending || ot.isPending, It = {
|
|
397
|
+
prepareVendorForSave: Dt,
|
|
398
|
+
isVendorSavePending: Ze || Ft,
|
|
399
|
+
hasUnsavedVendorChanges: Q,
|
|
400
|
+
isPendingVendor: !!K && !ft,
|
|
401
|
+
revealIncompleteVendor: ft ? vt : void 0,
|
|
402
|
+
isEditingPayTo: !!E || O,
|
|
403
|
+
activePayToOperation: E ? "vendor" : O ? G?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
|
|
404
|
+
discardPayToEdits: Z,
|
|
405
|
+
finalizePayToSave: Ot,
|
|
406
|
+
openPaymentInstructions: St,
|
|
407
|
+
paymentInstructions: a(Pt, !!G?.hasPaymentInstructions),
|
|
408
|
+
paymentInstructionsEditor: Pt,
|
|
409
|
+
detailsWarning: gt
|
|
410
|
+
}, Lt = E === "create" && ke ? {
|
|
411
|
+
values: A,
|
|
412
|
+
errors: We,
|
|
413
|
+
onChange: Ct,
|
|
414
|
+
isExtracted: !!(B && g(A, B))
|
|
415
|
+
} : void 0;
|
|
416
|
+
if (E) return {
|
|
417
|
+
mode: "creating",
|
|
418
|
+
summary: G,
|
|
419
|
+
newVendorForm: /* @__PURE__ */ ye(_e, {
|
|
420
|
+
mode: E,
|
|
421
|
+
values: U.values,
|
|
422
|
+
errors: U.errors,
|
|
423
|
+
onChange: At,
|
|
424
|
+
onAddressChange: jt,
|
|
425
|
+
sectionsToExpand: U.sectionsToExpand,
|
|
426
|
+
onAddressExpand: U.expandAddress,
|
|
427
|
+
onCancel: Tt,
|
|
428
|
+
onSave: Dt,
|
|
429
|
+
isSaving: Ft,
|
|
430
|
+
search: rt ? Mt : void 0,
|
|
431
|
+
paymentInstructions: Lt,
|
|
432
|
+
labels: Ae?.inlineForm
|
|
433
|
+
}),
|
|
434
|
+
...It
|
|
435
|
+
};
|
|
436
|
+
if (G) return {
|
|
437
|
+
mode: "resolved",
|
|
438
|
+
summary: G,
|
|
439
|
+
onEdit: b && !ht ? () => $(() => X("edit")) : void 0,
|
|
440
|
+
...It
|
|
441
|
+
};
|
|
442
|
+
if (K && !bt) {
|
|
443
|
+
let e = () => $(() => {
|
|
444
|
+
Xe(!0), X("create");
|
|
445
|
+
}), t = b && ke ? {
|
|
446
|
+
isOpen: !1,
|
|
447
|
+
values: A,
|
|
448
|
+
errors: We,
|
|
449
|
+
onOpen: e,
|
|
450
|
+
onChange: Ct,
|
|
451
|
+
onCancel: wt,
|
|
452
|
+
canEditExisting: !0
|
|
453
|
+
} : void 0;
|
|
454
|
+
return {
|
|
455
|
+
mode: "resolved",
|
|
456
|
+
summary: K,
|
|
457
|
+
onEdit: b ? e : void 0,
|
|
458
|
+
error: De,
|
|
459
|
+
...It,
|
|
460
|
+
showPaymentInstructions: !0,
|
|
461
|
+
paymentInstructions: a(t, K.hasPaymentInstructions),
|
|
462
|
+
paymentInstructionsEditor: t
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
mode: "selecting",
|
|
467
|
+
error: V.isError ? S.searchFailed : H.isError ? S.vendorDetailsFailed : De,
|
|
468
|
+
search: Mt,
|
|
469
|
+
...It
|
|
237
470
|
};
|
|
238
471
|
}
|
|
239
472
|
//#endregion
|
|
240
|
-
export {
|
|
473
|
+
export { _ as useVendorSectionProps };
|