@tesouro/embedded-components-react 0.5.285 → 0.5.288

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