@tesouro/embedded-components-react 0.3.63 → 0.4.1

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 (82) hide show
  1. package/README.md +1 -70
  2. package/dist/index.d.ts +67 -832
  3. package/dist/index.js +18 -34
  4. package/dist/lib/BillPayWidget.js +1 -1
  5. package/dist/lib/SettingsWidget.d.ts +53 -7
  6. package/dist/lib/SettingsWidget.js +4 -2
  7. package/dist/lib/WidgetSuite.d.ts +38 -0
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +8 -8
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +8 -14
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +7 -57
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +56 -16
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +18 -126
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +126 -14
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +22 -4
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +4 -41
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +40 -4
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +5 -73
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +72 -48
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +47 -91
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +91 -33
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +33 -167
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +167 -75
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +75 -21
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +23 -210
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +199 -203
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +198 -89
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +105 -13
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +12 -47
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +47 -31
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +27 -198
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +198 -30
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +30 -234
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +240 -18
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +18 -341
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +343 -4
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +4 -33
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +31 -83
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +78 -163
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +170 -3
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +3 -4
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +2 -44
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +46 -1
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +1 -8
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +6 -9
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +9 -92
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +94 -3
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +3 -128
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +125 -8
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -7
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +8 -46
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +43 -18
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +20 -28
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +27 -82
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +83 -47
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +47 -250
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +239 -101
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +107 -202
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +209 -3
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +4 -8
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +6 -113
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +115 -1
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +0 -24
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +25 -0
  64. package/dist/libs/tesouro-embedded-components-react/gl-code-table-widget/feature/dist/index.js +3 -3
  65. package/dist/libs/tesouro-embedded-components-react/gl-code-table-widget/ui/dist/index.js +5 -5
  66. package/dist/libs/tesouro-embedded-components-react/help-widget/feature/dist/index.js +4 -2
  67. package/dist/libs/tesouro-embedded-components-react/help-widget/ui/shadcn/dist/index.js +4 -4
  68. package/dist/libs/tesouro-embedded-components-react/help-widget/ui/shadcn/dist/index4.js +2 -3
  69. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js +35 -32
  70. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  71. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  72. package/package.json +1 -1
  73. package/dist/lib/ChartOfAccountsWidget.d.ts +0 -958
  74. package/dist/lib/ChartOfAccountsWidget.js +0 -9
  75. package/dist/lib/HelpWidget.d.ts +0 -739
  76. package/dist/lib/HelpWidget.js +0 -6
  77. package/dist/lib/ProfileWidget.d.ts +0 -672
  78. package/dist/lib/ProfileWidget.js +0 -3
  79. package/dist/lib/TagsWidget.d.ts +0 -719
  80. package/dist/lib/TagsWidget.js +0 -3
  81. package/dist/lib/TeamWidget.d.ts +0 -878
  82. package/dist/lib/TeamWidget.js +0 -3
@@ -2,107 +2,216 @@
2
2
  "use client";
3
3
  "use client";
4
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 { useUpdatePayableMutation as t } from "../../data-access/dist/index12.js";
5
+ import { usePayableSuggestionsQuery as e } from "../../data-access/dist/index16.js";
8
6
  import "../../data-access/dist/index.js";
9
- import { counterpartFormBankAccountToCreatePayload as n, counterpartFormBankAccountToUpdatePayload as r, getAchInstructions as i, resolveCounterpartBankAccountWrite as a, validateAchFormValues as o } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
10
- import { useCounterpartBankAccountsQuery as s, useCreateCounterpartBankAccountMutation as c, useUpdateCounterpartBankAccountMutation as l } from "../../../shared/counterpart-management/data-access/dist/index5.js";
7
+ import { maskAccountNumber as t } from "./index19.js";
8
+ import { counterpartFormBankAccountToCreatePayload as n, counterpartFormBankAccountToUpdatePayload as ee, getAchInstructions as r, getCounterpartEmail as i, getCounterpartName as a, getPayableAchInstructions as o, hasAchFormValues as s, resolveCounterpartBankAccountWrite as c, validateAchFormValues as te } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
9
+ import { useCounterpartsQuery as ne } from "../../../shared/counterpart-management/data-access/dist/index3.js";
10
+ import { useCreateCounterpartBankAccountMutation as re, useUpdateCounterpartBankAccountMutation as ie } from "../../../shared/counterpart-management/data-access/dist/index5.js";
11
+ import { useCounterpartDetails as ae } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
11
12
  import "../../../shared/counterpart-management/feature/dist/index.js";
