@tesouro/embedded-components-react 0.5.58 → 0.5.59

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