@tesouro/embedded-components-react 0.2.296 → 0.2.299

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 (45) hide show
  1. package/dist/index.css +6 -0
  2. package/dist/index.d.ts +107 -87
  3. package/dist/lib/CounterpartsWidget.d.ts +24 -4
  4. package/dist/lib/ReceivablesWidget.d.ts +20 -3
  5. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/data-access/dist/index.js +3 -2
  6. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index4.js +2 -2
  7. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js +210 -199
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +31 -27
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +2 -0
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index4.js +122 -149
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +163 -72
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +3 -3
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +52 -46
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +8 -2
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +98 -67
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +6 -1
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +7 -3
  18. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index7.js +4 -1
  19. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index8.js +12 -7
  20. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index4.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +17 -16
  23. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/CounterpartSelector.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +103 -50
  25. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +2 -1
  26. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js +2 -0
  27. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +126 -76
  28. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index.js +12 -11
  29. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index10.js +6 -173
  30. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index11.js +173 -5
  31. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index12.js +5 -57
  32. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index13.js +51 -22
  33. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index14.js +24 -72
  34. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +76 -0
  35. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +13 -7
  36. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index5.js +53 -110
  37. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index6.js +115 -51
  38. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index7.js +53 -47
  39. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index8.js +44 -504
  40. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index9.js +480 -6
  41. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +21 -19
  42. package/dist/libs/tesouro-embedded-components-react/{accept-disclosures-widget/data-access/dist/index2.js → shared/data-access/dist/lib/disclosures/useAcceptWidgetDisclosures.js} +3 -4
  43. package/dist/libs/tesouro-embedded-components-react/{accept-disclosures-widget/data-access/dist/index3.js → shared/data-access/dist/lib/disclosures/useDisclosuresQuery.js} +4 -5
  44. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  45. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { formatMoneyExact as e } from "../../../../util/dist/lib/formatMoneyExact.js";
2
- import { COUNTERPART_MESSAGE_LABELS_EN as t } from "./labels.js";
3
- import { EMPTY_ADDRESS_FORM_VALUES as n } from "../../../ui/dist/index5.js";
2
+ import { EMPTY_ADDRESS_FORM_VALUES as t } from "../../../ui/dist/index6.js";
4
3
  import "../../../ui/dist/index.js";
4
+ import { COUNTERPART_MESSAGE_LABELS_EN as n } from "./labels.js";
5
5
  //#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js
6
6
  var r = [
7
7
  "USD",
@@ -125,7 +125,15 @@ function y(e) {
125
125
  };
126
126
  });
127
127
  }
