@tesouro/embedded-components-react 0.2.296 → 0.2.299

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/index.css +6 -0
  2. package/dist/index.d.ts +107 -87
  3. package/dist/lib/CounterpartsWidget.d.ts +24 -4
  4. package/dist/lib/ReceivablesWidget.d.ts +20 -3
  5. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/data-access/dist/index.js +3 -2
  6. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index4.js +2 -2
  7. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js +210 -199
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +31 -27
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +2 -0
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index4.js +122 -149
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +163 -72
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +3 -3
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +52 -46
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +8 -2
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +98 -67
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +6 -1
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +7 -3
  18. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index7.js +4 -1
  19. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index8.js +12 -7
  20. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index4.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +17 -16
  23. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/CounterpartSelector.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +103 -50
  25. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +2 -1
  26. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js +2 -0
  27. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +126 -76
  28. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index.js +12 -11
  29. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index10.js +6 -173
  30. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index11.js +173 -5
  31. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index12.js +5 -57
  32. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index13.js +51 -22
  33. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index14.js +24 -72
  34. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +76 -0
  35. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +13 -7
  36. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index5.js +53 -110
  37. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index6.js +115 -51
  38. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index7.js +53 -47
  39. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index8.js +44 -504
  40. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index9.js +480 -6
  41. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +21 -19
  42. package/dist/libs/tesouro-embedded-components-react/{accept-disclosures-widget/data-access/dist/index2.js → shared/data-access/dist/lib/disclosures/useAcceptWidgetDisclosures.js} +3 -4
  43. package/dist/libs/tesouro-embedded-components-react/{accept-disclosures-widget/data-access/dist/index3.js → shared/data-access/dist/lib/disclosures/useDisclosuresQuery.js} +4 -5
  44. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  45. package/package.json +1 -1
