@tesouro/embedded-components-react 0.5.28 → 0.5.31

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 (118) hide show
  1. package/README.md +14 -13
  2. package/dist/index.css +15 -0
  3. package/dist/index.d.ts +9 -0
  4. package/dist/index.js +1 -1
  5. package/dist/lib/BankAccountOnboardingWidget.d.ts +9 -0
  6. package/dist/lib/BillPayWidget.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +155 -151
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +5 -5
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index14.js +2 -44
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +7 -7
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +1 -1
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +2 -2
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +2 -2
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +52 -67
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +15 -12
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +57 -62
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +1 -1
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +68 -207
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +278 -175
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +13 -126
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +47 -12
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +53 -47
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +204 -49
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +32 -202
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +234 -32
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +21 -240
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +532 -19
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +4 -436
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +42 -4
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +230 -35
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +3 -233
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +4 -3
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +44 -2
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +1 -46
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -1
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +11 -6
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +127 -11
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -129
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +127 -3
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -124
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +7 -8
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +46 -8
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +18 -43
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +28 -20
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +82 -27
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +47 -83
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +250 -47
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +122 -241
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +206 -126
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +3 -213
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +8 -4
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +113 -6
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +1 -115
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +24 -0
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +39 -33
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index101.js +10 -11
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index102.js +123 -8
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index103.js +2 -170
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index104.js +18 -2
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index105.js +7 -11
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index106.js +158 -96
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index107.js +1 -1
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index108.js +11 -7
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index109.js +100 -44
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index111.js +10 -0
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index112.js +52 -0
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index113.js +2 -0
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +1 -1
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +20 -22
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +4 -9
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +103 -146
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +3 -2
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +93 -88
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +15 -16
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index48.js +1 -0
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index50.js +43 -29
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index65.js +55 -51
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index66.js +9 -2
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index67.js +33 -1
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index68.js +2 -8
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index69.js +2 -39
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index70.js +0 -1
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index71.js +6 -2
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index72.js +34 -31
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index74.js +2 -37
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index75.js +34 -10
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index76.js +2 -201
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index77.js +39 -3
  90. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index78.js +3 -8
  91. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index79.js +187 -350
  92. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index80.js +3 -10
  93. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index81.js +13 -5
  94. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +356 -85
  95. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index83.js +10 -0
  96. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index84.js +9 -2
  97. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index85.js +87 -119
  98. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index87.js +2 -94
  99. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index88.js +125 -2
  100. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index89.js +25 -4
  101. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index90.js +90 -26
  102. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index92.js +3 -3
  103. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index93.js +26 -30
  104. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index95.js +4 -9
  105. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index96.js +30 -102
  106. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index98.js +9 -14
  107. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index99.js +85 -104
  108. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index.js +5 -5
  109. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +17 -17
  110. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js +4 -0
  111. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +92 -87
  112. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  113. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShell.js +126 -105
  114. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShellOverlayPortal.js +13 -6
  115. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  116. package/package.json +1 -1
  117. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +0 -25
  118. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index86.js +0 -28
