@tesouro/embedded-components-react 0.7.28 → 0.7.29

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 (34) hide show
  1. package/dist/index.d.ts +1 -12
  2. package/dist/lib/CounterpartsWidget.d.ts +1 -12
  3. package/dist/lib/CounterpartsWidgetPublic.d.ts +1 -12
  4. package/dist/lib/CustomersWidget.d.ts +0 -2
  5. package/dist/lib/ReceivablesWidget.d.ts +0 -2
  6. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsContainer.js +59 -38
  7. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsPanel.js +137 -0
  8. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartsWidget.js +86 -182
  9. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsActions.js +116 -0
  10. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsSheetView.js +16 -16
  11. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js +51 -108
  12. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useRebaseOnRefresh.js +33 -0
  13. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/viewModels.js +40 -39
  14. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index.js +1 -1
  15. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index4.js +2 -65
  16. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index5.js +37 -181
  17. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index6.js +193 -502
  18. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index7.js +520 -0
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +2 -0
  20. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index.js +3 -3
  21. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index5.js +31 -55
  22. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +11 -11
  23. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +98 -163
  24. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +1 -3
  25. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/subEntityForms.js +37 -32
  26. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +86 -93
  27. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index10.js +2 -0
  28. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index12.js +42 -173
  29. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +3 -12
  30. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index5.js +16 -16
  31. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +42 -42
  32. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +117 -125
  33. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  34. package/package.json +1 -1
@@ -6,27 +6,7 @@ import { EMPTY_ADDRESS_FORM_VALUES as i } from "../../../ui/dist/index6.js";
6
6
  import "../../../ui/dist/index.js";
7
7
  import { COUNTERPART_MESSAGE_LABELS_EN as a } from "./labels.js";
8
8
  //#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js