12
- import { useCallback as u, useEffect as d, useRef as f, useState as p } from "react";
13
+ import { VENDOR_SECTION_PROPS_LABELS_EN as oe } from "./index41.js";
14
+ import { buildVendorPrefill as se } from "./index43.js";
15
+ import { VendorInlineForm as ce } from "./index44.js";
16
+ import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
17
+ import { jsx as le } from "react/jsx-runtime";
13
18
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js
14
- var m = {
19
+ var m = 10, ue = 300, h = {
15
20
  accountHolderName: "",
16
21
  routingNumber: "",
17
22
  accountNumber: ""
18
23
  };
19
- function h({ payableId: h, counterpartId: g, saveErrorMessage: _, linkErrorMessage: v }) {
20
- let [y, b] = p(!1), [x, S] = p(m), [C, w] = p(), T = s(g), E = T.data?.data, D = c(), O = l(), k = t(), A = f(void 0), j = f(!1);
21
- d(() => {
22
- A.current = void 0;
23
- }, [g]);
24
- let M = u(() => {
25
- let e = T.isFetching ? void 0 : i(E);
26
- S(e ? {
27
- accountHolderName: e.account_holder_name ?? "",
28
- routingNumber: e.routing_number ?? "",
29
- accountNumber: e.account_number ?? ""
30
- } : m), A.current = e?.id ?? A.current, j.current = !T.isFetching, w(void 0), b(!0);
31
- }, [E, T.isFetching]);
32
- d(() => {
33
- if (!y || j.current || T.isFetching) return;
34
- j.current = !0;
35
- let e = i(E);
36
- e && (S((t) => t.accountHolderName === "" && t.routingNumber === "" && t.accountNumber === "" ? {
37
- accountHolderName: e.account_holder_name ?? "",
38
- routingNumber: e.routing_number ?? "",
39
- accountNumber: e.account_number ?? ""
40
- } : t), A.current = e.id);
24
+ function g({ payableId: g, counterpartId: _, payableCounterpartId: v, payableCounterpartBankAccountId: y, onCounterpartChange: b, requiredError: de, extractedVendor: x, labels: fe }) {
25
+ let S = {
26
+ ...oe,
27
+ ...fe
28
+ }, [C, w] = p(""), [T, E] = p(""), [D, O] = p(), [pe, k] = p(!1), [A, j] = p(h), M = f(A);
29
+ M.current = A;
30
+ let [N, P] = p(!1), F = s(A) || N, [I, L] = p(), [R, z] = p(), B = f(_), [V, me] = p(!1), H = l(() => {
31
+ k(!1), j(h), L(void 0), z(void 0);
32
+ }, []), U = l((e) => {
33
+ me(!0), b(e);
34
+ }, [b]), W = e(g, { enabled: !!g && !_ && !v }).data?.suggested_counterpart?.id;
35
+ u(() => {
36
+ !V && !_ && !v && W && U(W);
41
37
  }, [
42
- y,
43
- T.isFetching,
44
- E
45
- ]);
46
- let N = u(() => {
47
- b(!1);
48
- }, []), P = u((e) => {
49
- S((t) => ({
50
- ...t,
51
- ...e
52
- }));
53
- }, []), F = u(async () => {
54
- if (!h || !g) return !1;
55
- let t = o(x);
56
- if (Object.keys(t).length > 0) return w(t), !1;
57
- if (w(void 0), T.isFetching || T.isError) return e.error(_), !1;
58
- let s = A.current;
59
- try {
60
- let e = a(E, s ?? i(E)?.id);
61
- e.kind === "update" ? (await O.mutateAsync({
62
- path: {
63
- counterpart_id: g,
64
- bank_account_id: e.bankAccountId
38
+ _,
39
+ v,
40
+ V,
41
+ W,
42
+ U
43
+ ]), u(() => {
44
+ B.current !== _ && (B.current = _, H());
45
+ }, [_, H]), u(() => {
46
+ let e = setTimeout(() => {
47
+ E(C.trim());
48
+ }, ue);
49
+ return () => clearTimeout(e);
50
+ }, [C]);
51
+ let G = ne({
52
+ sort: "counterpart_name",
53
+ order: "asc",
54
+ limit: m,
55
+ counterpart_name__icontains: T || void 0,
56
+ is_vendor: !0,
57
+ enabled: !!T
58
+ }), K = ae({ selectedId: _ }), q = re(), J = ie(), Y = d(() => {
59
+ let e = K.counterpart;
60
+ if (!e) return;
61
+ if (K.isBankAccountsLoading) return {
62
+ name: a(e),
63
+ email: i(e),
64
+ methodLabel: S.paymentMethodLoading,
65
+ fields: []
66
+ };
67
+ if (K.isBankAccountsError) return {
68
+ name: a(e),
69
+ email: i(e),
70
+ methodLabel: S.paymentMethodUnavailable,
71
+ fields: []
72
+ };
73
+ let n = o(K.bankAccounts);
74
+ return {
75
+ name: a(e),
76
+ email: i(e),
77
+ methodLabel: n ? S.achMethod : S.noMethod,
78
+ fields: n ? [
79
+ {
80
+ label: S.accountHolder,
81
+ value: n.account_holder_name ?? ""
65
82
  },
66
- body: r(x, { includeAchDefaults: e.includeAchDefaults })
67
- }), s = e.bankAccountId) : s = (await D.mutateAsync({
68
- path: { counterpart_id: g },
69
- body: n(x, { isDefaultForCurrency: e.isDefaultForCurrency })
70
- }))?.id, A.current = s;
71
- } catch {
72
- return e.error(_), !1;
73
- }
74
- try {
75
- await k.mutateAsync({
76
- path: { payable_id: h },
77
- body: { counterpart_bank_account_id: s }
78
- });
79
- } catch {
80
- return e.error(v), !1;
81
- }
82
- return b(!1), !0;
83
+ {
84
+ label: S.routingNumber,
85
+ value: n.routing_number ?? ""
86
+ },
87
+ {
88
+ label: S.accountNumber,
89
+ value: n.account_number ?? "",
90
+ maskedValue: n.account_number ? t(n.account_number) : ""
91
+ }
92
+ ] : []
93
+ };
83
94
  }, [
84
- E,
85
- T.isError,
86
- T.isFetching,
87
- g,
88
- D,
89
- v,
90
- h,
95
+ K.bankAccounts,
96
+ K.counterpart,
97
+ K.isBankAccountsError,
98
+ K.isBankAccountsLoading,
99
+ S
100
+ ]), X = d(() => r(K.bankAccounts), [K.bankAccounts]), Z = d(() => o(K.bankAccounts)?.id, [K.bankAccounts]), Q = l(async () => {
101
+ let e = M.current;
102
+ if (!_) return { ok: !0 };
103
+ if (!s(e)) return y && _ === v ? {
104
+ ok: !0,
105
+ counterpartBankAccountId: y
106
+ } : K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError ? { ok: !1 } : {
107
+ ok: !0,
108
+ counterpartBankAccountId: Z
109
+ };
110
+ if (K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError) return { ok: !1 };
111
+ let t = te(e);
112
+ if (Object.keys(t).length > 0) return L(t), k(!0), { ok: !1 };
113
+ L(void 0);
114
+ let r = c(K.bankAccounts, R ?? X?.id);
115
+ if (r.kind === "update") return await J.mutateAsync({
116
+ path: {
117
+ counterpart_id: _,
118
+ bank_account_id: r.bankAccountId
119
+ },
120
+ body: ee(e, { includeAchDefaults: r.includeAchDefaults })
121
+ }), z(r.bankAccountId), {
122
+ ok: !0,
123
+ counterpartBankAccountId: r.bankAccountId
124
+ };
125
+ let i = await q.mutateAsync({
126
+ path: { counterpart_id: _ },
127
+ body: n(e, { isDefaultForCurrency: r.isDefaultForCurrency })
128
+ });
129
+ return z(i?.id), {
130
+ ok: !0,
131
+ counterpartBankAccountId: i?.id
132
+ };
133
+ }, [
134
+ X,
91
135
  _,
92
- O,
93
- k,
94
- x
95
- ]);
136
+ q,
137
+ K.bankAccounts,
138
+ K.isBankAccountsError,
139
+ K.isBankAccountsFetching,
140
+ K.isBankAccountsLoading,
141
+ R,
142
+ Z,
143
+ y,
144
+ v,
145
+ J
146
+ ]), he = d(() => (G.data?.data ?? []).map((e) => ({
147
+ name: a(e),
148
+ email: i(e),
149
+ onSelect: () => U(e.id)
150
+ })), [G.data, U]), ge = d(() => se(x), [x]), $ = l(() => {
151
+ O(void 0), P(!1);
152
+ }, []), _e = l((e) => {
153
+ O(void 0), P(!1), U(e);
154
+ }, [U]);
155
+ if (D) return {
156
+ mode: "creating",
157
+ newVendorForm: /* @__PURE__ */ le(ce, {
158
+ mode: D,
159
+ counterpart: D === "edit" ? K.counterpart : void 0,
160
+ primaryAddress: D === "edit" ? K.primaryAddress : void 0,
161
+ bankAccounts: D === "edit" ? K.bankAccounts : void 0,
162
+ isBankAccountsLoading: D === "edit" ? K.isBankAccountsLoading : void 0,
163
+ isBankAccountsError: D === "edit" ? K.isBankAccountsError : void 0,
164
+ initialName: D === "create" ? C : void 0,
165
+ initialValues: D === "create" ? ge : void 0,
166
+ onSaved: _e,
167
+ onCancel: $,
168
+ onDirtyChange: P
169
+ }),
170
+ onClear: $,
171
+ hasUnsavedVendorChanges: F
172
+ };
173
+ if (Y) {
174
+ let e = K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError;
175
+ return {
176
+ mode: "resolved",
177
+ summary: Y,
178
+ onEdit: e ? void 0 : () => O("edit"),
179
+ onClear: () => U(void 0),
180
+ paymentInstructions: e ? void 0 : {
181
+ isOpen: pe,
182
+ values: A,
183
+ errors: I,
184
+ onOpen: () => {
185
+ k(!0), X && (j({
186
+ accountHolderName: X.account_holder_name ?? "",
187
+ routingNumber: X.routing_number ?? "",
188
+ accountNumber: X.account_number ?? ""
189
+ }), z(X.id));
190
+ },
191
+ onChange: (e) => {
192
+ j((t) => ({
193
+ ...t,
194
+ ...e
195
+ })), L(void 0);
196
+ }
197
+ },
198
+ savePaymentInstructions: Q,
199
+ hasUnsavedVendorChanges: F
200
+ };
201
+ }
96
202
  return {
97
- isOpen: y,
98
- values: x,
99
- errors: C,
100
- isSaving: D.isPending || O.isPending || k.isPending,
101
- open: M,
102
- close: N,
103
- onChange: P,
104
- save: F
203
+ mode: "selecting",
204
+ error: G.isError ? S.searchFailed : K.isError ? S.vendorDetailsFailed : de,
205
+ search: {
206
+ query: C,
207
+ onQueryChange: w,
208
+ isLoading: G.isLoading,
209
+ onAddVendor: () => O("create"),
210
+ results: he
211
+ },
212
+ savePaymentInstructions: Q,
213
+ hasUnsavedVendorChanges: F
105
214
  };
106
215
  }
107
216
  //#endregion
108
- export { h as usePaymentInstructionsForm };
217
+ export { g as useVendorSectionProps };
@@ -1,16 +1,108 @@
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 { useUpdatePayableMutation as t } from "../../data-access/dist/index12.js";
8
+ import "../../data-access/dist/index.js";
9
+ import { counterpartFormBankAccountToCreatePayload as n, counterpartFormBankAccountToUpdatePayload as r, getAchInstructions as i, resolveCounterpartBankAccountWrite as a, validateAchFormValues as o } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
10
+ import { useCounterpartBankAccountsQuery as s, useCreateCounterpartBankAccountMutation as c, useUpdateCounterpartBankAccountMutation as l } from "../../../shared/counterpart-management/data-access/dist/index5.js";
11
+ import "../../../shared/counterpart-management/feature/dist/index.js";
12
+ import { useCallback as u, useEffect as d, useRef as f, useState as p } from "react";
1
13
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js
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
- });
14
+ var m = {
15
+ accountHolderName: "",
16
+ routingNumber: "",
17
+ accountNumber: ""
18
+ };
19
+ function h({ payableId: h, counterpartId: g, saveErrorMessage: _, linkErrorMessage: v }) {
20
+ let [y, b] = p(!1), [x, S] = p(m), [C, w] = p(), T = s(g), E = T.data?.data, D = c(), O = l(), k = t(), A = f(void 0), j = f(!1);
21
+ d(() => {
22
+ A.current = void 0;
23
+ }, [g]);
24
+ let M = u(() => {
25
+ let e = T.isFetching ? void 0 : i(E);
26
+ S(e ? {
27
+ accountHolderName: e.account_holder_name ?? "",
28
+ routingNumber: e.routing_number ?? "",
29
+ accountNumber: e.account_number ?? ""
30
+ } : m), A.current = e?.id ?? A.current, j.current = !T.isFetching, w(void 0), b(!0);
31
+ }, [E, T.isFetching]);
32
+ d(() => {
33
+ if (!y || j.current || T.isFetching) return;
34
+ j.current = !0;
35
+ let e = i(E);
36
+ e && (S((t) => t.accountHolderName === "" && t.routingNumber === "" && t.accountNumber === "" ? {
37
+ accountHolderName: e.account_holder_name ?? "",
38
+ routingNumber: e.routing_number ?? "",
39
+ accountNumber: e.account_number ?? ""
40
+ } : t), A.current = e.id);
41
+ }, [
42
+ y,
43
+ T.isFetching,
44
+ E
45
+ ]);
46
+ let N = u(() => {
47
+ b(!1);
48
+ }, []), P = u((e) => {
49
+ S((t) => ({
50
+ ...t,
51
+ ...e
52
+ }));
53
+ }, []), F = u(async () => {
54
+ if (!h || !g) return !1;
55
+ let t = o(x);
56
+ if (Object.keys(t).length > 0) return w(t), !1;
57
+ if (w(void 0), T.isFetching || T.isError) return e.error(_), !1;
58
+ let s = A.current;
59
+ try {
60
+ let e = a(E, s ?? i(E)?.id);
61
+ e.kind === "update" ? (await O.mutateAsync({
62
+ path: {
63
+ counterpart_id: g,
64
+ bank_account_id: e.bankAccountId
65
+ },
66
+ body: r(x, { includeAchDefaults: e.includeAchDefaults })
67
+ }), s = e.bankAccountId) : s = (await D.mutateAsync({
68
+ path: { counterpart_id: g },
69
+ body: n(x, { isDefaultForCurrency: e.isDefaultForCurrency })
70
+ }))?.id, A.current = s;
71
+ } catch {
72
+ return e.error(_), !1;
73
+ }
74
+ try {
75
+ await k.mutateAsync({
76
+ path: { payable_id: h },
77
+ body: { counterpart_bank_account_id: s }
78
+ });
79
+ } catch {
80
+ return e.error(v), !1;
81
+ }
82
+ return b(!1), !0;
83
+ }, [
84
+ E,
85
+ T.isError,
86
+ T.isFetching,
87
+ g,
88
+ D,
89
+ v,
90
+ h,
91
+ _,
92
+ O,
93
+ k,
94
+ x
95
+ ]);
96
+ return {
97
+ isOpen: y,
98
+ values: x,
99
+ errors: C,
100
+ isSaving: D.isPending || O.isPending || k.isPending,
101
+ open: M,
102
+ close: N,
103
+ onChange: P,
104
+ save: F
105
+ };
14
106
  }
15
107
  //#endregion
16
- export { e as encodeFileToBase64 };
108
+ export { h as usePaymentInstructionsForm };
@@ -1,51 +1,16 @@
1
- import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
2
- import "../../data-access/dist/index.js";
3
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js
4
- var t = "USD";
5
- function n(n) {
6
- return e(n, t);
7
- }
8
- function r(e) {
9
- let t = e.trim();
10
- if (!t) return null;
11
- let n = Number(t);
12
- return Number.isFinite(n) && n > 0 ? n : null;
13
- }
14
- function i(e) {
15
- return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
16
- }
17
- function a(e) {
18
- return n(e) ?? 0;
19
- }
20
- function o(e) {
21
- let t = Number.parseFloat(e);
22
- return Number.isFinite(t) ? t : 0;
23
- }
24
- function s(e) {
25
- return (e / 100).toFixed(2);
26
- }
27
- function c({ values: e, counterpartId: r, clearCounterpart: i, counterpartBankAccountId: a, editedTotals: o, document: s }) {
28
- let c = { currency: t };
29
- return r ? c.counterpart_id = r : i && (c.counterpart_id = null), r ? c.counterpart_bank_account_id = a ?? null : i && (c.counterpart_bank_account_id = null), e.invoiceNumber && (c.document_id = e.invoiceNumber), e.invoiceDate && (c.issued_at = e.invoiceDate), e.dueDate && (c.due_date = e.dueDate), s && (c.base64_encoded_file = s.base64EncodedFile, c.file_name = s.fileName), o && (c.discount = n(o.discount) ?? 0, c.tax_amount = n(o.tax) ?? 0, o.total !== void 0 && (c.total_amount = n(o.total) ?? 0)), c;
30
- }
31
- function l(e) {
32
- return e.filter(i).map((e) => {
33
- let t = n(e.amount), i = r(e.quantity) ?? 1, a = n(e.price) ?? (t === null ? 0 : Math.round(t / i)), o = Math.round(i * a);
34
- return {
35
- name: e.description,
36
- quantity: i,
37
- unit_price: a,
38
- tax: 0,
39
- ...t !== null && t !== o ? { subtotal: t } : {},
40
- ...e.glCode ? { ledger_account_id: e.glCode } : {}
41
- };
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);
42
13
  });
43
14
  }