@@ -8,215 +8,318 @@ import "../../../shared/data-access/dist/index.js";
8
8
  import { useWidgetConfig as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
9
  import "../../../shared/feature/dist/index.js";
10
10
  import { useCounterpartsQuery as r } from "../../../shared/counterpart-management/data-access/dist/index3.js";
11
- import { useCreateCounterpartBankAccountMutation as ee, useUpdateCounterpartBankAccountMutation as te } from "../../../shared/counterpart-management/data-access/dist/index5.js";
12
- import { usePayableSuggestionsQuery as i } from "../../data-access/dist/index18.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";
13
13
  import "../../data-access/dist/index.js";
14
- import { maskAccountNumber as a } from "./index23.js";
15
- import { counterpartFormBankAccountToCreatePayload as ne, counterpartFormBankAccountToUpdatePayload as re, getAchInstructions as ie, getCounterpartEmail as o, getCounterpartName as s, getPayableAchInstructions as c, hasAchFormValues as l, resolveCounterpartBankAccountWrite as ae, validateAchFormValues as oe } from "../../../shared/counterpart-management/feature/dist/lib/helpers.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
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";
17
18
  import "../../../shared/counterpart-management/feature/dist/index.js";
18
- import { VENDOR_SECTION_PROPS_LABELS_EN as ce } from "./index48.js";
19
- import { buildVendorPrefill as le } from "./index50.js";
20
- import { VendorInlineForm as ue } from "./index51.js";
19
+ import { VENDOR_SECTION_PROPS_LABELS_EN as le } from "./index48.js";
20
+ import { buildVendorPrefill as ue } from "./index50.js";
21
+ import { VendorInlineForm as de } from "./index51.js";
21
22
  import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
22
- import { jsx as de } from "react/jsx-runtime";
23
+ import { jsx as fe } from "react/jsx-runtime";
23
24
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js
24
- var fe = 10, h = 300, g = {
25
+ var pe = 10, me = 300, h = {
25
26
  accountHolderName: "",
26
27
  routingNumber: "",
27
28
  accountNumber: ""
28
29
  };
29
- function _({ payableId: _, counterpartId: v, payableCounterpartId: y, payableCounterpartBankAccountId: b, isVendorKnown: x = !0, onCounterpartChange: S, requiredError: pe, extractedVendor: C, labels: me }) {
30
- let w = {
31
- ...ce,
32
- ...me
33
- }, { initResponse: T } = n(), he = e(T?.scopes, [t.CounterpartReadOrg]), [E, D] = m(""), [ge, _e] = m(""), [O, k] = m(), [ve, A] = m(!1), [j, M] = m(g), N = p(j);
34
- N.current = j;
35
- let [P, F] = m(!1), I = l(j) || P, [ye, L] = m(), [R, z] = m(), B = p(v), [V, be] = m(!1), H = u(() => {
36
- A(!1), M(g), L(void 0), z(void 0);
37
- }, []), U = u((e) => {
38
- be(!0), S(e);
39
- }, [S]), W = i(_, { enabled: !!_ && !v && !y }).data?.suggested_counterpart?.id;
30
+ function he(e) {
31
+ return {
32
+ accountHolderName: e.account_holder_name ?? "",
33
+ routingNumber: e.routing_number ?? "",
34
+ accountNumber: e.account_number ?? ""
35
+ };
36
+ }
37
+ function g(e, t) {
38
+ return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
39
+ }
40
+ function ge(e, t) {
41
+ return e?.find((e) => e.id === t && l(e)) ?? o(e);
42
+ }
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;
40
54
  d(() => {
41
- !V && !v && !y && W && U(W);
55
+ !v && !ze && !l && !_ && I && F(I);
42
56
  }, [
57
+ l,
58
+ _,
43
59
  v,
44
- y,
45
- V,
46
- W,
47
- U
60
+ ze,
61
+ I,
62
+ F
48
63
  ]), d(() => {
49
- B.current !== v && (B.current = v, H());
50
- }, [v, H]), d(() => {
64
+ Re.current !== l && (Re.current = l, P(), M(void 0));
65
+ }, [l, P]), d(() => {
51
66
  let e = setTimeout(() => {
52
- _e(E.trim());
53
- }, h);
67
+ Ae(x.trim());
68
+ }, me);
54
69
  return () => clearTimeout(e);
55
- }, [E]);
56
- let G = r({
70
+ }, [x]);
71
+ let L = r({
57
72
  sort: "counterpart_name",
58
73
  order: "asc",
59
- limit: fe,
60
- counterpart_name__icontains: ge || void 0,
74
+ limit: pe,
75
+ counterpart_name__icontains: ke || void 0,
61
76
  is_vendor: !0,
62
- enabled: !O && !v && x && he
63
- }), K = se({ selectedId: v }), q = ee(), J = te(), Y = f(() => {
64
- let e = K.counterpart;
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,
87
+ counterpartType: "vendor",
88
+ counterpart: R.counterpart,
89
+ primaryAddress: R.primaryAddress,
90
+ includeBankAccount: !1
91
+ }), { openCreate: Ue, openEdit: We, close: Ge, setValues: B, submit: Ke } = z, V = f(() => {
92
+ let e = R.counterpart;
65
93
  if (!e) return;
66
- if (K.isBankAccountsLoading) return {
67
- name: s(e),
68
- email: o(e),
69
- methodLabel: w.paymentMethodLoading,
70
- fields: []
94
+ if (R.isBankAccountsLoading) return {
95
+ name: c(e),
96
+ email: s(e),
97
+ methodLabel: b.paymentMethodLoading,
98
+ hasPaymentInstructions: !1
71
99
  };
72
- if (K.isBankAccountsError) return {
73
- name: s(e),
74
- email: o(e),
75
- methodLabel: w.paymentMethodUnavailable,
76
- fields: []
100
+ if (R.isBankAccountsError) return {
101
+ name: c(e),
102
+ email: s(e),
103
+ methodLabel: b.paymentMethodUnavailable,
104
+ hasPaymentInstructions: !1
77
105
  };
78
- let t = c(K.bankAccounts);
106
+ let t = ie(R.bankAccounts);
79
107
  return {
80
- name: s(e),
81
- email: o(e),
82
- methodLabel: t ? w.achMethod : w.noMethod,
83
- fields: t ? [
84
- {
85
- label: w.accountHolder,
86
- value: t.account_holder_name ?? ""
87
- },
88
- {
89
- label: w.routingNumber,
90
- value: t.routing_number ?? ""
91
- },
92
- {
93
- label: w.accountNumber,
94
- value: t.account_number ?? "",
95
- maskedValue: t.account_number ? a(t.account_number) : ""
96
- }
97
- ] : []
108
+ name: c(e),
109
+ email: s(e),
110
+ methodLabel: t ? b.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : b.noMethod,
111
+ hasPaymentInstructions: !!t
98
112
  };
99
113
  }, [
100
- K.bankAccounts,
101
- K.counterpart,
102
- K.isBankAccountsError,
103
- K.isBankAccountsLoading,
104
- w
105
- ]), X = f(() => ie(K.bankAccounts), [K.bankAccounts]), Z = f(() => c(K.bankAccounts)?.id, [K.bankAccounts]), Q = u(async () => {
106
- let e = N.current;
107
- if (!v) return { ok: !0 };
108
- if (!l(e)) return b && v === y ? {
109
- ok: !0,
110
- counterpartBankAccountId: b
111
- } : K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError ? { ok: !1 } : {
112
- ok: !0,
113
- counterpartBankAccountId: Z
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();
123
+ else {
124
+ Ue();
125
+ let e = x.trim();
126
+ B((t) => ({
127
+ ...t,
128
+ 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
133
+ }));
134
+ }
135
+ C(e);
136
+ }, [
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();
148
+ }, [
149
+ P,
150
+ y,
151
+ N
152
+ ]), J = u(() => {
153
+ G(), P();
154
+ }, [P, G]), Y = Fe || N, X = u((e) => {
155
+ let t = () => {
156
+ J(), e();
114
157
  };
115
- if (K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError) return { ok: !1 };
116
- let t = oe(e);
117
- if (Object.keys(t).length > 0) return L(t), A(!0), { ok: !1 };
118
- L(void 0);
119
- let n = ae(K.bankAccounts, R ?? X?.id);
120
- if (n.kind === "update") return await J.mutateAsync({
158
+ Y ? y(t) : t();
159
+ }, [
160
+ y,
161
+ J,
162
+ Y
163
+ ]), Xe = u(() => {
164
+ Y ? y(J) : J();
165
+ }, [
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 };
174
+ }
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);
180
+ }
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 {
185
+ ok: !0,
186
+ counterpartId: e
187
+ };
188
+ let n = j ?? H;
189
+ return n ? (E(!1), {
190
+ ok: !0,
191
+ counterpartId: e,
192
+ counterpartBankAccountId: n
193
+ }) : r ? { ok: !1 } : (E(!1), {
194
+ ok: !0,
195
+ counterpartId: e,
196
+ counterpartBankAccountId: qe
197
+ });
198
+ }
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({
121
203
  path: {
122
- counterpart_id: v,
123
- bank_account_id: n.bankAccountId
204
+ counterpart_id: e,
205
+ bank_account_id: i.bankAccountId
124
206
  },
125
- body: re(e, { includeAchDefaults: n.includeAchDefaults })
126
- }), z(n.bankAccountId), {
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), {
127
212
  ok: !0,
128
- counterpartBankAccountId: n.bankAccountId
129
- };
130
- let r = await q.mutateAsync({
131
- path: { counterpart_id: v },
132
- body: ne(e, { isDefaultForCurrency: n.isDefaultForCurrency })
133
- });
134
- return z(r?.id), {
135
- ok: !0,
136
- counterpartBankAccountId: r?.id
213
+ counterpartId: e,
214
+ counterpartBankAccountId: a
137
215
  };
138
216
  }, [
217
+ P,
218
+ 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),
237
+ onSelect: () => {
238
+ X(() => F(e.id));
239
+ }
240
+ })), [
241
+ L.data,
139
242
  X,
140
- v,
141
- q,
142
- K.bankAccounts,
143
- K.isBankAccountsError,
144
- K.isBankAccountsFetching,
145
- K.isBankAccountsLoading,
146
- R,
147
- Z,
148
- b,
149
- y,
150
- J
151
- ]), xe = f(() => (G.data?.data ?? []).map((e) => ({
152
- name: s(e),
153
- email: o(e),
154
- onSelect: () => U(e.id)
155
- })), [G.data, U]), Se = f(() => le(C), [C]), $ = u(() => {
156
- k(void 0), F(!1);
157
- }, []), Ce = u((e) => {
158
- k(void 0), F(!1), U(e);
159
- }, [U]);
160
- if (O) return {
243
+ F
244
+ ]), $e = u((e) => {
245
+ w(!0), B((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
246
+ ...t,
247
+ ...e,
248
+ firstName: t.firstName || t.legalName,
249
+ legalName: t.legalName
250
+ } : e.entityType === "organization" && t.entityType !== "organization" ? {
251
+ ...t,
252
+ ...e,
253
+ legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
254
+ } : {
255
+ ...t,
256
+ ...e
257
+ });
258
+ }, [B]), et = u((e) => {
259
+ w(!0), B((t) => ({
260
+ ...t,
261
+ address: {
262
+ ...t.address,
263
+ ...e
264
+ }
265
+ }));
266
+ }, [B]), Z = {
267
+ query: x,
268
+ onQueryChange: Oe,
269
+ isLoading: !ve || !Ee || !!l && R.isLoading || L.isFetching,
270
+ onAddVendor: () => {
271
+ X(() => q("create"));
272
+ },
273
+ results: Qe
274
+ }, Q = we && (S === "create" || !W) ? {
275
+ isOpen: T,
276
+ values: D,
277
+ errors: Le,
278
+ onOpen: Je,
279
+ onCancel: Ye,
280
+ onChange: (e) => {
281
+ O((t) => ({
282
+ ...t,
283
+ ...e
284
+ })), A(void 0);
285
+ }
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
293
+ };
294
+ return S ? {
161
295
  mode: "creating",
162
- newVendorForm: /* @__PURE__ */ de(ue, {
163
- mode: O,
164
- counterpart: O === "edit" ? K.counterpart : void 0,
165
- primaryAddress: O === "edit" ? K.primaryAddress : void 0,
166
- bankAccounts: O === "edit" ? K.bankAccounts : void 0,
167
- isBankAccountsLoading: O === "edit" ? K.isBankAccountsLoading : void 0,
168
- isBankAccountsError: O === "edit" ? K.isBankAccountsError : void 0,
169
- initialName: O === "create" ? E : void 0,
170
- initialValues: O === "create" ? Se : void 0,
171
- onSaved: Ce,
172
- onCancel: $,
173
- onDirtyChange: F
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
174
307
  }),
175
- onClear: $,
176
- hasUnsavedVendorChanges: I
177
- };
178
- if (Y) {
179
- let e = K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError;
180
- return {
181
- mode: "resolved",
182
- summary: Y,
183
- onEdit: e ? void 0 : () => k("edit"),
184
- onClear: () => U(void 0),
185
- paymentInstructions: e ? void 0 : {
186
- isOpen: ve,
187
- values: j,
188
- errors: ye,
189
- onOpen: () => {
190
- A(!0), X && (M({
191
- accountHolderName: X.account_holder_name ?? "",
192
- routingNumber: X.routing_number ?? "",
193
- accountNumber: X.account_number ?? ""
194
- }), z(X.id));
195
- },
196
- onChange: (e) => {
197
- M((t) => ({
198
- ...t,
199
- ...e
200
- })), L(void 0);
201
- }
202
- },
203
- savePaymentInstructions: Q,
204
- hasUnsavedVendorChanges: I
205
- };
206
- }
207
- let we = !x || !T || !!v && K.isLoading;
208
- return {
308
+ ...$
309
+ } : V ? {
310
+ mode: "resolved",
311
+ summary: V,
312
+ onEdit: Se && !W ? () => q("edit") : void 0,
313
+ paymentInstructions: Q ? {
314
+ ...Q,
315
+ canEditExisting: Ce
316
+ } : void 0,
317
+ ...$
318
+ } : {
209
319
  mode: "selecting",
210
- error: G.isError ? w.searchFailed : K.isError ? w.vendorDetailsFailed : pe,
211
- search: {
212
- query: E,
213
- onQueryChange: D,
214
- isLoading: we || G.isFetching,
215
- onAddVendor: () => k("create"),
216
- results: xe
217
- },
218
- savePaymentInstructions: Q,
219
- hasUnsavedVendorChanges: I
320
+ error: L.isError ? b.searchFailed : R.isError ? b.vendorDetailsFailed : be,
321
+ search: Z,
322
+ ...$
220
323
  };