9
- var o = [
10
- "USD",
11
- "EUR",
12
- "GBP",
13
- "CAD",
14
- "AUD",
15
- "JPY",
16
- "CHF",
17
- "CNY",
18
- "INR",
19
- "BRL",
20
- "MXN",
21
- "SGD"
22
- ];
23
- function s(e) {
24
- return Array.from(/* @__PURE__ */ new Set([...o, ...e ? [e] : []])).sort().map((e) => ({
25
- value: e,
26
- label: e
27
- }));
28
- }
29
- function c(e) {
9
+ function o(e) {
30
10
  try {
31
11
  return new Intl.NumberFormat("en-US", {
32
12
  style: "currency",
@@ -36,58 +16,58 @@ function c(e) {
36
16
  return 2;
37
17
  }
38
18
  }
39
- function l(e, t) {
40
- return e / 10 ** c(t);
19
+ function s(e, t) {
20
+ return e / 10 ** o(t);
41
21
  }
42
- function u(t, n = "USD") {
43
- return e(l(t, n), { currencyCode: n });
22
+ function c(t, n = "USD") {
23
+ return e(s(t, n), { currencyCode: n });
44
24
  }
45
- var d = new Intl.DateTimeFormat(void 0, {
25
+ var l = new Intl.DateTimeFormat(void 0, {
46
26
  year: "numeric",
47
27
  month: "short",
48
28
  day: "numeric"
49
29
  });
50
- function f(e) {
30
+ function u(e) {
51
31
  if (!e) return "";
52
32
  let t = new Date(e);
53
- return Number.isNaN(t.getTime()) ? "" : d.format(t);
33
+ return Number.isNaN(t.getTime()) ? "" : l.format(t);
54
34
  }
55
- function p(e) {
35
+ function d(e) {
56
36
  if ("organization" in e) return e.organization.legal_name;
57
37
  let { first_name: t, last_name: n } = e.individual;
58
38
  return [t, n].filter(Boolean).join(" ").trim();
59
39
  }
60
- function m(e) {
40
+ function f(e) {
61
41
  return "organization" in e ? e.organization.email ?? "" : e.individual.email ?? "";
62
42
  }
63
- function h(e) {
43
+ function p(e) {
64
44
  return "organization" in e ? e.organization.phone ?? "" : e.individual.phone ?? "";
65
45
  }
66
- function g(e) {
46
+ function m(e) {
67
47
  let t = /* @__PURE__ */ new Map();
68
48
  for (let n of e ?? []) n.dimension_value && t.set(n.dimension_value, Math.round(n.metric_value));
69
49
  return t;
70
50
  }
71
- var _ = "-";
72
- function v({ counterparts: e, addresses: n, billedAmounts: r, dueOrOwedAmounts: i, isBilledAmountLoading: a = !1, isDueOrOwedAmountLoading: o = !1, isBilledAmountError: s = !1, isDueOrOwedAmountError: c = !1 }) {
51
+ var h = "-";
52
+ function g({ counterparts: e, addresses: n, billedAmounts: r, dueOrOwedAmounts: i, isBilledAmountLoading: a = !1, isDueOrOwedAmountLoading: o = !1, isBilledAmountError: s = !1, isDueOrOwedAmountError: l = !1 }) {
73
53
  return e.map((e) => {
74
- let l = r?.get(e.id) ?? 0, d = i?.get(e.id) ?? 0, f = l - d, m = a || o, h = s || c, g = p(e);
54
+ let u = r?.get(e.id) ?? 0, f = i?.get(e.id) ?? 0, p = u - f, m = a || o, g = s || l, _ = d(e);
75
55
  return {
76
56
  id: e.id,
77
- name: g,
78
- initials: t(g),
57
+ name: _,
58
+ initials: t(_),
79
59
  entityType: e.type,
80
- locationLabel: b(n?.get(e.id)),
81
- billedAmountLabel: s ? _ : r && !a ? u(l) : "",
82
- receivedOrPaidAmountLabel: h ? _ : r && i && !m ? u(f) : "",
83
- dueOrOwedAmountLabel: c ? _ : i && !o ? u(d) : "",
60
+ locationLabel: v(n?.get(e.id)),
61
+ billedAmountLabel: s ? h : r && !a ? c(u) : "",
62
+ receivedOrPaidAmountLabel: g ? h : r && i && !m ? c(p) : "",
63
+ dueOrOwedAmountLabel: l ? h : i && !o ? c(f) : "",
84
64
  isBilledAmountLoading: a && !s,
85
- isReceivedOrPaidAmountLoading: m && !h,
86
- isDueOrOwedAmountLoading: o && !c
65
+ isReceivedOrPaidAmountLoading: m && !g,
66
+ isDueOrOwedAmountLoading: o && !l
87
67
  };
88
68
  });
89
69
  }
90
- function y(e) {
70
+ function _(e) {
91
71
  if (!e) return [];
92
72
  let t = [
93
73
  e.city,
@@ -101,27 +81,27 @@ function y(e) {
101
81
  e.country
102
82
  ].filter((e) => !!(e && e.trim()));
103
83
  }
104
- function b(e) {
84
+ function v(e) {
105
85
  return e ? [e.country, e.city].filter(Boolean).join(" • ") : "";
106
86
  }
107
- function x({ counterpart: e, primaryAddress: t }) {
87
+ function y({ counterpart: e, primaryAddress: t }) {
108
88
  return {
109
- name: p(e),
89
+ name: d(e),
110
90
  entityType: e.type,
111
- email: m(e),
112
- phone: h(e),
91
+ email: f(e),
92
+ phone: p(e),
113
93
  taxId: e.tax_id ?? "",
114
- addressLines: y(t),
115
- createdAtLabel: f(e.created_at),
116
- updatedAtLabel: f(e.updated_at)
94
+ addressLines: _(t),
95
+ createdAtLabel: u(e.created_at),
96
+ updatedAtLabel: u(e.updated_at)
117
97
  };
118
98
  }
119
- function S(e) {
99
+ function b(e) {
120
100
  if (e) return `•••• ${e.slice(-4)}`;
121
101
  }
122
- function C(e) {
102
+ function x(e) {
123
103
  return (e ?? []).map((e) => {
124
- let t = S(e.iban || e.account_number || void 0), n = [e.currency, t].filter(Boolean).join(" · ");
104
+ let t = b(e.iban || e.account_number || void 0), n = [e.currency, t].filter(Boolean).join(" · ");
125
105
  return {
126
106
  id: e.id,
127
107
  primary: e.name || e.account_holder_name || e.currency,
@@ -130,17 +110,17 @@ function C(e) {
130
110
  };
131
111
  });
132
112
  }
133
- function w(e) {
113
+ function S(e) {
134
114
  let t = (e ?? []).filter((e) => e.currency === "USD" && (!!e.routing_number || !!e.account_number));
135
115
  return t.find((e) => e.is_default_for_currency) ?? t[0];
136
116
  }
137
- function T(e, t = "USD", n) {
138
- let r = n && (e ?? []).find((e) => e.id === n && U(e));
117
+ function C(e, t = "USD", n) {
118
+ let r = n && (e ?? []).find((e) => e.id === n && V(e));
139
119
  if (r) return r;
140
120
  let i = (e ?? []).filter((e) => e.currency === t && !!e.account_holder_name && !!e.routing_number && !!e.account_number);
141
121
  return i.find((e) => e.is_default_for_currency) ?? i[0];
142
122
  }
143
- function E(e, t = {}) {
123
+ function w(e, t = {}) {
144
124
  let n = e.line2.trim();
145
125
  return {
146
126
  line1: e.line1.trim(),
@@ -151,7 +131,7 @@ function E(e, t = {}) {
151
131
  country: "US"
152
132
  };
153
133
  }
154
- function D(e) {
134
+ function T(e) {
155
135
  return {
156
136
  line1: e.line1 ?? "",
157
137
  line2: e.line2 ?? "",
@@ -160,10 +140,10 @@ function D(e) {
160
140
  postalCode: e.postal_code ?? ""
161
141
  };
162
142
  }
163
- function O(e) {
164
- return E(e);
143
+ function E(e) {
144
+ return w(e);
165
145
  }
166
- function k(e) {
146
+ function D(e) {
167
147
  return {
168
148
  line1: e.line1.trim(),
169
149
  line2: e.line2.trim(),
@@ -173,7 +153,7 @@ function k(e) {
173
153
  country: "US"
174
154
  };
175
155
  }
176
- function A(e = "organization", t) {
156
+ function O(e = "organization", t) {
177
157
  return {
178
158
  entityType: e,
179
159
  legalName: "",
@@ -192,11 +172,11 @@ function A(e = "organization", t) {
192
172
  }
193
173
  };
194
174
  }
195
- function j(e, t) {
196
- let n = A(e.type);
197
- return n.email = m(e), n.phone = h(e), n.taxId = e.tax_id ?? "", n.remindersEnabled = !!e.reminders_enabled, t && (n.address = D(t)), "organization" in e ? n.legalName = e.organization.legal_name : (n.firstName = e.individual.first_name, n.lastName = e.individual.last_name), n;
175
+ function k(e, t) {
176
+ let n = O(e.type);
177
+ return n.email = f(e), n.phone = p(e), n.taxId = e.tax_id ?? "", n.remindersEnabled = !!e.reminders_enabled, t && (n.address = T(t)), "organization" in e ? n.legalName = e.organization.legal_name : (n.firstName = e.individual.first_name, n.lastName = e.individual.last_name), n;
198
178
  }
199
- function M(e) {
179
+ function A(e) {
200
180
  return [
201
181
  e.line1,
202
182
  e.line2,
@@ -205,11 +185,11 @@ function M(e) {
205
185
  e.postalCode
206
186
  ].some((e) => e.trim().length > 0);
207
187
  }
208
- function N(e) {
209
- return M(e) ? E(e) : void 0;
188
+ function j(e) {
189
+ return A(e) ? w(e) : void 0;
210
190
  }
211
- function P(e, t) {
212
- let n = t === "customer", r = t === "vendor", i = N(e.address), a = e.taxId.trim() || void 0, o = e.email.trim(), s = e.phone.trim() || void 0, c = {
191
+ function M(e, t) {
192
+ let n = t === "customer", r = t === "vendor", i = j(e.address), a = e.taxId.trim() || void 0, o = e.email.trim(), s = e.phone.trim() || void 0, c = {
213
193
  is_customer: n,
214
194
  is_vendor: r,
215
195
  language: "en",
@@ -238,9 +218,8 @@ function P(e, t) {
238
218
  }
239
219
  };
240
220
  }
241
- function F(e, t) {
221
+ function N(e, t) {
242
222
  let n = e.taxId.trim(), r = e.email.trim(), i = e.phone.trim(), a = {
243
- language: "en",
244
223
  reminders_enabled: t === "customer" ? e.remindersEnabled : void 0,
245
224
  tax_id: n
246
225
  };
@@ -256,13 +235,12 @@ function F(e, t) {
256
235
  individual: {
257
236
  first_name: e.firstName.trim(),
258
237
  last_name: e.lastName.trim(),
259
- title: e.title.trim(),
260
238
  email: r,
261
239
  phone: i
262
240
  }
263
241
  };
264
242
  }
265
- function I(e, t, n) {
243
+ function P(e, t, n) {
266
244
  let i = {
267
245
  ...r,
268
246
  ...n
@@ -273,20 +251,20 @@ function I(e, t, n) {
273
251
  description: t === "vendor" ? i.vendorTaxIdHelp : i.customerTaxIdHelp
274
252
  };
275
253
  }
276
- function L(e) {
277
- return M(e.address);
254
+ function F(e) {
255
+ return A(e.address);
278
256
  }
279
- function R(e) {
257
+ function I(e) {
280
258
  return [
281
259
  e.accountHolderName,
282
260
  e.routingNumber,
283
261
  e.accountNumber
284
262
  ].some((e) => e.trim().length > 0);
285
263
  }
286
- function z(e) {
287
- return R(e.bankAccount);
264
+ function L(e) {
265
+ return I(e.bankAccount);
288
266
  }
289
- function B(e, t = {}) {
267
+ function R(e, t = {}) {
290
268
  return {
291
269
  account_holder_name: e.accountHolderName.trim() || void 0,
292
270
  account_number: e.accountNumber.trim() || void 0,
@@ -296,7 +274,7 @@ function B(e, t = {}) {
296
274
  is_default_for_currency: t.isDefaultForCurrency ?? !0
297
275
  };
298
276
  }
299
- function V(e, t = {}) {
277
+ function z(e, t = {}) {
300
278
  return {
301
279
  account_holder_name: e.accountHolderName.trim() || void 0,
302
280
  account_number: e.accountNumber.trim() || void 0,
@@ -307,7 +285,7 @@ function V(e, t = {}) {
307
285
  } : {}
308
286
  };
309
287
  }
310
- function H(e) {
288
+ function B(e) {
311
289
  return [
312
290
  e.account_number,
313
291
  e.iban,
@@ -316,145 +294,102 @@ function H(e) {
316
294
  e.bic
317
295
  ].every((e) => !e);
318
296
  }
319
- function U(e) {
320
- return !!(H(e) || e.currency === "USD" && (e.routing_number || e.account_number));
297
+ function V(e) {
298
+ return B(e) ? !0 : !(e.country !== "US" || e.currency !== "USD" || e.iban || e.sort_code || e.bic || !e.routing_number && !e.account_number);
321
299
  }
322
- function W(e, t) {
300
+ function H(e, t) {
323
301
  if (t) {
324
302
  let n = e?.find((e) => e.id === t);
325
303
  return {
326
304
  kind: "update",
327
305
  bankAccountId: t,
328
- includeAchDefaults: n ? H(n) : !1
306
+ includeAchDefaults: n ? B(n) : !1
329
307
  };
330
308
  }
331
- let n = e?.find(H);
309
+ let n = e?.find(B);
332
310
  return n ? {
333
311
  kind: "update",
334
312
  bankAccountId: n.id,
335
313
  includeAchDefaults: !0
336
314
  } : {
337
315
  kind: "create",
338
- isDefaultForCurrency: !(e ?? []).some((e) => e.currency === "USD" && e.is_default_for_currency)
316
+ isDefaultForCurrency: !(e ?? []).some((e) => e.currency === "USD" && e.is_default_for_currency && V(e))
339
317
  };
340
318
  }
341
- function G() {
319
+ function U() {
342
320
  return {
343
- name: "",
344
321
  accountHolderName: "",
345
- accountNumber: "",
346
322
  routingNumber: "",
347
- iban: "",
348
- bic: "",
349
- sortCode: "",
350
- currency: "USD",
351
- isDefault: !1
323
+ accountNumber: ""
352
324
  };
353
325
  }
354
- function ee(e) {
326
+ function W(e) {
355
327
  return {
356
- name: e.name ?? "",
357
328
  accountHolderName: e.account_holder_name ?? "",
358
- accountNumber: e.account_number ?? "",
359
329
  routingNumber: e.routing_number ?? "",
360
- iban: e.iban ?? "",
361
- bic: e.bic ?? "",
362
- sortCode: e.sort_code ?? "",
363
- currency: e.currency ?? "USD",
364
- isDefault: e.is_default_for_currency ?? !1
330
+ accountNumber: e.account_number ?? ""
365
331
  };
366
332
  }
367
- function K(e) {
368
- return {
369
- name: e.name.trim() || void 0,
370
- account_holder_name: e.accountHolderName.trim() || void 0,
371
- account_number: e.accountNumber.trim() || void 0,
372
- routing_number: e.routingNumber.trim() || void 0,
373
- iban: e.iban.trim() || void 0,
374
- bic: e.bic.trim() || void 0,
375
- sort_code: e.sortCode.trim() || void 0,
376
- currency: e.currency,
377
- country: "US",
378
- is_default_for_currency: e.isDefault
379
- };
380
- }
381
- function q(e) {
382
- return {
383
- name: e.name.trim(),
384
- account_holder_name: e.accountHolderName.trim(),
385
- account_number: e.accountNumber.trim(),
386
- routing_number: e.routingNumber.trim(),
387
- iban: e.iban.trim(),
388
- bic: e.bic.trim(),
389
- sort_code: e.sortCode.trim(),
390
- currency: e.currency,
391
- country: "US"
392
- };
393
- }
394
- function J(e) {
333
+ function G(e) {
395
334
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
396
335
  }
397
- function Y(e, t) {
336
+ function K(e, t) {
398
337
  let n = {};
399
338
  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;
400
339
  }
401
- function X(e) {
340
+ function q(e) {
402
341
  return Object.values(e).some(Boolean);
403
342
  }
404
- function Z(e) {
343
+ function J(e) {
405
344
  if (!/^\d{9}$/.test(e)) return !1;
406
345
  let t = [...e].map(Number);
407
346
  return (3 * (t[0] + t[3] + t[6]) + 7 * (t[1] + t[4] + t[7]) + (t[2] + t[5] + t[8])) % 10 == 0;
408
347
  }
409
- function Q(e, t = a) {
348
+ function Y(e, t = a) {
410
349
  let r = {}, i = e.accountHolderName.trim(), o = e.routingNumber.trim(), s = e.accountNumber.trim();
411
- return i.length === 0 && (r.accountHolderName = t.accountHolderNameRequired), (o.length === 0 || !Z(o)) && (r.routingNumber = t.routingNumberInvalid), n(s) || (r.accountNumber = t.accountNumberInvalid), r;
350
+ return i.length === 0 && (r.accountHolderName = t.accountHolderNameRequired), (o.length === 0 || !J(o)) && (r.routingNumber = t.routingNumberInvalid), n(s) || (r.accountNumber = t.accountNumberInvalid), r;
412
351
  }
413
- function $(e) {
352
+ function X(e) {
414
353
  let t = (/^(\+?[\d\s().-]+?)\s*(?:(?:x|ext\.?)\s*\d+)?$/i.exec(e)?.[1])?.replace(/\D/g, "").length ?? 0;
415
354
  return t >= 7 && t <= 15;
416
355
  }
417
- function te(e) {
356
+ function Z(e) {
418
357
  return /^[\d\s-]+$/.test(e) && e.replace(/\D/g, "").length === 9;
419
358
  }
420
- function ne(e, t, n = a, r = "customer", i = !1) {
359
+ function Q(e, t, n = a, r = "customer", i = !1) {
421
360
  let o = {};
422
- e.entityType === "organization" ? e.legalName.trim().length === 0 && (o.legalName = n.legalNameRequired) : (e.firstName.trim().length === 0 && (o.firstName = n.firstNameRequired), e.lastName.trim().length === 0 && (o.lastName = n.lastNameRequired)), e.email.trim().length === 0 ? o.email = n.emailRequired : J(e.email.trim()) || (o.email = n.emailInvalid);
361
+ e.entityType === "organization" ? e.legalName.trim().length === 0 && (o.legalName = n.legalNameRequired) : (e.firstName.trim().length === 0 && (o.firstName = n.firstNameRequired), e.lastName.trim().length === 0 && (o.lastName = n.lastNameRequired)), e.email.trim().length === 0 ? o.email = n.emailRequired : G(e.email.trim()) || (o.email = n.emailInvalid);
423
362
  let s = e.phone.trim();
424
- s && !$(s) && (o.phone = n.phoneInvalid);
363
+ s && !X(s) && (o.phone = n.phoneInvalid);
425
364
  let c = e.taxId.trim();
426
- if (c && !te(c) && (o.taxId = n.taxIdInvalid), t === "create" && r === "vendor" || M(e.address)) {
427
- let t = Y(e.address, n);
428
- X(t) && (o.address = t);
365
+ if (c && !Z(c) && (o.taxId = n.taxIdInvalid), t === "create" && r === "vendor" || A(e.address)) {
366
+ let t = K(e.address, n);
367
+ q(t) && (o.address = t);
429
368
  }
430
- if (r === "vendor" && (i || z(e))) {
431
- let t = Q(e.bankAccount, n);
432
- X(t) && (o.bankAccount = t);
369
+ if (r === "vendor" && (i || L(e))) {
370
+ let t = Y(e.bankAccount, n);
371
+ q(t) && (o.bankAccount = t);
433
372
  }
434
373
  return o;
435
374
  }
436
- function re(e, t, n) {
375
+ function $(e, t, n) {
437
376
  if (!n) return e;
438
377
  let r = { ...e };
439
378
  return t.phone.trim() === n.phone.trim() && delete r.phone, t.taxId.trim() === n.taxId.trim() && delete r.taxId, r;
440
379
  }
441
- function ie(e) {
380
+ function ee(e) {
442
381
  let { address: t, bankAccount: n, ...r } = e;
443
- return X(r) || (t ? X(t) : !1) || (n ? X(n) : !1);
382
+ return q(r) || (t ? q(t) : !1) || (n ? q(n) : !1);
444
383
  }
445
- function ae(e, t = a) {
446
- let n = {};
447
- return e.accountNumber.trim().length === 0 && e.iban.trim().length === 0 && (n.accountNumber = t.bankAccountIdentifierRequired), e.currency.trim().length === 0 && (n.currency = t.bankAccountCurrencyRequired), n;
448
- }
449
- function oe(e) {
450
- return X(e);
384
+ function te(e) {
385
+ return q(e);
451
386
  }
452
- function se(e, t = a) {
453
- return Y(e, t);
387
+ function ne(e, t = a) {
388
+ return K(e, t);
454
389
  }
455
- function ce() {
390
+ function re() {
456
391
  let e = globalThis.getSelection?.();
457
392
  return !!(e && e.toString().length > 0);
458
393
  }
459
394
  //#endregion
460
- export { O as addressFormToCreatePayload, k as addressFormToUpdatePayload, D as addressResponseToFormValues, K as bankAccountFormToCreatePayload, q as bankAccountFormToUpdatePayload, ee as bankAccountToFormValues, g as buildAnalyticsMap, C as buildBankAccountItems, x as buildCounterpartDetailsView, I as buildCounterpartFormTaxIdField, v as buildCounterpartRows, B as counterpartFormBankAccountToCreatePayload, V as counterpartFormBankAccountToUpdatePayload, P as counterpartFormToCreatePayload, F as counterpartFormToUpdatePayload, j as counterpartToFormValues, G as emptyBankAccountFormValues, A as emptyCounterpartFormValues, f as formatCounterpartDate, u as formatMoney, l as fromMinorUnits, w as getAchInstructions, m as getCounterpartEmail, p as getCounterpartName, s as getCurrencyOptions, T as getPayableAchInstructions, R as hasAchFormValues, oe as hasBankAccountFormErrors, L as hasCounterpartFormAddressValues, z as hasCounterpartFormBankAccountValues, ie as hasCounterpartFormErrors, ce as hasSelectedText, U as isAchCompatibleBankAccount, W as resolveCounterpartBankAccountWrite, Q as validateAchFormValues, se as validateAddressForm, ae as validateBankAccountForm, ne as validateCounterpartForm, re as withoutUnchangedContactErrors };
395
+ export { E as addressFormToCreatePayload, D as addressFormToUpdatePayload, T as addressResponseToFormValues, W as bankAccountToAchFormValues, m as buildAnalyticsMap, x as buildBankAccountItems, y as buildCounterpartDetailsView, P as buildCounterpartFormTaxIdField, g as buildCounterpartRows, R as counterpartFormBankAccountToCreatePayload, z as counterpartFormBankAccountToUpdatePayload, M as counterpartFormToCreatePayload, N as counterpartFormToUpdatePayload, k as counterpartToFormValues, U as emptyAchFormValues, O as emptyCounterpartFormValues, u as formatCounterpartDate, c as formatMoney, s as fromMinorUnits, S as getAchInstructions, f as getCounterpartEmail, d as getCounterpartName, C as getPayableAchInstructions, te as hasAchFormErrors, I as hasAchFormValues, F as hasCounterpartFormAddressValues, L as hasCounterpartFormBankAccountValues, ee as hasCounterpartFormErrors, re as hasSelectedText, V as isAchCompatibleBankAccount, H as resolveCounterpartBankAccountWrite, Y as validateAchFormValues, ne as validateAddressForm, Q as validateCounterpartForm, $ as withoutUnchangedContactErrors };
@@ -11,15 +11,13 @@ var e = {
11
11
  cityRequired: "City is required",
12
12
  stateRequired: "State is required",
13
13
  postalCodeRequired: "ZIP code is required",
14
- bankAccountIdentifierRequired: "Enter an account number or IBAN for this bank account",
15
- bankAccountCurrencyRequired: "Currency is required",
16
14
  accountHolderNameRequired: "Account holder name is required",
17
15
  routingNumberInvalid: "Enter a valid 9-digit ABA routing number",
18
16
  accountNumberInvalid: "Enter a valid account number",
19
17
  vatIdValueRequired: "VAT ID is required",
20
18
  genericError: "Something went wrong. Please try again.",
21
19
  amountsUnavailable: "Some amounts could not be loaded. Try refreshing the page.",
22
- deleteTitle: "Delete “{name}”?",
20
+ deleteTitle: "Delete {name}?",
23
21
  deleteBankAccountTitle: "Delete bank account “{account}”?",
24
22
  deleteCounterpartMessage: "This record and its contacts, bank accounts, and tax ID will be permanently removed. You can't undo this action.",
25
23
  deleteBankAccountMessage: "This removes these payment instructions from the vendor. The vendor will not be deleted. You can't undo this action."
@@ -2,43 +2,48 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { bankAccountFormToCreatePayload as e, bankAccountFormToUpdatePayload as t, bankAccountToFormValues as n, emptyBankAccountFormValues as r, getCurrencyOptions as i, hasBankAccountFormErrors as a, validateBankAccountForm as o } from "./helpers.js";
6
- import { useCreateCounterpartBankAccountMutation as s, useMakeCounterpartBankAccountDefaultMutation as c, useUpdateCounterpartBankAccountMutation as l } from "../../../data-access/dist/index5.js";
5
+ import { bankAccountToAchFormValues as e, counterpartFormBankAccountToCreatePayload as t, counterpartFormBankAccountToUpdatePayload as n, emptyAchFormValues as r, hasAchFormErrors as i, resolveCounterpartBankAccountWrite as a, validateAchFormValues as o } from "./helpers.js";
6
+ import { useCreateCounterpartBankAccountMutation as s, useUpdateCounterpartBankAccountMutation as c } from "../../../data-access/dist/index5.js";
7
7
  import "../../../data-access/dist/index.js";
8
- import { useSubEntityForm as u } from "./useSubEntityForm.js";
9
- import { useMemo as d } from "react";
8
+ import { useSubEntityForm as l } from "./useSubEntityForm.js";
10
9
  //#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/subEntityForms.js
11
- function f({ items: f, selectedId: p, messages: m }) {
12
- let h = s(), g = l(), _ = c(), v = u({
13
- items: f,
10
+ function u({ items: u, selectedId: d, messages: f }) {
11
+ let p = s(), m = c(), h = l({
12
+ items: u,
14
13
  empty: r,
15
- toFormValues: n,
16
- validate: (e) => o(e, m),
17
- hasErrors: a,
18
- genericError: m.genericError,
19
- onSubmit: async ({ mode: n, id: r, values: i, existing: a }) => {
20
- if (!p) return;
21
- let o = r;
22
- n === "edit" && r ? await g.mutateAsync({
23
- path: {
24
- counterpart_id: p,
25
- bank_account_id: r
26
- },
27
- body: t(i)
28
- }) : o = (await h.mutateAsync({
29
- path: { counterpart_id: p },
30
- body: e(i)
31
- }))?.id, i.isDefault && !a?.is_default_for_currency && o && await _.mutateAsync({ path: {
32
- counterpart_id: p,
33
- bank_account_id: o
34
- } });
14
+ toFormValues: e,
15
+ validate: (e) => o(e, f),
16
+ hasErrors: (e) => i(e),
17
+ genericError: f.genericError,
18
+ onSubmit: async ({ mode: e, id: r, values: i }) => {
19
+ if (!d) return;
20
+ let o = a(u, e === "edit" ? r : void 0);
21
+ if (o.kind === "update") {
22
+ await m.mutateAsync({
23
+ path: {
24
+ counterpart_id: d,
25
+ bank_account_id: o.bankAccountId
26
+ },
27
+ body: n(i, { includeAchDefaults: o.includeAchDefaults })
28
+ });
29
+ return;
30
+ }
31
+ await p.mutateAsync({
32
+ path: { counterpart_id: d },
33
+ body: t(i, { isDefaultForCurrency: o.isDefaultForCurrency })
34
+ });
35
35
  }
36
- }), y = d(() => i(v.values.currency), [v.values.currency]);
36
+ }), g = h.sheet.mode === "edit" ? u?.find((e) => e.id === h.sheet.id) : void 0, _ = g ? {
37
+ accountHolderName: !h.values.accountHolderName.trim(),
38
+ routingNumber: !h.values.routingNumber.trim(),
39
+ accountNumber: !h.values.accountNumber.trim()
40
+ } : void 0, v = g ? e(g) : r(), y = Object.keys(v).some((e) => h.values[e] !== v[e]);
37
41
  return {
38
- form: v,
39
- inProgress: h.isPending || g.isPending || _.isPending,
40
- currencyOptions: y
42
+ form: h,
43
+ inProgress: p.isPending || m.isPending,
44
+ highlightedFields: _,
45
+ isDirty: y
41
46
  };
42
47
  }
43
48
  //#endregion
44
- export { f as useBankAccountForm };
49
+ export { u as useBankAccountForm };