@tesouro/embedded-components-react 0.5.231 → 0.5.233

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 (78) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +4 -0
  3. package/dist/index.d.ts +105 -2
  4. package/dist/index.js +1 -1
  5. package/dist/lib/ReceivablesWidget.d.ts +105 -2
  6. package/dist/lib/ReceivablesWidget.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +92 -55
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +67 -142
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +186 -17
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +27 -0
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +45 -74
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +68 -53
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +66 -32
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +28 -34
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +24 -166
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +177 -1
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +42 -95
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +36 -33
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +38 -0
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +206 -147
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +2 -2
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +39 -58
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +53 -227
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +216 -287
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +453 -43
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +103 -126
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +122 -146
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +145 -41
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +39 -115
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +113 -90
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +81 -98
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +111 -27
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +26 -633
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +639 -39
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +41 -40
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +35 -74
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +73 -130
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +133 -329
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index36.js +345 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +13 -12
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +15 -12
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +35 -24
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +8 -71
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +70 -17
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +31 -12
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +18 -30
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +12 -301
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +33 -1
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +14 -46
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +23 -67
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +76 -485
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +395 -95
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +2 -0
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +48 -2
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +72 -4
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +496 -1
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +97 -91
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +2 -236
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -2
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +1 -249
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +89 -82
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +23 -54
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +223 -340
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +3 -0
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +249 -0
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +93 -0
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +59 -0
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +353 -0
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +18 -1
  73. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +41 -41
  74. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/clientRegistry.js +6 -3
  75. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +75 -43
  76. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  77. package/package.json +1 -1
  78. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +0 -28
@@ -2,50 +2,154 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { usePaymentTermsQuery as e } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
6
- import { buildCustomDateCalendar as t, buildPaymentTermsView as n, closeCustomDatePickerFields as r, resolveIssueDate as i, selectPaymentTermsFields as a, toCustomDateValue as o } from "./index10.js";
5
+ import { toFileArray as e, validateAttachmentFile as t } from "./index7.js";
6
+ import { useDeleteReceivableAttachmentMutation as n, useUploadReceivableAttachmentMutation as r } from "../../data-access/dist/index5.js";
7
7
  import "../../data-access/dist/index.js";