128
- function b(e, t = {}) {
128
+ function b(e) {
129
+ let t = (e ?? []).filter((e) => e.currency === "USD" && (!!e.routing_number || !!e.account_number));
130
+ return t.find((e) => e.is_default_for_currency) ?? t[0];
131
+ }
132
+ function x(e) {
133
+ let t = (e ?? []).filter((e) => e.currency === "USD" && !!e.account_holder_name && !!e.routing_number && !!e.account_number);
134
+ return t.find((e) => e.is_default_for_currency) ?? t[0];
135
+ }
136
+ function S(e, t = {}) {
129
137
  let n = e.line2.trim();
130
138
  return {
131
139
  line1: e.line1.trim(),
@@ -136,7 +144,7 @@ function b(e, t = {}) {
136
144
  country: "US"
137
145
  };
138
146
  }
139
- function x(e) {
147
+ function C(e) {
140
148
  return {
141
149
  line1: e.line1 ?? "",
142
150
  line2: e.line2 ?? "",
@@ -145,10 +153,10 @@ function x(e) {
145
153
  postalCode: e.postal_code ?? ""
146
154
  };
147
155
  }
148
- function S(e) {
149
- return b(e);
156
+ function w(e) {
157
+ return S(e);
150
158
  }
151
- function C(e) {
159
+ function T(e) {
152
160
  return {
153
161
  line1: e.line1.trim(),
154
162
  line2: e.line2.trim(),
@@ -158,7 +166,7 @@ function C(e) {
158
166
  country: "US"
159
167
  };
160
168
  }
161
- function w(e = "organization", t) {
169
+ function E(e = "organization", n) {
162
170
  return {
163
171
  entityType: e,
164
172
  legalName: "",
@@ -168,8 +176,8 @@ function w(e = "organization", t) {
168
176
  email: "",
169
177
  phone: "",
170
178
  taxId: "",
171
- remindersEnabled: t === "customer",
172
- address: { ...n },
179
+ remindersEnabled: n === "customer",
180
+ address: { ...t },
173
181
  bankAccount: {
174
182
  accountHolderName: "",
175
183
  routingNumber: "",
@@ -177,11 +185,11 @@ function w(e = "organization", t) {
177
185
  }
178
186
  };
179
187
  }
180
- function T(e, t) {
181
- let n = w(e.type);
182
- return n.email = d(e), n.phone = f(e), n.taxId = e.tax_id ?? "", n.remindersEnabled = !!e.reminders_enabled, t && (n.address = x(t)), "organization" in e ? n.legalName = e.organization.legal_name : (n.firstName = e.individual.first_name, n.lastName = e.individual.last_name), n;
188
+ function D(e, t) {
189
+ let n = E(e.type);
190
+ return n.email = d(e), n.phone = f(e), n.taxId = e.tax_id ?? "", n.remindersEnabled = !!e.reminders_enabled, t && (n.address = C(t)), "organization" in e ? n.legalName = e.organization.legal_name : (n.firstName = e.individual.first_name, n.lastName = e.individual.last_name), n;
183
191
  }
184
- function E(e) {
192
+ function O(e) {
185
193
  return [
186
194
  e.line1,
187
195
  e.line2,
@@ -190,11 +198,11 @@ function E(e) {
190
198
  e.postalCode
191
199
  ].some((e) => e.trim().length > 0);
192
200
  }
193
- function D(e) {
194
- return E(e) ? b(e) : void 0;
201
+ function k(e) {
202
+ return O(e) ? S(e) : void 0;
195
203
  }
196
- function O(e, t) {
197
- let n = t === "customer", r = t === "vendor", i = D(e.address), a = e.taxId.trim() || void 0, o = e.email.trim(), s = e.phone.trim() || void 0, c = {
204
+ function A(e, t) {
205
+ let n = t === "customer", r = t === "vendor", i = k(e.address), a = e.taxId.trim() || void 0, o = e.email.trim(), s = e.phone.trim() || void 0, c = {
198
206
  is_customer: n,
199
207
  is_vendor: r,
200
208
  language: "en",
@@ -223,7 +231,7 @@ function O(e, t) {
223
231
  }
224
232
  };
225
233
  }
226
- function k(e, t) {
234
+ function j(e, t) {
227
235
  let n = e.taxId.trim(), r = e.email.trim(), i = e.phone.trim(), a = {
228
236
  language: "en",
229
237
  reminders_enabled: t === "customer" ? e.remindersEnabled : void 0,
@@ -247,17 +255,20 @@ function k(e, t) {
247
255
  }
248
256
  };
249
257
  }
250
- function A(e) {
251
- return E(e.address);
258
+ function M(e) {
259
+ return O(e.address);
252
260
  }
253
- function j(e) {
261
+ function N(e) {
254
262
  return [
255
- e.bankAccount.accountHolderName,
256
- e.bankAccount.routingNumber,
257
- e.bankAccount.accountNumber
263
+ e.accountHolderName,
264
+ e.routingNumber,
265
+ e.accountNumber
258
266
  ].some((e) => e.trim().length > 0);
259
267
  }
260
- function M(e) {
268
+ function P(e) {
269
+ return N(e.bankAccount);
270
+ }
271
+ function F(e) {
261
272
  return {
262
273
  account_holder_name: e.accountHolderName.trim() || void 0,
263
274
  account_number: e.accountNumber.trim() || void 0,
@@ -267,7 +278,40 @@ function M(e) {
267
278
  is_default_for_currency: !0
268
279
  };
269
280
  }
270
- function N() {
281
+ function I(e, t = {}) {
282
+ return {
283
+ account_holder_name: e.accountHolderName.trim() || void 0,
284
+ account_number: e.accountNumber.trim() || void 0,
285
+ routing_number: e.routingNumber.trim() || void 0,
286
+ ...t.includeAchDefaults ? {
287
+ country: "US",
288
+ currency: "USD"
289
+ } : {}
290
+ };
291
+ }
292
+ function L(e) {
293
+ return [
294
+ e.account_number,
295
+ e.iban,
296
+ e.routing_number,
297
+ e.sort_code,
298
+ e.bic
299
+ ].every((e) => !e);
300
+ }
301
+ function R(e, t) {
302
+ if (t) return {
303
+ kind: "update",
304
+ bankAccountId: t,
305
+ includeAchDefaults: !1
306
+ };
307
+ let n = e?.find(L);
308
+ return n ? {
309
+ kind: "update",
310
+ bankAccountId: n.id,
311
+ includeAchDefaults: !0
312
+ } : { kind: "create" };
313
+ }
314
+ function z() {
271
315
  return {
272
316
  name: "",
273
317
  accountHolderName: "",
@@ -280,7 +324,7 @@ function N() {
280
324
  isDefault: !1
281
325
  };
282
326
  }
283
- function P(e) {
327
+ function B(e) {
284
328
  return {
285
329
  name: e.name ?? "",
286
330
  accountHolderName: e.account_holder_name ?? "",
@@ -293,7 +337,7 @@ function P(e) {
293
337
  isDefault: e.is_default_for_currency ?? !1
294
338
  };
295
339
  }
296
- function F(e) {
340
+ function V(e) {
297
341
  return {
298
342
  name: e.name.trim() || void 0,
299
343
  account_holder_name: e.accountHolderName.trim() || void 0,
@@ -307,7 +351,7 @@ function F(e) {
307
351
  is_default_for_currency: e.isDefault
308
352
  };
309
353
  }
310
- function I(e) {
354
+ function H(e) {
311
355
  return {
312
356
  name: e.name.trim(),
313
357
  account_holder_name: e.accountHolderName.trim(),
@@ -320,45 +364,54 @@ function I(e) {
320
364
  country: "US"
321
365
  };
322
366
  }
323
- function L(e) {
367
+ function U(e) {
324
368
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
325
369
  }
326
- function R(e, t) {
370
+ function W(e, t) {
327
371
  let n = {};
328
372
  return e.line1.trim().length === 0 && (n.line1 = t.addressLine1Required), e.city.trim().length === 0 && (n.city = t.cityRequired), e.state.trim().length === 0 && (n.state = t.stateRequired), e.postalCode.trim().length === 0 && (n.postalCode = t.postalCodeRequired), n;
329
373
  }
330
- function z(e) {
374
+ function G(e) {
331
375
  return Object.values(e).some(Boolean);
332
376
  }
333
- function B(e, n, r = t, i = "customer", { requireAddress: a = !0 } = {}) {
377
+ function K(e) {
378
+ if (!/^\d{9}$/.test(e)) return !1;
379
+ let t = [...e].map(Number);
380
+ return (3 * (t[0] + t[3] + t[6]) + 7 * (t[1] + t[4] + t[7]) + (t[2] + t[5] + t[8])) % 10 == 0;
381
+ }
382
+ function q(e, t = n) {
383
+ let r = {}, i = e.accountHolderName.trim(), a = e.routingNumber.trim(), o = e.accountNumber.trim();
384
+ return i.length === 0 && (r.accountHolderName = t.accountHolderNameRequired), (a.length === 0 || !K(a)) && (r.routingNumber = t.routingNumberInvalid), (o.length === 0 || !/^\d{9,12}$/.test(o)) && (r.accountNumber = t.accountNumberInvalid), r;
385
+ }
386
+ function J(e, t, r = n, i = "customer", a = !1) {
334
387
  let o = {};
335
- if (e.entityType === "organization" ? e.legalName.trim().length === 0 && (o.legalName = r.legalNameRequired) : (e.firstName.trim().length === 0 && (o.firstName = r.firstNameRequired), e.lastName.trim().length === 0 && (o.lastName = r.lastNameRequired)), e.email.trim().length === 0 ? o.email = r.emailRequired : L(e.email.trim()) || (o.email = r.emailInvalid), i === "vendor" && a || E(e.address)) {
336
- let t = R(e.address, r);
337
- z(t) && (o.address = t);
388
+ if (e.entityType === "organization" ? e.legalName.trim().length === 0 && (o.legalName = r.legalNameRequired) : (e.firstName.trim().length === 0 && (o.firstName = r.firstNameRequired), e.lastName.trim().length === 0 && (o.lastName = r.lastNameRequired)), e.email.trim().length === 0 ? o.email = r.emailRequired : U(e.email.trim()) || (o.email = r.emailInvalid), t === "create" && i === "vendor" || O(e.address)) {
389
+ let t = W(e.address, r);
390
+ G(t) && (o.address = t);
338
391
  }
339
- if (i === "vendor" && j(e)) {
340
- let t = {}, n = e.bankAccount.routingNumber.trim(), i = e.bankAccount.accountNumber.trim();
341
- n.length > 0 && n.length !== 9 && (t.routingNumber = r.routingNumberInvalid), i.length > 0 && (i.length < 9 || i.length > 12) && (t.accountNumber = r.accountNumberInvalid), z(t) && (o.bankAccount = t);
392
+ if (i === "vendor" && (a || P(e))) {
393
+ let t = q(e.bankAccount, r);
394
+ G(t) && (o.bankAccount = t);
342
395
  }
343
396
  return o;
344
397
  }
345
- function V(e) {
398
+ function Y(e) {
346
399
  let { address: t, bankAccount: n, ...r } = e;
347
- return z(r) || (t ? z(t) : !1) || (n ? z(n) : !1);
400
+ return G(r) || (t ? G(t) : !1) || (n ? G(n) : !1);
348
401
  }
349
- function H(e, n = t) {
402
+ function X(e, t = n) {
350
403
  let r = {};
351
- return e.name.trim().length === 0 && (r.name = n.bankAccountNameRequired), e.accountNumber.trim().length === 0 && e.iban.trim().length === 0 && (r.accountNumber = n.bankAccountIdentifierRequired), e.currency.trim().length === 0 && (r.currency = n.bankAccountCurrencyRequired), r;
404
+ return e.name.trim().length === 0 && (r.name = t.bankAccountNameRequired), e.accountNumber.trim().length === 0 && e.iban.trim().length === 0 && (r.accountNumber = t.bankAccountIdentifierRequired), e.currency.trim().length === 0 && (r.currency = t.bankAccountCurrencyRequired), r;
352
405
  }
353
- function U(e) {
354
- return z(e);
406
+ function Z(e) {
407
+ return G(e);
355
408
  }
356
- function W(e, n = t) {
357
- return R(e, n);
409
+ function Q(e, t = n) {
410
+ return W(e, t);
358
411
  }
359
- function G() {
412
+ function $() {
360
413
  let e = globalThis.getSelection?.();
361
414
  return !!(e && e.toString().length > 0);
362
415
  }
363
416
  //#endregion
364
- export { S as addressFormToCreatePayload, C as addressFormToUpdatePayload, x as addressResponseToFormValues, F as bankAccountFormToCreatePayload, I as bankAccountFormToUpdatePayload, P as bankAccountToFormValues, p as buildAnalyticsMap, y as buildBankAccountItems, _ as buildCounterpartDetailsView, m as buildCounterpartRows, M as counterpartFormBankAccountToCreatePayload, O as counterpartFormToCreatePayload, k as counterpartFormToUpdatePayload, T as counterpartToFormValues, N as emptyBankAccountFormValues, w as emptyCounterpartFormValues, l as formatCounterpartDate, s as formatMoney, o as fromMinorUnits, d as getCounterpartEmail, u as getCounterpartName, i as getCurrencyOptions, U as hasBankAccountFormErrors, A as hasCounterpartFormAddressValues, j as hasCounterpartFormBankAccountValues, V as hasCounterpartFormErrors, G as hasSelectedText, W as validateAddressForm, H as validateBankAccountForm, B as validateCounterpartForm };
417
+ export { w as addressFormToCreatePayload, T as addressFormToUpdatePayload, C as addressResponseToFormValues, V as bankAccountFormToCreatePayload, H as bankAccountFormToUpdatePayload, B as bankAccountToFormValues, p as buildAnalyticsMap, y as buildBankAccountItems, _ as buildCounterpartDetailsView, m as buildCounterpartRows, F as counterpartFormBankAccountToCreatePayload, I as counterpartFormBankAccountToUpdatePayload, A as counterpartFormToCreatePayload, j as counterpartFormToUpdatePayload, D as counterpartToFormValues, z as emptyBankAccountFormValues, E as emptyCounterpartFormValues, l as formatCounterpartDate, s as formatMoney, o as fromMinorUnits, b as getAchInstructions, d as getCounterpartEmail, u as getCounterpartName, i as getCurrencyOptions, x as getPayableAchInstructions, N as hasAchFormValues, Z as hasBankAccountFormErrors, M as hasCounterpartFormAddressValues, P as hasCounterpartFormBankAccountValues, Y as hasCounterpartFormErrors, $ as hasSelectedText, R as resolveCounterpartBankAccountWrite, q as validateAchFormValues, Q as validateAddressForm, X as validateBankAccountForm, J as validateCounterpartForm };
@@ -12,7 +12,8 @@ var e = {
12
12
  bankAccountNameRequired: "Account name is required",
13
13
  bankAccountIdentifierRequired: "Enter an account number or IBAN for this bank account",
14
14
  bankAccountCurrencyRequired: "Currency is required",
15
- routingNumberInvalid: "Routing number must be 9 digits",
15
+ accountHolderNameRequired: "Account holder name is required",
16
+ routingNumberInvalid: "Enter a valid 9-digit ABA routing number",
16
17
  accountNumberInvalid: "Account number must be between 9 and 12 digits",
17
18
  vatIdValueRequired: "VAT ID is required",
18
19
  genericError: "Something went wrong. Please try again.",
@@ -26,7 +26,9 @@ function o({ selectedId: o, enabled: s = !0 }) {
26
26
  counterpart: u,
27
27
  isOrganization: d,
28
28
  isLoading: l.isLoading,
29
+ isBankAccountsLoading: m.isLoading,
29
30
  isError: l.isError,
31
+ isBankAccountsError: m.isError,
30
32
  primaryAddress: g,
31
33
  detailsView: _,
32
34
  bankAccounts: m.data?.data,
@@ -3,98 +3,148 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { extractApiErrorMessage as e } from "../../../../util/dist/lib/apiErrors.js";
6
- import { addressFormToCreatePayload as t, addressFormToUpdatePayload as n, addressResponseToFormValues as r, counterpartFormBankAccountToCreatePayload as i, counterpartFormToCreatePayload as a, counterpartFormToUpdatePayload as o, counterpartToFormValues as s, emptyCounterpartFormValues as c, hasCounterpartFormAddressValues as l, hasCounterpartFormBankAccountValues as u, hasCounterpartFormErrors as d, validateCounterpartForm as f } from "./helpers.js";
7
- import { useCreateCounterpartMutation as p, useUpdateCounterpartMutation as m } from "../../../data-access/dist/index3.js";
8
- import { useCreateCounterpartBankAccountMutation as h } from "../../../data-access/dist/index5.js";
9
- import { useCreateCounterpartAddressMutation as g, useUpdateCounterpartAddressMutation as _ } from "../../../data-access/dist/index7.js";
6
+ import { addressFormToCreatePayload as t, addressFormToUpdatePayload as n, addressResponseToFormValues as r, counterpartFormBankAccountToCreatePayload as i, counterpartFormBankAccountToUpdatePayload as a, counterpartFormToCreatePayload as o, counterpartFormToUpdatePayload as s, counterpartToFormValues as c, emptyCounterpartFormValues as l, getAchInstructions as u, hasCounterpartFormAddressValues as d, hasCounterpartFormBankAccountValues as f, hasCounterpartFormErrors as p, resolveCounterpartBankAccountWrite as m, validateCounterpartForm as h } from "./helpers.js";
7
+ import { useCreateCounterpartMutation as g, useUpdateCounterpartMutation as _ } from "../../../data-access/dist/index3.js";
8
+ import { useCreateCounterpartBankAccountMutation as v, useUpdateCounterpartBankAccountMutation as y } from "../../../data-access/dist/index5.js";
9
+ import { useCreateCounterpartAddressMutation as b, useUpdateCounterpartAddressMutation as x } from "../../../data-access/dist/index7.js";
10
10
  import "../../../data-access/dist/index.js";
11
- import { useCallback as v, useState as y } from "react";
11
+ import { useCallback as S, useState as C } from "react";
12
12
  //#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js
13
- function b(e) {
14
- return e.entityType === "organization" ? e.legalName.trim().length > 0 : e.firstName.trim().length > 0 && e.lastName.trim().length > 0;
15
- }
16
- function x(e) {
17
- let { address: t } = e;
18
- return t.line1.trim().length > 0 && t.city.trim().length > 0 && t.state.trim().length > 0 && t.postalCode.trim().length > 0;
19
- }
20
- function S(e, t) {
21
- if (!t) return l(e);
13
+ function w(e, t) {
14
+ if (!t) return d(e);
22
15
  let n = r(t);
23
16
  return e.address.line1.trim() !== n.line1.trim() || e.address.line2.trim() !== n.line2.trim() || e.address.city.trim() !== n.city.trim() || e.address.state.trim() !== n.state.trim() || e.address.postalCode.trim() !== n.postalCode.trim();
24
17
  }
25
- function C({ view: r, setView: C, selectedId: w, setSelectedId: T, messages: E, counterpartType: D, counterpart: O, primaryAddress: k, requireAddress: A }) {
26
- let j = p(), M = g(), N = h(), P = m(), F = _(), [I, L] = y(() => c()), [R, z] = y({}), [B, V] = y(), H = j.isPending || M.isPending || N.isPending || P.isPending || F.isPending, U = D === "vendor" && A !== !1;
18
+ function T(e) {
27
19
  return {
28
- values: I,
29
- errors: R,
30
- setValues: L,
31
- isSubmitting: H,
32
- isSubmitDisabled: !b(I) || I.email.trim().length === 0 || U && !x(I),
33
- openCreate: v(() => {
34
- T(void 0), V(void 0), L(c("organization", D)), z({}), C("create");
35
- }, [
36
- D,
37
- T,
38
- C
39
- ]),
40
- openEdit: v(() => {
41
- O && (V(void 0), L(s(O, k)), z({}), C("edit"));
42
- }, [
43
- O,
44
- k,
45
- C
46
- ]),
47
- close: v(() => {
48
- C("none");
49
- }, [C]),
50
- submit: v(async () => {
51
- let s = f(I, r === "edit" ? "edit" : "create", E, D, { requireAddress: A });
52
- if (d(s)) {
53
- z(s);
20
+ accountHolderName: e.account_holder_name ?? "",
21
+ routingNumber: e.routing_number ?? "",
22
+ accountNumber: e.account_number ?? ""
23
+ };
24
+ }
25
+ function E(e, t) {
26
+ if (!t) return f(e);
27
+ let n = T(t);
28
+ return e.bankAccount.accountHolderName.trim() !== n.accountHolderName.trim() || e.bankAccount.routingNumber.trim() !== n.routingNumber.trim() || e.bankAccount.accountNumber.trim() !== n.accountNumber.trim();
29
+ }
30
+ function D({ view: r, setView: D, selectedId: O, setSelectedId: k, messages: A, counterpartType: j, counterpart: M, primaryAddress: N, bankAccounts: P, isBankAccountsLoading: F, isBankAccountsError: I }) {
31
+ let L = g(), R = b(), z = v(), B = _(), V = x(), H = y(), [U, W] = C(() => l()), [G, K] = C({}), [q, J] = C({
32
+ address: !1,
33
+ bankAccount: !1
34
+ }), [Y, X] = C(), [Z, Q] = C(), $ = L.isPending || R.isPending || z.isPending || H.isPending || B.isPending || V.isPending, ee = S(() => {
35
+ k(void 0), Q(void 0), X(void 0), J({
36
+ address: j === "vendor",
37
+ bankAccount: !1
38
+ }), W(l("organization", j)), K({}), D("create");
39
+ }, [
40
+ j,
41
+ k,
42
+ D
43
+ ]), te = S(() => {
44
+ if (!M || j === "vendor" && (F || I)) return;
45
+ let e = u(P), t = c(M, N);
46
+ Q(void 0), X(e?.id), J({
47
+ address: d(t),
48
+ bankAccount: !1
49
+ }), W({
50
+ ...t,
51
+ ...e ? { bankAccount: T(e) } : {}
52
+ }), K({}), D("edit");
53
+ }, [
54
+ P,
55
+ M,
56
+ j,
57
+ I,
58
+ F,
59
+ N,
60
+ D
61
+ ]), ne = S(() => {
62
+ D("none");
63
+ }, [D]);
64
+ return {
65
+ values: U,
66
+ errors: G,
67
+ setValues: W,
68
+ isSubmitting: $,
69
+ sectionsToExpand: q,
70
+ expandAddress: S(() => {
71
+ J((e) => ({
72
+ ...e,
73
+ address: !0
74
+ }));
75
+ }, []),
76
+ openCreate: ee,
77
+ openEdit: te,
78
+ close: ne,
79
+ submit: S(async () => {
80
+ let c = r === "edit" ? "edit" : "create", l = h(U, c, A, j, c === "edit" && j === "vendor" && !!Y);
81
+ if (p(l)) {
82
+ K(l), J((e) => ({
83
+ address: e.address || !!l.address,
84
+ bankAccount: e.bankAccount || !!l.bankAccount
85
+ }));
54
86
  return;
55
87
  }
56
- z({});
57
- let c = B;
88
+ K({}), J({
89
+ address: !1,
90
+ bankAccount: !1
91
+ });
92
+ let g = Z;
58
93
  try {
59
- r === "edit" && w ? (V(void 0), await P.mutateAsync({
60
- path: { counterpart_id: w },
61
- body: o(I, D)
62
- }), k ? S(I, k) && await F.mutateAsync({
63
- path: {
64
- counterpart_id: w,
65
- address_id: k.id
66
- },
67
- body: n(I.address)
68
- }) : l(I) && await M.mutateAsync({
69
- path: { counterpart_id: w },
70
- body: t(I.address)
71
- }), D === "vendor" && u(I) && await N.mutateAsync({
72
- path: { counterpart_id: w },
73
- body: i(I.bankAccount)
74
- }), C("none")) : (c ||= (await j.mutateAsync({ body: a(I, D) }))?.id, c && D === "vendor" && u(I) && (V(c), await N.mutateAsync({
75
- path: { counterpart_id: c },
76
- body: i(I.bankAccount)
77
- })), V(void 0), C("none"), c && T(c));
94
+ if (r === "edit" && O) {
95
+ Q(void 0), await B.mutateAsync({
96
+ path: { counterpart_id: O },
97
+ body: s(U, j)
98
+ });
99
+ let e = N ? w(U, N) ? V.mutateAsync({
100
+ path: {
101
+ counterpart_id: O,
102
+ address_id: N.id
103
+ },
104
+ body: n(U.address)
105
+ }) : void 0 : d(U) ? R.mutateAsync({
106
+ path: { counterpart_id: O },
107
+ body: t(U.address)
108
+ }) : void 0, r = j === "vendor" && E(U, u(P)) ? m(P, Y) : void 0, o = r?.kind === "update" ? H.mutateAsync({
109
+ path: {
110
+ counterpart_id: O,
111
+ bank_account_id: r.bankAccountId
112
+ },
113
+ body: a(U.bankAccount, { includeAchDefaults: r.includeAchDefaults })
114
+ }) : r?.kind === "create" ? z.mutateAsync({
115
+ path: { counterpart_id: O },
116
+ body: i(U.bankAccount)
117
+ }) : void 0, [c, l] = await Promise.allSettled([e, o]);
118
+ if (r?.kind === "create" && l.status === "fulfilled" && X(l.value?.id), c.status === "rejected") throw c.reason;
119
+ if (l.status === "rejected") throw l.reason;
120
+ D("none");
121
+ } else g ||= (await L.mutateAsync({ body: o(U, j) }))?.id, g && j === "vendor" && f(U) && (Q(g), await z.mutateAsync({
122
+ path: { counterpart_id: g },
123
+ body: i(U.bankAccount)
124
+ })), Q(void 0), D("none"), g && k(g);
78
125
  } catch (t) {
79
- c && (V(c), T(c)), z({ form: e(t) ?? E.genericError });
126
+ g && (Q(g), k(g)), K({ form: e(t) ?? A.genericError });
80
127
  }
81
128
  }, [
82
129
  r,
83
- I,
84
- w,
85
- B,
86
- E,
87
- D,
88
- k,
89
- M,
90
- N,
130
+ U,
131
+ O,
132
+ Z,
133
+ A,
91
134
  j,
92
- F,
135
+ N,
93
136
  P,
94
- C,
95
- T
137
+ Y,
138
+ R,
139
+ z,
140
+ L,
141
+ V,
142
+ H,
143
+ B,
144
+ D,
145
+ k
96
146
  ])
97
147
  };
98
148
  }
99
149
  //#endregion
100
- export { C as useCounterpartForm };
150
+ export { D as useCounterpartForm };
@@ -1,12 +1,13 @@
1
- import { COUNTERPART_FORM_SHEET_LABELS_EN as e, COUNTERPART_TYPE_BADGE_LABELS_EN as t } from "./index2.js";
1
+ import { ACH_FIELD_GROUP_LABELS_EN as e, COUNTERPART_FORM_SHEET_LABELS_EN as t, COUNTERPART_TYPE_BADGE_LABELS_EN as n } from "./index2.js";
2
2
  import "./index3.js";
3
- import { AddressFieldGroup as n, EMPTY_ADDRESS_FORM_VALUES as r } from "./index5.js";
4
- import "./index6.js";
5
- import { CounterpartFormFields as i, CounterpartFormSheet as a } from "./index8.js";
6
- import "./index9.js";
7
- import { BankAccountFormSheet as o } from "./index10.js";
8
- import "./index11.js";
9
- import { AddressFormSheet as s } from "./index12.js";
10
- import { ConfirmDeleteDialog as c } from "./index13.js";
11
- import { CounterpartSelector as l } from "./index14.js";
12
- export { n as AddressFieldGroup, s as AddressFormSheet, o as BankAccountFormSheet, e as COUNTERPART_FORM_SHEET_LABELS_EN, t as COUNTERPART_TYPE_BADGE_LABELS_EN, c as ConfirmDeleteDialog, i as CounterpartFormFields, a as CounterpartFormSheet, l as CounterpartSelector, r as EMPTY_ADDRESS_FORM_VALUES };
3
+ import { AchFieldGroup as r } from "./index5.js";
4
+ import { EMPTY_ADDRESS_FORM_VALUES as i } from "./index6.js";
5
+ import "./index7.js";
6
+ import { CounterpartFormFields as a, CounterpartFormSheet as o, useFocusFirstInvalidField as s } from "./index9.js";
7
+ import "./index10.js";
8
+ import { BankAccountFormSheet as c } from "./index11.js";
9
+ import "./index12.js";
10
+ import { AddressFormSheet as l } from "./index13.js";
11
+ import { ConfirmDeleteDialog as u } from "./index14.js";
12
+ import { CounterpartSelector as d } from "./index15.js";
13
+ export { e as ACH_FIELD_GROUP_LABELS_EN, r as AchFieldGroup, l as AddressFormSheet, c as BankAccountFormSheet, t as COUNTERPART_FORM_SHEET_LABELS_EN, n as COUNTERPART_TYPE_BADGE_LABELS_EN, u as ConfirmDeleteDialog, a as CounterpartFormFields, o as CounterpartFormSheet, d as CounterpartSelector, i as EMPTY_ADDRESS_FORM_VALUES, s as useFocusFirstInvalidField };