@@ -2,127 +2,139 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { Button as e, Input as t, Label as n } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { getStateOptions as r } from "../../../shared/util/dist/lib/usStates.js";
7
- import { VENDOR_INLINE_FORM_LABELS_EN as i } from "./index2.js";
8
- import { COUNTERPART_MESSAGE_LABELS_EN as a } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
9
- import { AddressFieldGroup as o } from "../../../shared/counterpart-management/ui/dist/index5.js";
10
- import { CounterpartFormFields as s } from "../../../shared/counterpart-management/ui/dist/index8.js";
11
- import "../../../shared/counterpart-management/ui/dist/index.js";
12
- import { useCounterpartForm as c } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
5
+ import { Button as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { getStateOptions as t } from "../../../shared/util/dist/lib/usStates.js";
7
+ import { VENDOR_INLINE_FORM_LABELS_EN as n } from "./index2.js";
8
+ import { AchFieldGroup as r } from "../../../shared/counterpart-management/ui/dist/index5.js";
9
+ import { CounterpartFormFields as i, useFocusFirstInvalidField as a } from "../../../shared/counterpart-management/ui/dist/index9.js";
10
+ import { COUNTERPART_MESSAGE_LABELS_EN as o } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
11
+ import { useCounterpartForm as s } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
13
12
  import "../../../shared/counterpart-management/feature/dist/index.js";
14
- import { useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
13
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
15
14
  import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
16
15
  import { Landmark as g, Plus as _, X as v } from "lucide-react";
17
16
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index4.js
18
- function y({ mode: y, counterpart: b, primaryAddress: x, initialName: S, onSaved: C, onCancel: w, labels: T }) {
19
- let E = {
20
- ...i,
21
- ...T
22
- }, [D, O] = f("none"), [k, A] = f(b?.id), [j, M] = f(!1), [N, P] = f(!1), F = u(() => r(), []), I = d(D), L = d(!1), R = c({
23
- view: D,
24
- setView: O,
25
- selectedId: k,
26
- setSelectedId: A,
27
- messages: a,
17
+ function y({ mode: y, counterpart: b, primaryAddress: x, bankAccounts: S, isBankAccountsLoading: C, isBankAccountsError: w, initialName: T, onSaved: E, onCancel: D, onDirtyChange: O, labels: k }) {
18
+ let A = {
19
+ ...n,
20
+ ...k
21
+ }, [j, M] = f("none"), [N, P] = f(b?.id), [F, I] = f(!1), [L, R] = f(!1);
22
+ l(() => {
23
+ O?.(L);
24
+ }, [L, O]);
25
+ let z = u(() => t(), []), B = d(j), V = d(!1), H = s({
26
+ view: j,
27
+ setView: M,
28
+ selectedId: N,
29
+ setSelectedId: P,
30
+ messages: o,
28
31
  counterpartType: "vendor",
29
32
  counterpart: b,
30
33
  primaryAddress: x,
31
- requireAddress: !1
32
- }), { openCreate: z, openEdit: B, setValues: V } = R;
33
- return l(() => {
34
- y === "edit" ? B() : z();
34
+ bankAccounts: S,
35
+ isBankAccountsLoading: C,
36
+ isBankAccountsError: w
37
+ }), { openCreate: U, openEdit: W, setValues: G } = H, K = a(H.errors);
38
+ l(() => {
39
+ y === "edit" ? W() : U();
35
40
  }, [
36
41
  y,
37
- z,
38
- B
42
+ U,
43
+ W
39
44
  ]), l(() => {
40
- I.current !== "none" && D === "none" && k && C(k), I.current = D;
45
+ B.current !== "none" && j === "none" && N && E(N), B.current = j;
41
46
  }, [
42
- D,
43
- k,
44
- C
47
+ j,
48
+ N,
49
+ E
45
50
  ]), l(() => {
46
- y !== "create" || L.current || (L.current = !0, V((e) => ({
51
+ y !== "create" || V.current || (V.current = !0, G((e) => ({
47
52
  ...e,
48
53
  entityType: "organization",
49
- legalName: S?.trim() || e.legalName
54
+ legalName: T?.trim() || e.legalName
50
55
  })));
51
56
  }, [
52
57
  y,
53
- S,
54
- V
58
+ T,
59
+ G
55
60
  ]), l(() => {
56
- y === "edit" && x && M(!0);
57
- }, [y, x]), /* @__PURE__ */ h("div", {
61
+ y === "edit" && (H.values.bankAccount.routingNumber || H.values.bankAccount.accountNumber) && I(!0);
62
+ }, [
63
+ y,
64
+ H.values.bankAccount.accountNumber,
65
+ H.values.bankAccount.routingNumber
66
+ ]), l(() => {
67
+ H.sectionsToExpand.bankAccount && I(!0);
68
+ }, [H.sectionsToExpand.bankAccount]);
69
+ let q = c((e) => {
70
+ R(!0), G((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
71
+ ...t,
72
+ ...e,
73
+ firstName: t.firstName || t.legalName,
74
+ legalName: t.legalName
75
+ } : e.entityType === "organization" && t.entityType !== "organization" ? {
76
+ ...t,
77
+ ...e,
78
+ legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
79
+ } : {
80
+ ...t,
81
+ ...e
82
+ });
83
+ }, [G]);
84
+ return /* @__PURE__ */ h("div", {
85
+ ref: K,
58
86
  className: "ttw:flex ttw:flex-col ttw:gap-4 ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4",
59
87
  children: [
60
88
  /* @__PURE__ */ h("div", {
61
89
  className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-2",
62
90
  children: [/* @__PURE__ */ m("p", {
63
91
  className: "ttw:text-base ttw:font-semibold ttw:text-foreground",
64
- children: y === "edit" ? E.editTitle : E.createTitle
92
+ children: y === "edit" ? A.editTitle : A.createTitle
65
93
  }), /* @__PURE__ */ m(e, {
66
94
  type: "button",
67
95
  variant: "ghost",
68
96
  size: "icon",
69
- "aria-label": E.close,
70
- onClick: w,
97
+ "aria-label": A.close,
98
+ onClick: D,
71
99
  children: /* @__PURE__ */ m(v, { className: "ttw:size-4" })
72
100
  })]
73
101
  }),
74
- /* @__PURE__ */ m(s, {
102
+ /* @__PURE__ */ m(i, {
75
103
  mode: y,
76
104
  counterpartMode: "vendor",
77
- values: R.values,
78
- errors: R.errors,
79
- stateOptions: F,
80
- onChange: (e) => V((t) => ({
81
- ...t,
82
- ...e
83
- })),
84
- onAddressChange: (e) => V((t) => ({
85
- ...t,
86
- address: {
87
- ...t.address,
88
- ...e
89
- }
90
- })),
105
+ values: H.values,
106
+ errors: H.errors,
107
+ stateOptions: z,
108
+ onChange: q,
109
+ onAddressChange: (e) => {
110
+ R(!0), G((t) => ({
111
+ ...t,
112
+ address: {
113
+ ...t.address,
114
+ ...e
115
+ }
116
+ }));
117
+ },
91
118
  sections: {
92
- entityType: !1,
119
+ entityType: !0,
93
120
  profileHeading: !1,
121
+ title: !1,
94
122
  taxId: !1,
95
- address: !1,
123
+ address: "collapsible",
96
124
  bankAccount: !1
97
125
  },
98
- labels: { businessNameLabel: E.nameLabel }
99
- }),
100
- j ? /* @__PURE__ */ m(o, {
101
- idPrefix: "vendor-inline-address",
102
- values: R.values.address,
103
- errors: R.errors?.address,
104
- stateOptions: F,
105
- onChange: (e) => V((t) => ({
106
- ...t,
107
- address: {
108
- ...t.address,
109
- ...e
110
- }
111
- }))
112
- }) : /* @__PURE__ */ h("button", {
113
- type: "button",
114
- onClick: () => M(!0),
115
- className: "ttw:flex ttw:w-fit ttw:items-center ttw:gap-1 ttw:text-sm ttw:font-medium ttw:text-primary ttw:hover:underline",
116
- children: [/* @__PURE__ */ m(_, { className: "ttw:size-4" }), E.addAddress]
126
+ sectionsToExpand: H.sectionsToExpand,
127
+ onAddressExpand: H.expandAddress,
128
+ labels: { businessNameLabel: A.nameLabel }
117
129
  }),
118
130
  /* @__PURE__ */ h("div", {
119
131
  className: "ttw:flex ttw:flex-col ttw:gap-1",
120
132
  children: [/* @__PURE__ */ m("p", {
121
133
  className: "ttw:text-sm ttw:font-semibold ttw:text-foreground",
122
- children: E.paymentMethodsHeading
134
+ children: A.paymentMethodsHeading
123
135
  }), /* @__PURE__ */ m("p", {
124
136
  className: "ttw:text-sm ttw:text-muted-foreground",
125
- children: E.paymentMethodsDescription
137
+ children: A.paymentMethodsDescription
126
138
  })]
127
139
  }),
128
140
  /* @__PURE__ */ h("div", {
@@ -139,77 +151,38 @@ function y({ mode: y, counterpart: b, primaryAddress: x, initialName: S, onSaved
139
151
  className: "ttw:flex ttw:flex-col ttw:gap-0.5",
140
152
  children: [/* @__PURE__ */ m("p", {
141
153
  className: "ttw:text-sm ttw:font-medium ttw:text-foreground",
142
- children: E.achTitle
154
+ children: A.achTitle
143
155
  }), /* @__PURE__ */ m("p", {
144
156
  className: "ttw:text-sm ttw:text-muted-foreground",
145
- children: E.achDescription
157
+ children: A.achDescription
146
158
  })]
147
- }), N ? /* @__PURE__ */ h(p, { children: [
148
- /* @__PURE__ */ h("div", {
149
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
150
- children: [/* @__PURE__ */ m(n, {
151
- htmlFor: "vendor-inline-account-holder",
152
- children: E.accountHolderNameLabel
153
- }), /* @__PURE__ */ m(t, {
154
- id: "vendor-inline-account-holder",
155
- value: R.values.bankAccount.accountHolderName,
156
- "aria-invalid": !!R.errors?.bankAccount?.accountHolderName,
157
- onChange: (e) => V((t) => ({
158
- ...t,
159
- bankAccount: {
160
- ...t.bankAccount,
161
- accountHolderName: e.target.value
162
- }
163
- }))
164
- })]
165
- }),
166
- /* @__PURE__ */ h("div", {
167
- className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
168
- children: [/* @__PURE__ */ h("div", {
169
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
170
- children: [/* @__PURE__ */ m(n, {
171
- htmlFor: "vendor-inline-routing",
172
- children: E.routingNumberLabel
173
- }), /* @__PURE__ */ m(t, {
174
- id: "vendor-inline-routing",
175
- value: R.values.bankAccount.routingNumber,
176
- "aria-invalid": !!R.errors?.bankAccount?.routingNumber,
177
- onChange: (e) => V((t) => ({
178
- ...t,
179
- bankAccount: {
180
- ...t.bankAccount,
181
- routingNumber: e.target.value
182
- }
183
- }))
184
- })]
185
- }), /* @__PURE__ */ h("div", {
186
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
187
- children: [/* @__PURE__ */ m(n, {
188
- htmlFor: "vendor-inline-account-number",
189
- children: E.accountNumberLabel
190
- }), /* @__PURE__ */ m(t, {
191
- id: "vendor-inline-account-number",
192
- value: R.values.bankAccount.accountNumber,
193
- "aria-invalid": !!R.errors?.bankAccount?.accountNumber,
194
- onChange: (e) => V((t) => ({
195
- ...t,
196
- bankAccount: {
197
- ...t.bankAccount,
198
- accountNumber: e.target.value
199
- }
200
- }))
201
- })]
202
- })]
203
- }),
204
- /* @__PURE__ */ m("p", {
205
- className: "ttw:text-sm ttw:text-muted-foreground",
206
- children: E.achHelp
207
- })
208
- ] }) : /* @__PURE__ */ h("button", {
159
+ }), F ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(r, {
160
+ idPrefix: "vendor-inline-ach",
161
+ values: H.values.bankAccount,
162
+ errors: H.errors?.bankAccount,
163
+ onChange: (e) => {
164
+ R(!0), G((t) => ({
165
+ ...t,
166
+ bankAccount: {
167
+ ...t.bankAccount,
168
+ ...e
169
+ }
170
+ }));
171
+ },
172
+ labels: {
173
+ accountHolderName: A.accountHolderNameLabel,
174
+ routingNumber: A.routingNumberLabel,
175
+ accountNumber: A.accountNumberLabel
176
+ }
177
+ }), /* @__PURE__ */ m("p", {
178
+ className: "ttw:text-sm ttw:text-muted-foreground",
179
+ children: A.achHelp
180
+ })] }) : /* @__PURE__ */ h(e, {
209
181
  type: "button",
210
- onClick: () => P(!0),
211
- className: "ttw:flex ttw:w-fit ttw:items-center ttw:gap-1 ttw:text-sm ttw:font-medium ttw:text-primary ttw:hover:underline",
212
- children: [/* @__PURE__ */ m(_, { className: "ttw:size-4" }), E.addBankAccount]
182
+ variant: "link",
183
+ className: "ttw:w-fit ttw:px-0",
184
+ onClick: () => I(!0),
185
+ children: [/* @__PURE__ */ m(_, { className: "ttw:size-4" }), A.addBankAccount]
213
186
  })]
214
187
  })]
215
188
  }),
@@ -218,14 +191,14 @@ function y({ mode: y, counterpart: b, primaryAddress: x, initialName: S, onSaved
218
191
  children: [/* @__PURE__ */ m(e, {
219
192
  type: "button",
220
193
  variant: "outline",
221
- onClick: w,
222
- children: E.cancel
194
+ onClick: D,
195
+ children: A.cancel
223
196
  }), /* @__PURE__ */ m(e, {
224
197
  type: "button",
225
- onClick: R.submit,
226
- loading: R.isSubmitting,
227
- disabled: R.isSubmitDisabled,
228
- children: E.save
198
+ onClick: H.submit,
199
+ loading: H.isSubmitting,
200
+ disabled: H.isSubmitting,
201
+ children: A.save
229
202
  })]
230
203
  })
231
204
  ]
@@ -5,105 +5,196 @@
5
5
  import { VENDOR_SECTION_PROPS_LABELS_EN as e } from "./index2.js";
6
6
  import { usePayableSuggestionsQuery as t } from "../../data-access/dist/index11.js";
7
7
  import "../../data-access/dist/index.js";
8
- import { getCounterpartEmail as n, getCounterpartName as r } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
9
- import { useCounterpartsQuery as i } from "../../../shared/counterpart-management/data-access/dist/index3.js";
10
- import { useCounterpartDetails as a } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
8
+ import { counterpartFormBankAccountToCreatePayload as ee, counterpartFormBankAccountToUpdatePayload as te, getAchInstructions as n, getCounterpartEmail as r, getCounterpartName as i, getPayableAchInstructions as ne, hasAchFormValues as a, resolveCounterpartBankAccountWrite as re, validateAchFormValues as ie } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
9
+ import { useCounterpartsQuery as ae } from "../../../shared/counterpart-management/data-access/dist/index3.js";
10
+ import { useCreateCounterpartBankAccountMutation as oe, useUpdateCounterpartBankAccountMutation as o } from "../../../shared/counterpart-management/data-access/dist/index5.js";
11
+ import { useCounterpartDetails as s } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
11
12
  import "../../../shared/counterpart-management/feature/dist/index.js";
12
- import { VendorInlineForm as o } from "./index4.js";
13
- import { useCallback as s, useEffect as c, useMemo as l, useState as u } from "react";
14
- import { jsx as d } from "react/jsx-runtime";
13
+ import { VendorInlineForm as se } from "./index4.js";
14
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
15
+ import { jsx as p } from "react/jsx-runtime";
15
16
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js
16
- var f = 10, p = 300;
17
- function m({ payableId: m, counterpartId: h, payableCounterpartId: g, onCounterpartChange: _, requiredError: v, labels: y }) {
18
- let b = {
17
+ var m = 10, ce = 300, h = {
18
+ accountHolderName: "",
19
+ routingNumber: "",
20
+ accountNumber: ""
21
+ };
22
+ function le(e) {
23
+ return `••••••••${e.slice(-4)}`;
24
+ }
25
+ function g({ payableId: g, counterpartId: _, payableCounterpartId: v, onCounterpartChange: y, requiredError: b, labels: x }) {
26
+ let S = {
19
27
  ...e,
20
- ...y
21
- }, [x, S] = u(""), [C, w] = u(""), [T, E] = u(), [D, O] = u(!1), k = s((e) => {
22
- O(!0), _(e);
23
- }, [_]), A = t(m, { enabled: !!m && !h && !g }).data?.suggested_counterpart?.id;
24
- c(() => {
25
- !D && !h && !g && A && k(A);
28
+ ...x
29
+ }, [C, w] = f(""), [T, E] = f(""), [D, O] = f(), [ue, k] = f(!1), [A, j] = f(h), M = d(A);
30
+ M.current = A;
31
+ let [N, P] = f(!1), F = a(A) || N, [I, L] = f(), [R, z] = f(), B = d(_), [V, H] = f(!1), U = c(() => {
32
+ k(!1), j(h), L(void 0), z(void 0);
33
+ }, []), W = c((e) => {
34
+ H(!0), y(e);
35
+ }, [y]), G = t(g, { enabled: !!g && !_ && !v }).data?.suggested_counterpart?.id;
36
+ l(() => {
37
+ !V && !_ && !v && G && W(G);
26
38
  }, [
27
- h,
28
- g,
29
- D,
30
- A,
31
- k
32
- ]), c(() => {
39
+ _,
40
+ v,
41
+ V,
42
+ G,
43
+ W
44
+ ]), l(() => {
45
+ B.current !== _ && (B.current = _, U());
46
+ }, [_, U]), l(() => {
33
47
  let e = setTimeout(() => {
34
- w(x.trim());
35
- }, p);
48
+ E(C.trim());
49
+ }, ce);
36
50
  return () => clearTimeout(e);
37
- }, [x]);
38
- let j = i({
51
+ }, [C]);
52
+ let K = ae({
39
53
  sort: "counterpart_name",
40
54
  order: "asc",
41
- limit: f,
42
- counterpart_name__icontains: C || void 0,
55
+ limit: m,
56
+ counterpart_name__icontains: T || void 0,
43
57
  is_vendor: !0,
44
- enabled: !!C
45
- }), M = a({ selectedId: h }), N = l(() => {
46
- let e = M.counterpart;
58
+ enabled: !!T
59
+ }), q = s({ selectedId: _ }), J = oe(), Y = o(), X = u(() => {
60
+ let e = q.counterpart;
47
61
  if (!e) return;
48
- let t = M.bankAccounts?.find((e) => e.is_default_for_currency);
62
+ if (q.isBankAccountsLoading) return {
63
+ name: i(e),
64
+ email: r(e),
65
+ methodLabel: S.paymentMethodLoading,
66
+ fields: []
67
+ };
68
+ if (q.isBankAccountsError) return {
69
+ name: i(e),
70
+ email: r(e),
71
+ methodLabel: S.paymentMethodUnavailable,
72
+ fields: []
73
+ };
74
+ let t = ne(q.bankAccounts);
49
75
  return {
50
- name: r(e),
51
- email: n(e),
52
- methodLabel: t ? b.achMethod : b.noMethod,
76
+ name: i(e),
77
+ email: r(e),
78
+ methodLabel: t ? S.achMethod : S.noMethod,
53
79
  fields: t ? [
54
80
  {
55
- label: b.accountHolder,
81
+ label: S.accountHolder,
56
82
  value: t.account_holder_name ?? ""
57
83
  },
58
84
  {
59
- label: b.routingNumber,
85
+ label: S.routingNumber,
60
86
  value: t.routing_number ?? ""
61
87
  },
62
88
  {
63
- label: b.accountNumber,
64
- value: "",
65
- maskedValue: t.account_number ?? ""
89
+ label: S.accountNumber,
90
+ value: t.account_number ?? "",
91
+ maskedValue: t.account_number ? le(t.account_number) : ""
66
92
  }
67
93
  ] : []
68
94
  };
69
95
  }, [
70
- M.bankAccounts,
71
- M.counterpart,
72
- b
73
- ]), P = l(() => (j.data?.data ?? []).map((e) => ({
74
- name: r(e),
75
- email: n(e),
76
- onSelect: () => k(e.id)
77
- })), [j.data, k]), F = s(() => E(void 0), []), I = s((e) => {
78
- E(void 0), k(e);
79
- }, [k]);
80
- return T ? {
96
+ q.bankAccounts,
97
+ q.counterpart,
98
+ q.isBankAccountsError,
99
+ q.isBankAccountsLoading,
100
+ S
101
+ ]), Z = u(() => n(q.bankAccounts), [q.bankAccounts]), Q = c(async () => {
102
+ let e = M.current;
103
+ if (!_ || !a(e)) return !0;
104
+ if (q.isBankAccountsLoading || q.isBankAccountsError) return !1;
105
+ let t = ie(e);
106
+ if (Object.keys(t).length > 0) return L(t), k(!0), !1;
107
+ L(void 0);
108
+ let n = re(q.bankAccounts, R ?? Z?.id);
109
+ if (n.kind === "update") return await Y.mutateAsync({
110
+ path: {
111
+ counterpart_id: _,
112
+ bank_account_id: n.bankAccountId
113
+ },
114
+ body: te(e, { includeAchDefaults: n.includeAchDefaults })
115
+ }), z(n.bankAccountId), !0;
116
+ let r = await J.mutateAsync({
117
+ path: { counterpart_id: _ },
118
+ body: ee(e)
119
+ });
120
+ return z(r?.id), !0;
121
+ }, [
122
+ Z,
123
+ _,
124
+ J,
125
+ q.bankAccounts,
126
+ q.isBankAccountsError,
127
+ q.isBankAccountsLoading,
128
+ R,
129
+ Y
130
+ ]), de = u(() => (K.data?.data ?? []).map((e) => ({
131
+ name: i(e),
132
+ email: r(e),
133
+ onSelect: () => W(e.id)
134
+ })), [K.data, W]), $ = c(() => {
135
+ O(void 0), P(!1);
136
+ }, []), fe = c((e) => {
137
+ O(void 0), P(!1), W(e);
138
+ }, [W]);
139
+ if (D) return {
81
140
  mode: "creating",
82
- newVendorForm: /* @__PURE__ */ d(o, {
83
- mode: T,
84
- counterpart: T === "edit" ? M.counterpart : void 0,
85
- primaryAddress: T === "edit" ? M.primaryAddress : void 0,
86
- initialName: T === "create" ? x : void 0,
87
- onSaved: I,
88
- onCancel: F
141
+ newVendorForm: /* @__PURE__ */ p(se, {
142
+ mode: D,
143
+ counterpart: D === "edit" ? q.counterpart : void 0,
144
+ primaryAddress: D === "edit" ? q.primaryAddress : void 0,
145
+ bankAccounts: D === "edit" ? q.bankAccounts : void 0,
146
+ isBankAccountsLoading: D === "edit" ? q.isBankAccountsLoading : void 0,
147
+ isBankAccountsError: D === "edit" ? q.isBankAccountsError : void 0,
148
+ initialName: D === "create" ? C : void 0,
149
+ onSaved: fe,
150
+ onCancel: $,
151
+ onDirtyChange: P
89
152
  }),
90
- onClear: F
91
- } : N ? {
92
- mode: "resolved",
93
- summary: N,
94
- onEdit: () => E("edit"),
95
- onClear: () => k(void 0)
96
- } : {
153
+ onClear: $,
154
+ hasUnsavedVendorChanges: F
155
+ };
156
+ if (X) {
157
+ let e = q.isBankAccountsLoading || q.isBankAccountsError;
158
+ return {
159
+ mode: "resolved",
160
+ summary: X,
161
+ onEdit: e ? void 0 : () => O("edit"),
162
+ onClear: () => W(void 0),
163
+ paymentInstructions: e ? void 0 : {
164
+ isOpen: ue,
165
+ values: A,
166
+ errors: I,
167
+ onOpen: () => {
168
+ k(!0), Z && (j({
169
+ accountHolderName: Z.account_holder_name ?? "",
170
+ routingNumber: Z.routing_number ?? "",
171
+ accountNumber: Z.account_number ?? ""
172
+ }), z(Z.id));
173
+ },
174
+ onChange: (e) => {
175
+ j((t) => ({
176
+ ...t,
177
+ ...e
178
+ })), L(void 0);
179
+ }
180
+ },
181
+ savePaymentInstructions: Q,
182
+ hasUnsavedVendorChanges: F
183
+ };
184
+ }
185
+ return {
97
186
  mode: "selecting",
98
- error: j.isError ? b.searchFailed : M.isError ? b.vendorDetailsFailed : v,
187
+ error: K.isError ? S.searchFailed : q.isError ? S.vendorDetailsFailed : b,
99
188
  search: {
100
- query: x,
101
- onQueryChange: S,
102
- isLoading: j.isLoading,
103
- onAddVendor: () => E("create"),
104
- results: P
105
- }
189
+ query: C,
190
+ onQueryChange: w,
191
+ isLoading: K.isLoading,
192
+ onAddVendor: () => O("create"),
193
+ results: de
194
+ },
195
+ savePaymentInstructions: Q,
196
+ hasUnsavedVendorChanges: F
106
197
  };
107
198
  }
108
199
  //#endregion
109
- export { m as useVendorSectionProps };
200
+ export { g as useVendorSectionProps };
@@ -24,9 +24,9 @@ function o(e) {
24
24
  function s(e) {
25
25
  return (e / 100).toFixed(2);
26
26
  }
27
- function c({ values: e, counterpartId: r, editedTotals: i }) {
28
- let a = { currency: t };
29
- return r && (a.counterpart_id = r), e.invoiceNumber && (a.document_id = e.invoiceNumber), e.invoiceDate && (a.issued_at = e.invoiceDate), e.dueDate && (a.due_date = e.dueDate), i && (a.discount = n(i.discount) ?? 0, a.tax_amount = n(i.tax) ?? 0, i.total !== void 0 && (a.total_amount = n(i.total) ?? 0)), a;
27
+ function c({ values: e, counterpartId: r, clearCounterpart: i, editedTotals: a }) {
28
+ let o = { currency: t };
29
+ return r ? o.counterpart_id = r : i && (o.counterpart_id = null), e.invoiceNumber && (o.document_id = e.invoiceNumber), e.invoiceDate && (o.issued_at = e.invoiceDate), e.dueDate && (o.due_date = e.dueDate), a && (o.discount = n(a.discount) ?? 0, o.tax_amount = n(a.tax) ?? 0, a.total !== void 0 && (o.total_amount = n(a.total) ?? 0)), o;
30
30
  }
31
31
  function l(e) {
32
32
  return e.filter(i).map((e) => {