@tesouro/embedded-components-react 0.5.158 → 0.5.159

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