44
- function u(e, t) {
45
- return s(Math.round(o(e) * a(t)));
46
- }
47
- function d(e, t, n) {
48
- return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
49
- }
50
15
  //#endregion
51
- export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
16
+ export { e as encodeFileToBase64 };
@@ -1,35 +1,51 @@
1
- import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index40.js";
2
- import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index47.js";
1
+ import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
2
+ import "../../data-access/dist/index.js";
3
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js
4
- var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
5
- function a(e) {
4
+ var t = "USD";
5
+ function n(n) {
6
+ return e(n, t);
7
+ }
8
+ function r(e) {
6
9
  let t = e.trim();
7
- return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
8
- }
9
- function o(t, i = e) {
10
- let a = {};
11
- for (let e of t) {
12
- let t = n(e.price), o = n(e.amount), s = {};
13
- e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), r(e.quantity) === null && (e.quantity.trim() || t !== null || o !== null) && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
14
- }
15
- return Object.keys(a).length ? a : void 0;
16
- }
17
- function s(i, a, o, s = e) {
18
- let c = {};
19
- a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField), i.invoiceDate.trim() || (c.invoiceDate = s.requiredField), i.dueDate.trim() || (c.dueDate = s.requiredField);
20
- let l = {};
21
- return o.forEach((e, i) => {
22
- if (i > 0 && !t(e)) return;
23
- let a = {};
24
- e.description.trim() || (a.description = s.requiredField), r(e.quantity) === null && (a.quantity = s.requiredField), n(e.price) === null && n(e.amount) === null && (a.price = s.requiredField, a.amount = s.requiredField), Object.keys(a).length && (l[e.id] = a);
25
- }), {
26
- formErrors: Object.keys(c).length ? c : void 0,
27
- lineItemErrors: Object.keys(l).length ? l : void 0
28
- };
29
- }
30
- function c(t, r, i, o = e) {
31
- let s = {};
32
- return a(t) || (s.discount = o.unreadableDiscount), a(r) || (s.tax = o.unreadableTax), i !== void 0 && n(i) === null && (s.total = o.unreadableTotal), Object.keys(s).length ? s : void 0;
10
+ if (!t) return null;
11
+ let n = Number(t);
12
+ return Number.isFinite(n) && n > 0 ? n : null;
13
+ }
14
+ function i(e) {
15
+ return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
16
+ }
17
+ function a(e) {
18
+ return n(e) ?? 0;
19
+ }
20
+ function o(e) {
21
+ let t = Number.parseFloat(e);
22
+ return Number.isFinite(t) ? t : 0;
23
+ }
24
+ function s(e) {
25
+ return (e / 100).toFixed(2);
26
+ }
27
+ function c({ values: e, counterpartId: r, clearCounterpart: i, counterpartBankAccountId: a, editedTotals: o, document: s }) {
28
+ let c = { currency: t };
29
+ return r ? c.counterpart_id = r : i && (c.counterpart_id = null), r ? c.counterpart_bank_account_id = a ?? null : i && (c.counterpart_bank_account_id = null), e.invoiceNumber && (c.document_id = e.invoiceNumber), e.invoiceDate && (c.issued_at = e.invoiceDate), e.dueDate && (c.due_date = e.dueDate), s && (c.base64_encoded_file = s.base64EncodedFile, c.file_name = s.fileName), o && (c.discount = n(o.discount) ?? 0, c.tax_amount = n(o.tax) ?? 0, o.total !== void 0 && (c.total_amount = n(o.total) ?? 0)), c;
30
+ }
31
+ function l(e) {
32
+ return e.filter(i).map((e) => {
33
+ let t = n(e.amount), i = r(e.quantity) ?? 1, a = n(e.price) ?? (t === null ? 0 : Math.round(t / i)), o = Math.round(i * a);
34
+ return {
35
+ name: e.description,
36
+ quantity: i,
37
+ unit_price: a,
38
+ tax: 0,
39
+ ...t !== null && t !== o ? { subtotal: t } : {},
40
+ ...e.glCode ? { ledger_account_id: e.glCode } : {}
41
+ };
42
+ });
43
+ }
44
+ function u(e, t) {
45
+ return s(Math.round(o(e) * a(t)));
46
+ }
47
+ function d(e, t, n) {
48
+ return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
33
49
  }
34
50
  //#endregion
35
- export { a as isReadableMoneyOrZero, s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };
51
+ export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };