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