221
324
  }
222
325
  //#endregion
@@ -1,129 +1,16 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import "../../../shared/ui/dist/index.js";
7
- import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
8
- import { useUpdatePayableMutation as n } from "../../data-access/dist/index13.js";
9
- import { useCounterpartBankAccountsQuery as r, useCreateCounterpartBankAccountMutation as i } from "../../../shared/counterpart-management/data-access/dist/index5.js";
10
- import { useUpdatePayableCounterpartBankAccountMutation as a } from "../../data-access/dist/index14.js";
11
- import "../../data-access/dist/index.js";
12
- import { counterpartFormBankAccountToCreatePayload as o, counterpartFormBankAccountToUpdatePayload as s, getAchInstructions as c, isAchCompatibleBankAccount as l, resolveCounterpartBankAccountWrite as u, validateAchFormValues as d } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
13
- import "../../../shared/counterpart-management/feature/dist/index.js";
14
- import { useCallback as f, useEffect as p, useRef as m, useState as h } from "react";
15
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js
16
- function g(e, n) {
17
- let r = t(n);
18
- return r ? `${e} ${r}` : e;
19
- }
20
- var _ = {
21
- accountHolderName: "",
22
- routingNumber: "",
23
- accountNumber: ""
24
- };
25
- function v(e, t) {
26
- return e?.find((e) => e.id === t && l(e)) ?? c(e);
27
- }
28
- function y({ payableId: t, counterpartId: l, currentBankAccountId: y, canReadCounterpartBankAccounts: b = !0, saveErrorMessage: x, linkErrorMessage: S }) {
29
- let [C, w] = h(!1), [T, E] = h(_), [D, O] = h(), k = r(l, { enabled: b }), A = k.data?.data, j = i(), M = a(), N = n(), P = m(void 0), F = m(!1);
30
- p(() => {
31
- P.current = void 0;
32
- }, [l, t]);
33
- let I = f(() => {
34
- if (C) return;
35
- let e = k.isFetching ? void 0 : v(A, y);
36
- E(e ? {
37
- accountHolderName: e.account_holder_name ?? "",
38
- routingNumber: e.routing_number ?? "",
39
- accountNumber: e.account_number ?? ""
40
- } : _), P.current = e?.id ?? P.current, F.current = !k.isFetching, O(void 0), w(!0);
41
- }, [
42
- A,
43
- k.isFetching,
44
- y,
45
- C
46
- ]);
47
- p(() => {
48
- if (!C || F.current || k.isFetching) return;
49
- F.current = !0;
50
- let e = v(A, y);
51
- e && (E((t) => t.accountHolderName === "" && t.routingNumber === "" && t.accountNumber === "" ? {
52
- accountHolderName: e.account_holder_name ?? "",
53
- routingNumber: e.routing_number ?? "",
54
- accountNumber: e.account_number ?? ""
55
- } : t), P.current = e.id);
56
- }, [
57
- C,
58
- k.isFetching,
59
- A,
60
- y,
61
- b
62
- ]);
63
- let L = f(() => {
64
- w(!1);
65
- }, []), R = f((e) => {
66
- E((t) => ({
67
- ...t,
68
- ...e
69
- }));
70
- }, []), z = f(async () => {
71
- if (!t || !l) return !1;
72
- let n = d(T);
73
- if (Object.keys(n).length > 0) return O(n), !1;
74
- if (O(void 0), !b || k.isFetching || k.isError) return e.error(x), !1;
75
- let r = P.current;
76
- try {
77
- let e = u(A, r ?? c(A)?.id);
78
- e.kind === "update" ? (await M.mutateAsync({
79
- path: {
80
- counterpart_id: l,
81
- bank_account_id: e.bankAccountId
82
- },
83
- body: s(T, { includeAchDefaults: e.includeAchDefaults }),
84
- payableId: t,
85
- makeDefault: e.includeAchDefaults || !A?.find((t) => t.id === e.bankAccountId)?.is_default_for_currency
86
- }), r = e.bankAccountId) : r = (await j.mutateAsync({
87
- path: { counterpart_id: l },
88
- body: o(T, { isDefaultForCurrency: e.isDefaultForCurrency })
89
- }))?.id, P.current = r;
90
- } catch (t) {
91
- return e.error(g(x, t)), !1;
92
- }
93
- if (r !== y) try {
94
- await N.mutateAsync({
95
- path: { payable_id: t },
96
- body: { counterpart_bank_account_id: r }
97
- });
98
- } catch (t) {
99
- return e.error(g(S, t)), !1;
100
- }
101
- return w(!1), !0;
102
- }, [
103
- A,
104
- k.isError,
105
- k.isFetching,
106
- b,
107
- l,
108
- j,
109
- y,
110
- S,
111
- t,
112
- x,
113
- M,
114
- N,
115
- T
116
- ]);
117
- return {
118
- isOpen: C,
119
- values: T,
120
- errors: D,
121
- isSaving: j.isPending || M.isPending || N.isPending,
122
- open: I,
123
- close: L,
124
- onChange: R,
125
- save: z
126
- };
2
+ function e(e) {
3
+ return new Promise((t, n) => {
4
+ let r = new FileReader();
5
+ r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("Failed to read file")), r.onload = () => {
6
+ let e = r.result;
7
+ if (typeof e != "string") {
8
+ n(/* @__PURE__ */ Error("Failed to read file as a data URL"));
9
+ return;
10
+ }
11
+ t(e.slice(e.indexOf(",") + 1));
12
+ }, r.readAsDataURL(e);
13
+ });
127
14
  }
128
15
  //#endregion
129
- export { y as usePaymentInstructionsForm };
16
+ export { e as encodeFileToBase64 };