8
- import { useCallback as s, useMemo as c, useState as l } from "react";
8
+ import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
9
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js
10
- function u({ paymentTermsId: u, paymentTermsCustomDate: d, issueDate: f, isRecurring: p, messages: m, onChange: h }) {
11
- let g = e(), [_, v] = l(!1);
12
- return {
13
- view: c(() => n({
14
- terms: g.data?.data,
15
- isLoading: g.isLoading,
16
- fields: {
17
- paymentTermsId: u,
18
- paymentTermsCustomDate: d
19
- },
20
- customDatePickerOpen: _,
21
- isRecurring: p,
22
- messages: m,
23
- issueDate: i(f)
24
- }), [
25
- _,
26
- p,
27
- f,
28
- m,
29
- d,
30
- u,
31
- g.data?.data,
32
- g.isLoading
33
- ]),
34
- calendar: c(() => t(d), [d]),
35
- select: s((e) => {
36
- h((t) => a(t, e)), v(!1);
37
- }, [h]),
38
- changeCustomDatePickerOpen: s((e) => {
39
- v(e), e || h(r);
40
- }, [h]),
41
- selectCustomDate: s((e) => {
42
- h((t) => r({
10
+ function c({ attachments: c, setAttachments: l, receivableId: u }) {
11
+ let { mutateAsync: d } = r(), { mutate: f } = n(), [p, m] = s([]), [h, g] = s(!1), _ = o(0), v = o(/* @__PURE__ */ new Set()), y = o(/* @__PURE__ */ new Set()), b = o(/* @__PURE__ */ new Set()), x = o(0), S = o(!1), C = o({
12
+ deleteFile: f,
13
+ receivableId: u
14
+ });
15
+ a(() => {
16
+ C.current = {
17
+ deleteFile: f,
18
+ receivableId: u
19
+ };
20
+ }, [f, u]), a(() => {
21
+ S.current = !1;
22
+ let e = y.current;
23
+ return () => {
24
+ S.current = !0;
25
+ let { deleteFile: t, receivableId: n } = C.current;
26
+ for (let r of e) t({
27
+ path: { file_id: r },
28
+ receivableId: n
29
+ });
30
+ e.clear();
31
+ };
32
+ }, []);
33
+ let w = i(async (e, t) => {
34
+ let n = x.current, r = () => S.current || x.current !== n;
35
+ try {
36
+ let n = await d({
37
+ file: t,
38
+ receivableId: u
39
+ });
40
+ if (r() || v.current.delete(e)) {
41
+ f({
42
+ path: { file_id: n.id },
43
+ receivableId: u
44
+ });
45
+ return;
46
+ }
47
+ y.current.add(n.id), m((t) => t.filter((t) => t.id !== e)), l((e) => [...e, {
48
+ id: n.id,
49
+ includeInEmail: !0,
50
+ name: n.name,
51
+ size: n.size
52
+ }]);
53
+ } catch {
54
+ let t = v.current.delete(e);
55
+ if (r() || t) return;
56
+ m((t) => t.map((t) => t.id === e ? {
43
57
  ...t,
44
- paymentTermsCustomDate: o(e)
45
- })), v(!1);
46
- }, [h]),
47
- reset: s(() => v(!1), [])
58
+ status: "upload_failed"
59
+ } : t));
60
+ }
61
+ }, [
62
+ f,
63
+ u,
64
+ l,
65
+ d
66
+ ]), T = i((n) => {
67
+ let r = e(n);
68
+ if (r.length === 0) return;
69
+ let i = p.filter((e) => e.status === "uploading").length, a = 10 - c.length - i, o = [], s = !1;
70
+ for (let e of r) {
71
+ _.current += 1;
72
+ let n = `pending-attachment-${_.current}`, r = t(e);
73
+ if (r) {
74
+ o.push({
75
+ id: n,
76
+ name: e.name,
77
+ status: r
78
+ });
79
+ continue;
80
+ }
81
+ if (a <= 0) {
82
+ s = !0;
83
+ continue;
84
+ }
85
+ --a, o.push({
86
+ id: n,
87
+ name: e.name,
88
+ status: "uploading"
89
+ }), w(n, e);
90
+ }
91
+ o.length > 0 && m((e) => [...e, ...o]), g(s);
92
+ }, [
93
+ c.length,
94
+ p,
95
+ w
96
+ ]), E = i((e, t) => {
97
+ l((n) => n.map((n) => n.id === e ? {
98
+ ...n,
99
+ includeInEmail: t
100
+ } : n));
101
+ }, [l]), D = i((e) => {
102
+ g(!1);
103
+ let t = p.find((t) => t.id === e);
104
+ if (t) {
105
+ t.status === "uploading" && v.current.add(e), m((t) => t.filter((t) => t.id !== e));
106
+ return;
107
+ }
108
+ if (l((t) => t.filter((t) => t.id !== e)), !y.current.delete(e)) {
109
+ b.current.add(e);
110
+ return;
111
+ }
112
+ f({
113
+ path: { file_id: e },
114
+ receivableId: u
115
+ });
116
+ }, [
117
+ f,
118
+ p,
119
+ u,
120
+ l
121
+ ]), O = i(() => {
122
+ x.current += 1, v.current.clear(), y.current.clear(), b.current.clear(), m([]), g(!1);
123
+ }, []), k = i(() => {
124
+ let e = new Set(y.current);
125
+ for (let t of e) f({
126
+ path: { file_id: t },
127
+ receivableId: u
128
+ });
129
+ l((t) => t.filter(({ id: t }) => !e.has(t))), O();
130
+ }, [
131
+ f,
132
+ u,
133
+ O,
134
+ l
135
+ ]), A = i(() => {
136
+ for (let e of b.current) f({
137
+ path: { file_id: e },
138
+ receivableId: u
139
+ });
140
+ b.current.clear();
141
+ }, [f, u]);
142
+ return {
143
+ pendingUploads: p,
144
+ isUploading: p.some((e) => e.status === "uploading"),
145
+ isCountLimitReached: h,
146
+ selectFiles: T,
147
+ setIncludeInEmail: E,
148
+ remove: D,
149
+ reset: O,
150
+ discardUploads: k,
151
+ commitRemovals: A
48
152
  };
49
153
  }
50
154
  //#endregion
51
- export { u as useReceivablePaymentTerms };
155
+ export { c as useReceivableAttachmentUploads };
@@ -2,126 +2,50 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { getCounterpartEmail as e } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
6
- import { useCounterpartQuery as t } from "../../../shared/counterpart-management/data-access/dist/index3.js";
7
- import "../../../shared/counterpart-management/feature/dist/index.js";
8
- import { applyRecurrenceEmailDraft as n, buildRecurrenceEmailView as r, buildRecurrenceView as i, clearRecurrenceRecipients as a, createRecurrenceEmailDraft as o, selectRecurrenceDate as s, selectRecurrenceDayOfWeek as c, selectRecurrenceEndMode as l, selectRecurrenceFrequency as u, selectRecurrenceIssueMode as d, shouldOpenRecurrenceEmail as f } from "./index9.js";
9
- import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
5
+ import { usePaymentTermsQuery as e } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
6
+ import { buildCustomDateCalendar as t, buildPaymentTermsView as n, closeCustomDatePickerFields as r, resolveIssueDate as i, selectPaymentTermsFields as a, toCustomDateValue as o } from "./index10.js";
7
+ import "../../data-access/dist/index.js";
8
+ import { useCallback as s, useMemo as c, useState as l } from "react";
10
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js
11
- var v = [
12
- "recurrenceStartDate",
13
- "recurrenceEndDate",
14
- "recurrenceIssueMode",
15
- "recurrenceDayOfWeek",
16
- "recurrenceEndMode",
17
- "recurrenceMaxOccurrences"
18
- ], y = [
19
- "recurrenceSubject",
20
- "recurrenceBody",
21
- "recurrenceRecipientsTo",
22
- "recurrenceRecipientsCc",
23
- "recurrenceRecipientsBcc"
24
- ];
25
- function b({ values: b, errors: x, lockSchedule: S, messages: C, onChange: w, onClearErrors: T, onRevalidateErrors: E }) {
26
- let D = t(b.customerId || void 0), O = D.data ? e(D.data).trim() : "", [k, A] = _(!1), [j, M] = _(b), [N, P] = _(null), F = h(() => N ?? o(j, O), [
27
- O,
28
- N,
29
- j
30
- ]), I = g(O);
31
- m(() => {
32
- let e = I.current;
33
- I.current = O, e && e !== O && w(a);
34
- }, [O, w]);
35
- let L = p((e) => {
36
- M(e), P(null), A(!0);
37
- }, []);
10
+ function u({ paymentTermsId: u, paymentTermsCustomDate: d, issueDate: f, isRecurring: p, messages: m, onChange: h }) {
11
+ let g = e(), [_, v] = l(!1);
38
12
  return {
39
- view: h(() => i({
40
- fields: b,
41
- errors: x,
42
- lockSchedule: S,
43
- messages: C
13
+ view: c(() => n({
14
+ terms: g.data?.data,
15
+ isLoading: g.isLoading,
16
+ fields: {
17
+ paymentTermsId: u,
18
+ paymentTermsCustomDate: d
19
+ },
20
+ customDatePickerOpen: _,
21
+ isRecurring: p,
22
+ messages: m,
23
+ issueDate: i(f)
44
24
  }), [
45
- x,
46
- S,
47
- C,
48
- b
25
+ _,
26
+ p,
27
+ f,
28
+ m,
29
+ d,
30
+ u,
31
+ g.data?.data,
32
+ g.isLoading
49
33
  ]),
50
- emailView: h(() => r({
51
- open: k,
52
- ready: !D.isLoading,
53
- draft: F,
54
- messages: C
55
- }), [
56
- D.isLoading,
57
- F,
58
- k,
59
- C
60
- ]),
61
- changeFrequency: p((e) => {
62
- T(v), w((t) => u(t, e));
63
- }, [w, T]),
64
- changeMonthDay: p((e) => {
65
- E(["recurrenceIssueMode"]), w((t) => d(t, e, { lockSchedule: S }));
66
- }, [
67
- S,
68
- w,
69
- E
70
- ]),
71
- changeWeekday: p((e) => {
72
- S || (T(["recurrenceStartDate"]), E(["recurrenceDayOfWeek"]), w((t) => c(t, e, { lockSchedule: S })));
73
- }, [
74
- S,
75
- w,
76
- T,
77
- E
78
- ]),
79
- changeStartDate: p((e) => {
80
- E(["recurrenceStartDate"]), w((t) => s(t, "recurrenceStartDate", e));
81
- }, [w, E]),
82
- changeEndDate: p((e) => {
83
- E(["recurrenceEndDate"]), w((t) => s(t, "recurrenceEndDate", e));
84
- }, [w, E]),
85
- changeEndMode: p((e) => {
86
- E(["recurrenceEndMode"]), w((t) => l(t, e));
87
- }, [w, E]),
88
- changeMaxOccurrences: p((e) => {
89
- E(["recurrenceMaxOccurrences"]), w((t) => ({
34
+ calendar: c(() => t(d), [d]),
35
+ select: s((e) => {
36
+ h((t) => a(t, e)), v(!1);
37
+ }, [h]),
38
+ changeCustomDatePickerOpen: s((e) => {
39
+ v(e), e || h(r);
40
+ }, [h]),
41
+ selectCustomDate: s((e) => {
42
+ h((t) => r({
90
43
  ...t,
91
- recurrenceMaxOccurrences: e
92
- }));
93
- }, [w, E]),
94
- changeCreationMode: p((e) => {
95
- let t = {
96
- ...b,
97
- recurrenceAutomationLevel: e
98
- };
99
- w((t) => ({
100
- ...t,
101
- recurrenceAutomationLevel: e
102
- })), f(t, e) && L(t);
103
- }, [
104
- w,
105
- L,
106
- b
107
- ]),
108
- setUpEmail: p(() => L(b), [L, b]),
109
- changeEmailOpen: A,
110
- changeEmail: p((e, t) => P((n) => ({
111
- ...n ?? F,
112
- [e]: t
113
- })), [F]),
114
- saveEmail: p(() => {
115
- w((e) => n(e, F)), T(y), A(!1);
116
- }, [
117
- F,
118
- w,
119
- T
120
- ]),
121
- reset: p(() => {
122
- A(!1), I.current = "";
123
- }, [])
44
+ paymentTermsCustomDate: o(e)
45
+ })), v(!1);
46
+ }, [h]),
47
+ reset: s(() => v(!1), [])
124
48
  };
125
49
  }
126
50
  //#endregion
127
- export { b as useReceivableRecurrence };
51
+ export { u as useReceivablePaymentTerms };
@@ -2,103 +2,126 @@
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 { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
7
- import "../../../shared/ui/dist/index.js";
8
- import { useWidgetConfig as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
- import "../../../shared/feature/dist/index.js";
10
- import { useCreateEntityBankAccountMutation as r, usePaymentAccountsQuery as i } from "../../data-access/dist/index3.js";
11
- import "../../data-access/dist/index.js";
12
- import { EMPTY_BANK_ACCOUNT_FORM_VALUES as a, bankAccountFormToPayload as o, buildBankAccountSectionView as s, buildPaymentAccountOptions as c, getBankAccountPermissions as l, validateBankAccountForm as u } from "./index19.js";
13
- import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
5
+ import { getCounterpartEmail as e } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
6
+ import { useCounterpartQuery as t } from "../../../shared/counterpart-management/data-access/dist/index3.js";
7
+ import "../../../shared/counterpart-management/feature/dist/index.js";
8
+ import { applyRecurrenceEmailDraft as n, buildRecurrenceEmailView as r, buildRecurrenceView as i, clearRecurrenceRecipients as a, createRecurrenceEmailDraft as o, selectRecurrenceDate as s, selectRecurrenceDayOfWeek as c, selectRecurrenceEndMode as l, selectRecurrenceFrequency as u, selectRecurrenceIssueMode as d, shouldOpenRecurrenceEmail as f } from "./index9.js";
9
+ import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
14
10
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js
15
- function g({ open: g, bankAccountId: _, embeddedBankName: v, messages: y, onSelect: b }) {
16
- let { initResponse: x } = n(), S = p(() => l(x?.scopes), [x?.scopes]), { paymentAccounts: C, isLoading: w, isIncomplete: T } = i({
17
- enabled: g,
18
- canReadEmbedded: S.canReadEmbedded,
19
- canReadExternal: S.canReadExternal
20
- }), E = r(), [D, O] = h(!1), [k, A] = h(a), [j, M] = h({}), N = m(!1), P = d(() => {
21
- N.current = !1, O(!1), A(a), M({});
11
+ var v = [
12
+ "recurrenceStartDate",
13
+ "recurrenceEndDate",
14
+ "recurrenceIssueMode",
15
+ "recurrenceDayOfWeek",
16
+ "recurrenceEndMode",
17
+ "recurrenceMaxOccurrences"
18
+ ], y = [
19
+ "recurrenceSubject",
20
+ "recurrenceBody",
21
+ "recurrenceRecipientsTo",
22
+ "recurrenceRecipientsCc",
23
+ "recurrenceRecipientsBcc"
24
+ ];
25
+ function b({ values: b, errors: x, lockSchedule: S, messages: C, onChange: w, onClearErrors: T, onRevalidateErrors: E }) {
26
+ let D = t(b.customerId || void 0), O = D.data ? e(D.data).trim() : "", [k, A] = _(!1), [j, M] = _(b), [N, P] = _(null), F = h(() => N ?? o(j, O), [
27
+ O,
28
+ N,
29
+ j
30
+ ]), I = g(O);
31
+ m(() => {
32
+ let e = I.current;
33
+ I.current = O, e && e !== O && w(a);
34
+ }, [O, w]);
35
+ let L = p((e) => {
36
+ M(e), P(null), A(!0);
22
37
  }, []);
23
- f(() => {
24
- if (!g || T || N.current || C.length !== 1) return;
25
- let [e] = C;
26
- N.current = !0, b({
27
- bankAccountId: e.id,
28
- bankAccountType: e.type
29
- });
30
- }, [
31
- T,
32
- b,
33
- g,
34
- C
35
- ]);
36
- let F = d((e) => {
37
- let t = C.find((t) => t.id === e);
38
- t && b({
39
- bankAccountId: t.id,
40
- bankAccountType: t.type
41
- });
42
- }, [b, C]), I = d(() => O(!0), []), L = d(() => {
43
- O(!1), A(a), M({});
44
- }, []), R = d((e) => A((t) => ({
45
- ...t,
46
- ...e
47
- })), []), z = d(async () => {
48
- let n = u(k, y);
49
- if (M(n), !(Object.keys(n).length > 0)) try {
50
- let t = await E.mutateAsync({ body: o(k) });
51
- O(!1), A(a), b({
52
- bankAccountId: t.id,
53
- bankAccountType: "BANK_DETAILS"
54
- }), e.success(y.bankAccountCreated.replace("{name}", t.display_name ?? ""));
55
- } catch (n) {
56
- e.error(t(n) ?? y.bankAccountCreateFailed);
57
- }
58
- }, [
59
- E,
60
- k,
61
- y,
62
- b
63
- ]), B = p(() => c({
64
- accounts: C,
65
- embeddedBankName: v,
66
- messages: y
67
- }), [
68
- v,
69
- y,
70
- C
71
- ]);
72
38
  return {
73
- view: p(() => s({
74
- options: B,
75
- isLoading: w,
76
- selectedId: _,
77
- isAddingAccount: D,
78
- canAddAccount: S.canAddAccount,
79
- formValues: k,
80
- formErrors: j,
81
- isSaving: E.isPending
39
+ view: h(() => i({
40
+ fields: b,
41
+ errors: x,
42
+ lockSchedule: S,
43
+ messages: C
82
44
  }), [
83
- _,
84
- E.isPending,
85
- j,
45
+ x,
46
+ S,
47
+ C,
48
+ b
49
+ ]),
50
+ emailView: h(() => r({
51
+ open: k,
52
+ ready: !D.isLoading,
53
+ draft: F,
54
+ messages: C
55
+ }), [
56
+ D.isLoading,
57
+ F,
86
58
  k,
87
- D,
59
+ C
60
+ ]),
61
+ changeFrequency: p((e) => {
62
+ T(v), w((t) => u(t, e));
63
+ }, [w, T]),
64
+ changeMonthDay: p((e) => {
65
+ E(["recurrenceIssueMode"]), w((t) => d(t, e, { lockSchedule: S }));
66
+ }, [
67
+ S,
68
+ w,
69
+ E
70
+ ]),
71
+ changeWeekday: p((e) => {
72
+ S || (T(["recurrenceStartDate"]), E(["recurrenceDayOfWeek"]), w((t) => c(t, e, { lockSchedule: S })));
73
+ }, [
74
+ S,
75
+ w,
76
+ T,
77
+ E
78
+ ]),
79
+ changeStartDate: p((e) => {
80
+ E(["recurrenceStartDate"]), w((t) => s(t, "recurrenceStartDate", e));
81
+ }, [w, E]),
82
+ changeEndDate: p((e) => {
83
+ E(["recurrenceEndDate"]), w((t) => s(t, "recurrenceEndDate", e));
84
+ }, [w, E]),
85
+ changeEndMode: p((e) => {
86
+ E(["recurrenceEndMode"]), w((t) => l(t, e));
87
+ }, [w, E]),
88
+ changeMaxOccurrences: p((e) => {
89
+ E(["recurrenceMaxOccurrences"]), w((t) => ({
90
+ ...t,
91
+ recurrenceMaxOccurrences: e
92
+ }));
93
+ }, [w, E]),
94
+ changeCreationMode: p((e) => {
95
+ let t = {
96
+ ...b,
97
+ recurrenceAutomationLevel: e
98
+ };
99
+ w((t) => ({
100
+ ...t,
101
+ recurrenceAutomationLevel: e
102
+ })), f(t, e) && L(t);
103
+ }, [
104
+ w,
105
+ L,
106
+ b
107
+ ]),
108
+ setUpEmail: p(() => L(b), [L, b]),
109
+ changeEmailOpen: A,
110
+ changeEmail: p((e, t) => P((n) => ({
111
+ ...n ?? F,
112
+ [e]: t
113
+ })), [F]),
114
+ saveEmail: p(() => {
115
+ w((e) => n(e, F)), T(y), A(!1);
116
+ }, [
117
+ F,
88
118
  w,
89
- B,
90
- S.canAddAccount
119
+ T
91
120
  ]),
92
- isLoading: w,
93
- hasAccounts: C.length > 0,
94
- canAddAccount: S.canAddAccount,
95
- reset: P,
96
- selectAccount: F,
97
- openAddAccount: I,
98
- cancelAddAccount: L,
99
- updateAccountForm: R,
100
- saveAccount: z
121
+ reset: p(() => {
122
+ A(!1), I.current = "";
123
+ }, [])
101
124
  };
102
125
  }
103
126
  //#endregion
104
- export { g as useReceivableBankAccount };
127
+ export { b as useReceivableRecurrence };