@tesouro/embedded-components-react 0.5.74 → 0.5.76
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/experimental/InvoiceSettings.d.ts +660 -0
- package/dist/experimental/InvoiceSettings.js +3 -0
- package/dist/experimental/index.d.ts +31 -2
- package/dist/experimental/index.js +4 -2
- package/dist/index.css +0 -8
- package/dist/index.js +1 -1
- package/dist/lib/BillPayWidget.js +1 -1
- 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/index45.js +140 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +46 -140
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +114 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +163 -112
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +75 -164
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +21 -75
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +71 -23
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +376 -65
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +12 -381
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +84 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +54 -79
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +223 -54
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +37 -223
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +245 -37
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +21 -252
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +571 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +4 -572
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +44 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +247 -38
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +3 -234
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +44 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +1 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +11 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +127 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -129
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +127 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -124
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +7 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +47 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +18 -44
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +28 -20
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +82 -27
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +47 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +250 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +123 -241
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +211 -126
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +3 -219
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +7 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +98 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +1 -100
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +26 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +10 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +2 -72
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +12 -269
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index33.js +2 -19
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index34.js +16 -50
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index36.js +97 -15
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index37.js +76 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index38.js +277 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index39.js +2 -35
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index40.js +16 -369
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index41.js +56 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index42.js +2 -23
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index43.js +15 -93
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index44.js +50 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index45.js +1 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +32 -49
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index47.js +374 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index48.js +1 -55
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index49.js +20 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index50.js +87 -188
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index51.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index52.js +30 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index53.js +48 -37
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index55.js +47 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +10 -85
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +197 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index58.js +2 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index59.js +2 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index60.js +41 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +2 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index62.js +14 -17
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index63.js +88 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index64.js +1 -94
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index65.js +167 -161
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index2.js +5 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index3.js +29 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index4.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/auditHistory/buildPayableAuditHistory.js +5 -1
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +1391 -1369
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +0 -27
|
@@ -2,73 +2,384 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import "
|
|
5
|
+
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import { hasAnyScope as t } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
|
|
7
|
+
import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
|
|
8
|
+
import "../../../shared/data-access/dist/index.js";
|
|
9
|
+
import "../../../shared/ui/dist/index.js";
|
|
10
|
+
import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
11
|
+
import "../../../shared/feature/dist/index.js";
|
|
12
|
+
import { useCounterpartsQuery as i } from "../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
13
|
+
import { useCreateCounterpartBankAccountMutation as a, useUpdateCounterpartBankAccountMutation as o } from "../../../shared/counterpart-management/data-access/dist/index5.js";
|
|
14
|
+
import { usePayableSuggestionsQuery as s } from "../../data-access/dist/index18.js";
|
|
15
|
+
import "../../data-access/dist/index.js";
|
|
16
|
+
import { COUNTERPART_MESSAGE_LABELS_EN as ee } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
17
|
+
import { counterpartFormBankAccountToCreatePayload as te, counterpartFormBankAccountToUpdatePayload as ne, getAchInstructions as c, getCounterpartEmail as l, getCounterpartName as u, getPayableAchInstructions as re, isAchCompatibleBankAccount as d, resolveCounterpartBankAccountWrite as ie, validateAchFormValues as ae } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
18
|
+
import { useCounterpartDetails as oe } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
|
|
19
|
+
import { useCounterpartForm as se } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
10
20
|
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
21
|
+
import { VENDOR_SECTION_PROPS_LABELS_EN as ce } from "./index48.js";
|
|
22
|
+
import { buildVendorPrefill as le } from "./index50.js";
|
|
23
|
+
import { VendorInlineForm as ue } from "./index51.js";
|
|
24
|
+
import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
25
|
+
import { jsx as de } from "react/jsx-runtime";
|
|
14
26
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}) : null]
|
|
69
|
-
})
|
|
70
|
-
]
|
|
27
|
+
var fe = 10, pe = 300, _ = {
|
|
28
|
+
accountHolderName: "",
|
|
29
|
+
routingNumber: "",
|
|
30
|
+
accountNumber: ""
|
|
31
|
+
};
|
|
32
|
+
function me(e) {
|
|
33
|
+
return {
|
|
34
|
+
accountHolderName: e.account_holder_name ?? "",
|
|
35
|
+
routingNumber: e.routing_number ?? "",
|
|
36
|
+
accountNumber: e.account_number ?? ""
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function he(e, t) {
|
|
40
|
+
return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
|
|
41
|
+
}
|
|
42
|
+
function ge(e, t) {
|
|
43
|
+
return e?.find((e) => e.id === t && d(e)) ?? c(e);
|
|
44
|
+
}
|
|
45
|
+
function v({ payableId: c, counterpartId: d, payableCounterpartId: v, payableCounterpartBankAccountId: _e, isVendorKnown: ve = !0, onCounterpartChange: ye, requiredError: be, extractedVendor: y, readOnly: b = !1, canEditVendor: xe = !0, canEditPaymentInstructions: Se = !0, canAddPaymentInstructions: Ce = !0, confirmDiscard: x = (e) => e(), labels: we }) {
|
|
46
|
+
let S = {
|
|
47
|
+
...ce,
|
|
48
|
+
...we
|
|
49
|
+
}, { initResponse: Te } = r(), Ee = t(Te?.scopes, [n.CounterpartReadOrg]), [C, De] = g(""), [w, Oe] = g(""), ke = h(w), [T, Ae] = g(), [je, Me] = g("none"), [Ne, Pe] = g(), [Fe, E] = g(!1), [D, O] = g(!1), [k, A] = g(_), Ie = h(k);
|
|
50
|
+
Ie.current = k;
|
|
51
|
+
let j = h(_), [Le, M] = g(), [N, Re] = g(), P = h(void 0), ze = h(d), [Be, Ve] = g(!1), [He, Ue] = g(!1), F = h(void 0), We = D && !he(k, j.current), I = f(() => {
|
|
52
|
+
O(!1), A(_), j.current = _, M(void 0);
|
|
53
|
+
}, []), L = f((e) => {
|
|
54
|
+
Ve(!0), ye(e);
|
|
55
|
+
}, [ye]), Ge = s(c, { enabled: !b && !!c && !d && !v }).data?.suggested_counterpart?.id, Ke = y?.name;
|
|
56
|
+
p(() => {
|
|
57
|
+
!b && !Be && !d && !v && Ge && L(Ge);
|
|
58
|
+
}, [
|
|
59
|
+
d,
|
|
60
|
+
v,
|
|
61
|
+
b,
|
|
62
|
+
Be,
|
|
63
|
+
Ge,
|
|
64
|
+
L
|
|
65
|
+
]), p(() => {
|
|
66
|
+
ze.current !== d && (ze.current = d, I(), Re(void 0));
|
|
67
|
+
}, [d, I]), p(() => {
|
|
68
|
+
let e = setTimeout(() => {
|
|
69
|
+
Oe(C.trim());
|
|
70
|
+
}, pe);
|
|
71
|
+
return () => clearTimeout(e);
|
|
72
|
+
}, [C]);
|
|
73
|
+
let R = i({
|
|
74
|
+
sort: "counterpart_name",
|
|
75
|
+
order: "asc",
|
|
76
|
+
limit: fe,
|
|
77
|
+
counterpart_name__icontains: w || void 0,
|
|
78
|
+
is_vendor: !0,
|
|
79
|
+
enabled: !b && (T === "edit" || !T && !d) && ve && Ee
|
|
71
80
|
});
|
|
81
|
+
p(() => {
|
|
82
|
+
R.isPlaceholderData || (ke.current = w);
|
|
83
|
+
}, [w, R.isPlaceholderData]);
|
|
84
|
+
let qe = R.isPlaceholderData && ke.current !== w, z = oe({
|
|
85
|
+
selectedId: d,
|
|
86
|
+
enabled: Ee
|
|
87
|
+
}), Je = a(), Ye = o(), B = se({
|
|
88
|
+
view: je,
|
|
89
|
+
setView: Me,
|
|
90
|
+
selectedId: Ne,
|
|
91
|
+
setSelectedId: Pe,
|
|
92
|
+
messages: ee,
|
|
93
|
+
counterpartType: "vendor",
|
|
94
|
+
counterpart: z.counterpart,
|
|
95
|
+
primaryAddress: z.primaryAddress,
|
|
96
|
+
includeBankAccount: !1
|
|
97
|
+
}), { openCreate: Xe, openEdit: Ze, close: Qe, setValues: V, submit: $e } = B, H = m(() => {
|
|
98
|
+
let e = z.counterpart;
|
|
99
|
+
if (!e) return;
|
|
100
|
+
if (z.isBankAccountsLoading) return {
|
|
101
|
+
name: u(e),
|
|
102
|
+
email: l(e),
|
|
103
|
+
methodLabel: S.paymentMethodLoading,
|
|
104
|
+
hasPaymentInstructions: !1
|
|
105
|
+
};
|
|
106
|
+
if (z.isBankAccountsError) return {
|
|
107
|
+
name: u(e),
|
|
108
|
+
email: l(e),
|
|
109
|
+
methodLabel: S.paymentMethodUnavailable,
|
|
110
|
+
hasPaymentInstructions: !1
|
|
111
|
+
};
|
|
112
|
+
let t = re(z.bankAccounts);
|
|
113
|
+
return {
|
|
114
|
+
name: u(e),
|
|
115
|
+
email: l(e),
|
|
116
|
+
methodLabel: t ? S.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : S.noMethod,
|
|
117
|
+
hasPaymentInstructions: !!t
|
|
118
|
+
};
|
|
119
|
+
}, [
|
|
120
|
+
z.bankAccounts,
|
|
121
|
+
z.counterpart,
|
|
122
|
+
z.isBankAccountsError,
|
|
123
|
+
z.isBankAccountsLoading,
|
|
124
|
+
S
|
|
125
|
+
]), et = m(() => {
|
|
126
|
+
let e = Ke?.trim();
|
|
127
|
+
if (!(!e || d || T)) return {
|
|
128
|
+
name: e,
|
|
129
|
+
email: y?.email ?? "",
|
|
130
|
+
description: S.pendingVendorDescription,
|
|
131
|
+
methodLabel: "",
|
|
132
|
+
hasPaymentInstructions: !1
|
|
133
|
+
};
|
|
134
|
+
}, [
|
|
135
|
+
d,
|
|
136
|
+
y?.email,
|
|
137
|
+
Ke,
|
|
138
|
+
T,
|
|
139
|
+
S.pendingVendorDescription
|
|
140
|
+
]), U = d === v ? _e : void 0, W = m(() => ge(z.bankAccounts, U), [z.bankAccounts, U]), tt = m(() => re(z.bankAccounts)?.id, [z.bankAccounts]), G = !z.counterpart || z.isLoading || z.isFetching || z.isError || z.isAddressesLoading || z.isAddressesFetching || z.isAddressesError || z.isBankAccountsLoading || z.isBankAccountsFetching || z.isBankAccountsError, K = f(() => {
|
|
141
|
+
Qe(), Ae(void 0), E(!1), P.current = void 0;
|
|
142
|
+
}, [Qe]), q = m(() => le(y), [y]), nt = f((e) => {
|
|
143
|
+
if (E(!1), P.current = void 0, e === "edit") Pe(d), Ze();
|
|
144
|
+
else {
|
|
145
|
+
Xe();
|
|
146
|
+
let e = C.trim();
|
|
147
|
+
V((t) => ({
|
|
148
|
+
...t,
|
|
149
|
+
entityType: "organization",
|
|
150
|
+
legalName: e || q?.legalName || t.legalName,
|
|
151
|
+
email: q?.email || t.email,
|
|
152
|
+
phone: q?.phone || t.phone,
|
|
153
|
+
address: q?.address ?? t.address
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
Ae(e);
|
|
157
|
+
}, [
|
|
158
|
+
d,
|
|
159
|
+
Xe,
|
|
160
|
+
Ze,
|
|
161
|
+
C,
|
|
162
|
+
V,
|
|
163
|
+
q
|
|
164
|
+
]), J = f(() => {
|
|
165
|
+
let e = W ? me(W) : _;
|
|
166
|
+
j.current = e, A(e), M(void 0), O(!0);
|
|
167
|
+
}, [W]), rt = f(() => {
|
|
168
|
+
We ? x(I) : I();
|
|
169
|
+
}, [
|
|
170
|
+
I,
|
|
171
|
+
x,
|
|
172
|
+
We
|
|
173
|
+
]), Y = f(() => {
|
|
174
|
+
K(), I();
|
|
175
|
+
}, [I, K]), X = Fe || We, Z = f((e) => {
|
|
176
|
+
let t = () => {
|
|
177
|
+
Y(), e();
|
|
178
|
+
};
|
|
179
|
+
X ? x(t) : t();
|
|
180
|
+
}, [
|
|
181
|
+
x,
|
|
182
|
+
Y,
|
|
183
|
+
X
|
|
184
|
+
]), it = f(() => {
|
|
185
|
+
X ? x(Y) : Y();
|
|
186
|
+
}, [
|
|
187
|
+
x,
|
|
188
|
+
Y,
|
|
189
|
+
X
|
|
190
|
+
]), at = f(async (t) => {
|
|
191
|
+
let n = d, r = !1, i = Ie.current;
|
|
192
|
+
if (!he(i, j.current)) {
|
|
193
|
+
let e = ae(i);
|
|
194
|
+
if (Object.keys(e).length > 0) return M(e), O(!0), { ok: !1 };
|
|
195
|
+
}
|
|
196
|
+
if (T === "edit" && G) return { ok: !1 };
|
|
197
|
+
if (T) {
|
|
198
|
+
if (T === "create" && P.current) n = P.current;
|
|
199
|
+
else {
|
|
200
|
+
let e = await $e();
|
|
201
|
+
if (!e.ok) return { ok: !1 };
|
|
202
|
+
T === "create" ? (n = e.counterpartId, P.current = n) : n = e.counterpartId ?? n;
|
|
203
|
+
}
|
|
204
|
+
T === "create" && (r = !0);
|
|
205
|
+
}
|
|
206
|
+
if (!n) return { ok: !0 };
|
|
207
|
+
let a = z.isBankAccountsLoading || z.isBankAccountsFetching || z.isBankAccountsError;
|
|
208
|
+
if (he(i, j.current)) {
|
|
209
|
+
let e = N ?? U;
|
|
210
|
+
return e ? (t && (O(!1), T && K()), r && L(n), {
|
|
211
|
+
ok: !0,
|
|
212
|
+
counterpartId: n,
|
|
213
|
+
counterpartBankAccountId: e
|
|
214
|
+
}) : r ? (t && K(), L(n), {
|
|
215
|
+
ok: !0,
|
|
216
|
+
counterpartId: n
|
|
217
|
+
}) : a ? { ok: !1 } : (t && (O(!1), T && K()), {
|
|
218
|
+
ok: !0,
|
|
219
|
+
counterpartId: n,
|
|
220
|
+
counterpartBankAccountId: tt
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (a) return { ok: !1 };
|
|
224
|
+
M(void 0);
|
|
225
|
+
let o = ie(z.bankAccounts, N ?? W?.id), s;
|
|
226
|
+
try {
|
|
227
|
+
o.kind === "update" ? (await Ye.mutateAsync({
|
|
228
|
+
path: {
|
|
229
|
+
counterpart_id: n,
|
|
230
|
+
bank_account_id: o.bankAccountId
|
|
231
|
+
},
|
|
232
|
+
body: ne(i, { includeAchDefaults: o.includeAchDefaults })
|
|
233
|
+
}), s = o.bankAccountId) : s = (await Je.mutateAsync({
|
|
234
|
+
path: { counterpart_id: n },
|
|
235
|
+
body: te(i, { isDefaultForCurrency: o.isDefaultForCurrency })
|
|
236
|
+
}))?.id;
|
|
237
|
+
} catch {
|
|
238
|
+
return e.error(S.bankAccountSaveFailed), {
|
|
239
|
+
ok: !1,
|
|
240
|
+
counterpartId: n
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
return j.current = i, Re(s), t && (O(!1), T && K()), r && L(n), {
|
|
244
|
+
ok: !0,
|
|
245
|
+
counterpartId: n,
|
|
246
|
+
counterpartBankAccountId: s
|
|
247
|
+
};
|
|
248
|
+
}, [
|
|
249
|
+
K,
|
|
250
|
+
d,
|
|
251
|
+
Je,
|
|
252
|
+
z.bankAccounts,
|
|
253
|
+
z.isBankAccountsError,
|
|
254
|
+
z.isBankAccountsFetching,
|
|
255
|
+
z.isBankAccountsLoading,
|
|
256
|
+
T,
|
|
257
|
+
G,
|
|
258
|
+
U,
|
|
259
|
+
tt,
|
|
260
|
+
L,
|
|
261
|
+
W,
|
|
262
|
+
$e,
|
|
263
|
+
Ye,
|
|
264
|
+
N
|
|
265
|
+
]), ot = f((e) => {
|
|
266
|
+
if (F.current) return F.current;
|
|
267
|
+
let t = e?.closeOnSuccess ?? !0, n = (async () => {
|
|
268
|
+
Ue(!0);
|
|
269
|
+
try {
|
|
270
|
+
return await at(t);
|
|
271
|
+
} finally {
|
|
272
|
+
F.current = void 0, Ue(!1);
|
|
273
|
+
}
|
|
274
|
+
})();
|
|
275
|
+
return F.current = n, n;
|
|
276
|
+
}, [at]), st = f(() => {
|
|
277
|
+
O(!1), T && K();
|
|
278
|
+
}, [T, K]), ct = m(() => (R.data?.data ?? []).map((e) => ({
|
|
279
|
+
name: u(e),
|
|
280
|
+
email: l(e),
|
|
281
|
+
onSelect: () => {
|
|
282
|
+
Z(() => L(e.id));
|
|
283
|
+
}
|
|
284
|
+
})), [
|
|
285
|
+
R.data,
|
|
286
|
+
Z,
|
|
287
|
+
L
|
|
288
|
+
]), lt = f((e) => {
|
|
289
|
+
E(!0), V((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
|
|
290
|
+
...t,
|
|
291
|
+
...e,
|
|
292
|
+
firstName: t.firstName || t.legalName,
|
|
293
|
+
legalName: t.legalName
|
|
294
|
+
} : e.entityType === "organization" && t.entityType !== "organization" ? {
|
|
295
|
+
...t,
|
|
296
|
+
...e,
|
|
297
|
+
legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
|
|
298
|
+
} : {
|
|
299
|
+
...t,
|
|
300
|
+
...e
|
|
301
|
+
});
|
|
302
|
+
}, [V]), ut = f((e) => {
|
|
303
|
+
E(!0), V((t) => ({
|
|
304
|
+
...t,
|
|
305
|
+
address: {
|
|
306
|
+
...t.address,
|
|
307
|
+
...e
|
|
308
|
+
}
|
|
309
|
+
}));
|
|
310
|
+
}, [V]), dt = {
|
|
311
|
+
query: C,
|
|
312
|
+
onQueryChange: De,
|
|
313
|
+
isLoading: !ve || !Te || !!d && z.isLoading || R.isLoading || R.isFetching && qe,
|
|
314
|
+
onAddVendor: () => {
|
|
315
|
+
Z(() => nt("create"));
|
|
316
|
+
},
|
|
317
|
+
results: ct
|
|
318
|
+
}, Q = Ce && (T === "create" || !G) ? {
|
|
319
|
+
isOpen: D,
|
|
320
|
+
values: k,
|
|
321
|
+
errors: Le,
|
|
322
|
+
onOpen: J,
|
|
323
|
+
onCancel: rt,
|
|
324
|
+
onChange: (e) => {
|
|
325
|
+
A((t) => ({
|
|
326
|
+
...t,
|
|
327
|
+
...e
|
|
328
|
+
})), M(void 0);
|
|
329
|
+
}
|
|
330
|
+
} : void 0, ft = T !== "create" && Q ? {
|
|
331
|
+
...Q,
|
|
332
|
+
onOpen: T === "edit" ? () => Z(J) : Q.onOpen,
|
|
333
|
+
canEditExisting: Se
|
|
334
|
+
} : void 0, pt = B.isSubmitting || Je.isPending || Ye.isPending, $ = {
|
|
335
|
+
prepareVendorForSave: ot,
|
|
336
|
+
isVendorSavePending: He || pt,
|
|
337
|
+
hasUnsavedVendorChanges: X,
|
|
338
|
+
isPendingVendor: !!et,
|
|
339
|
+
isEditingPayTo: !!T || D,
|
|
340
|
+
activePayToOperation: T ? "vendor" : D ? H?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
|
|
341
|
+
discardPayToEdits: Y,
|
|
342
|
+
finalizePayToSave: st,
|
|
343
|
+
openPaymentInstructions: J,
|
|
344
|
+
paymentInstructions: ft
|
|
345
|
+
};
|
|
346
|
+
return T ? {
|
|
347
|
+
mode: "creating",
|
|
348
|
+
summary: H,
|
|
349
|
+
newVendorForm: /* @__PURE__ */ de(ue, {
|
|
350
|
+
mode: T,
|
|
351
|
+
values: B.values,
|
|
352
|
+
errors: B.errors,
|
|
353
|
+
onChange: lt,
|
|
354
|
+
onAddressChange: ut,
|
|
355
|
+
sectionsToExpand: B.sectionsToExpand,
|
|
356
|
+
onAddressExpand: B.expandAddress,
|
|
357
|
+
onCancel: it,
|
|
358
|
+
onSave: ot,
|
|
359
|
+
isSaving: pt,
|
|
360
|
+
search: T === "edit" && !b ? dt : void 0
|
|
361
|
+
}),
|
|
362
|
+
...$
|
|
363
|
+
} : H ? {
|
|
364
|
+
mode: "resolved",
|
|
365
|
+
summary: H,
|
|
366
|
+
onEdit: xe && !G ? () => Z(() => nt("edit")) : void 0,
|
|
367
|
+
...$
|
|
368
|
+
} : et ? {
|
|
369
|
+
mode: "resolved",
|
|
370
|
+
summary: et,
|
|
371
|
+
onEdit: xe ? () => Z(() => {
|
|
372
|
+
Ve(!0), nt("create");
|
|
373
|
+
}) : void 0,
|
|
374
|
+
showPaymentInstructions: !1,
|
|
375
|
+
error: be,
|
|
376
|
+
...$
|
|
377
|
+
} : {
|
|
378
|
+
mode: "selecting",
|
|
379
|
+
error: R.isError ? S.searchFailed : z.isError ? S.vendorDetailsFailed : be,
|
|
380
|
+
search: dt,
|
|
381
|
+
...$
|
|
382
|
+
};
|
|
72
383
|
}
|
|
73
384
|
//#endregion
|
|
74
|
-
export {
|
|
385
|
+
export { v as useVendorSectionProps };
|