@tesouro/embedded-components-react 0.5.257 → 0.5.259

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 (64) hide show
  1. package/README.md +2 -1
  2. package/dist/fixtures/index.d.ts +1 -1
  3. package/dist/index.css +109 -9
  4. package/dist/index.d.ts +41 -10
  5. package/dist/lib/ReceivablesWidget.d.ts +41 -10
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +42 -94
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +91 -76
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +67 -173
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +186 -17
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +27 -0
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +28 -72
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +128 -53
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +66 -28
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +28 -34
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +24 -168
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +173 -44
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +274 -267
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +99 -95
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +1 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +28 -25
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +49 -43
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/unsavedChanges.js +13 -0
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +4 -4
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +2 -2
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js +77 -72
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +4 -4
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +363 -295
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +1 -1
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +1 -1
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePreview.js +36 -21
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +1 -1
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +1 -1
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +12 -10
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +21 -14
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +1 -1
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +1 -1
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +68 -64
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +383 -379
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +22 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +8 -2
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +258 -1
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +2 -100
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +95 -23
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +23 -231
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +237 -3
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +3 -249
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +234 -78
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +87 -53
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +49 -349
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +359 -0
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +45 -0
  55. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
  56. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +247 -214
  57. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +175 -147
  58. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +1 -1
  59. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  60. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
  61. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +2 -1
  62. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +109 -89
  63. package/package.json +1 -1
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +0 -4
@@ -2,26 +2,195 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { getAnalyticsReceivablesOptions as e } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
6
- import { withAuthEpoch as t } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
7
- import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
- import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
5
+ import { patchRecurrencesId as e, postOverdueReminders as t, postPaymentReminders as n, postRecurrences as r, postRecurrencesIdCancel as i, postRecurrencesIdPause as a, postRecurrencesIdResume as o } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
6
+ import { getOverdueRemindersOptions as s, getPaymentRemindersOptions as c, getRecurrencesIdOptions as l } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
+ import { withAuthEpoch as u } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
8
+ import { invalidateAllClients as d } from "../../../shared/data-access/dist/lib/clientRegistry.js";
9
+ import { useEmbedApi as f } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
10
+ import { organizationHeaders as p } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
9
11
  import "../../../shared/data-access/dist/index.js";
10
- import { useQuery as i } from "@tanstack/react-query";
12
+ import { overdueRemindersInvalidationKey as m, paymentRemindersInvalidationKey as h, recurrenceInvalidationKey as g, recurrencesInvalidationKey as _ } from "./index2.js";
13
+ import { invalidateReceivable as v } from "./index7.js";
14
+ import { useMutation as y, useQuery as b } from "@tanstack/react-query";
11
15
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js
12
- function a({ enabled: a = !0, ...o }) {
13
- let { client: s, organizationId: c, widgetToken: l, authEpoch: u, organizationStatus: d } = n(), f = !!(c && l) && a, p = e({
14
- client: s,
15
- headers: r(c),
16
- query: o
17
- });
18
- return i({
19
- ...t(p, {
20
- authEpoch: u,
21
- organizationStatus: d
16
+ function x() {
17
+ let e = f();
18
+ return {
19
+ ...e,
20
+ isEnabled: !!(e.organizationId && e.widgetToken)
21
+ };
22
+ }
23
+ function S({ enabled: e = !0 } = {}) {
24
+ let { client: t, organizationId: n, authEpoch: r, organizationStatus: i, isEnabled: a } = x(), o = c({
25
+ client: t,
26
+ headers: p(n)
27
+ });
28
+ return b({
29
+ ...u(o, {
30
+ authEpoch: r,
31
+ organizationStatus: i
32
+ }),
33
+ enabled: a && e
34
+ });
35
+ }
36
+ function C({ enabled: e = !0 } = {}) {
37
+ let { client: t, organizationId: n, authEpoch: r, organizationStatus: i, isEnabled: a } = x(), o = s({
38
+ client: t,
39
+ headers: p(n)
40
+ });
41
+ return b({
42
+ ...u(o, {
43
+ authEpoch: r,
44
+ organizationStatus: i
45
+ }),
46
+ enabled: a && e
47
+ });
48
+ }
49
+ function w() {
50
+ let { client: e, organizationId: t } = f();
51
+ return y({
52
+ mutationFn: async ({ body: r }) => {
53
+ let { data: i } = await n({
54
+ client: e,
55
+ headers: p(t),
56
+ body: r,
57
+ throwOnError: !0
58
+ });
59
+ return i;
60
+ },
61
+ onSuccess: async () => {
62
+ await d(h({
63
+ client: e,
64
+ organizationId: t
65
+ }));
66
+ }
67
+ });
68
+ }
69
+ function T() {
70
+ let { client: e, organizationId: n } = f();
71
+ return y({
72
+ mutationFn: async ({ body: r }) => {
73
+ let { data: i } = await t({
74
+ client: e,
75
+ headers: p(n),
76
+ body: r,
77
+ throwOnError: !0
78
+ });
79
+ return i;
80
+ },
81
+ onSuccess: async () => {
82
+ await d(m({
83
+ client: e,
84
+ organizationId: n
85
+ }));
86
+ }
87
+ });
88
+ }
89
+ async function E({ client: e, organizationId: t, recurrenceId: n, receivableId: r }) {
90
+ await Promise.all([
91
+ d(_({
92
+ client: e,
93
+ organizationId: t
94
+ })),
95
+ ...n ? [d(g({
96
+ client: e,
97
+ organizationId: t,
98
+ recurrenceId: n
99
+ }))] : [],
100
+ v({
101
+ client: e,
102
+ organizationId: t,
103
+ receivableId: r
104
+ })
105
+ ]);
106
+ }
107
+ function D(e) {
108
+ let { client: t, organizationId: n, authEpoch: r, organizationStatus: i, isEnabled: a } = x(), o = l({
109
+ client: t,
110
+ headers: p(n),
111
+ path: { recurrence_id: e ?? "" }
112
+ });
113
+ return b({
114
+ ...u(o, {
115
+ authEpoch: r,
116
+ organizationStatus: i
22
117
  }),
23
- enabled: f
118
+ enabled: a && !!e
119
+ });
120
+ }
121
+ function O() {
122
+ let { client: e, organizationId: t } = f();
123
+ return y({
124
+ mutationFn: async ({ body: n }) => {
125
+ let { data: i } = await r({
126
+ client: e,
127
+ headers: p(t),
128
+ body: n,
129
+ throwOnError: !0
130
+ });
131
+ return i;
132
+ },
133
+ onSuccess: async (n, r) => {
134
+ await E({
135
+ client: e,
136
+ organizationId: t,
137
+ receivableId: r.body.invoice_id
138
+ });
139
+ }
140
+ });
141
+ }
142
+ function k() {
143
+ let { client: t, organizationId: n } = f();
144
+ return y({
145
+ mutationFn: async ({ path: r, body: i }) => {
146
+ let { data: a } = await e({
147
+ client: t,
148
+ headers: p(n),
149
+ path: r,
150
+ body: i,
151
+ throwOnError: !0
152
+ });
153
+ return a;
154
+ },
155
+ onSuccess: async (e, r) => {
156
+ await E({
157
+ client: t,
158
+ organizationId: n,
159
+ recurrenceId: r.path.recurrence_id
160
+ });
161
+ }
162
+ });
163
+ }
164
+ function A(e) {
165
+ let { client: t, organizationId: n } = f();
166
+ return y({
167
+ mutationFn: async ({ path: r }) => {
168
+ let { data: i } = await e({
169
+ client: t,
170
+ headers: p(n),
171
+ path: r,
172
+ throwOnError: !0
173
+ });
174
+ return i;
175
+ },
176
+ onSuccess: async (e, r) => {
177
+ await E({
178
+ client: t,
179
+ organizationId: n,
180
+ recurrenceId: r.path.recurrence_id,
181
+ receivableId: r.receivableId
182
+ });
183
+ }
24
184
  });
25
185
  }
186
+ function j() {
187
+ return A(i);
188
+ }
189
+ function M() {
190
+ return A(a);
191
+ }
192
+ function N() {
193
+ return A(o);
194
+ }
26
195
  //#endregion
27
- export { a as useReceivablesAnalyticsQuery };
196
+ export { j as useCancelRecurrenceMutation, T as useCreateOverdueReminderMutation, w as useCreatePaymentReminderMutation, O as useCreateRecurrenceMutation, C as useOverdueRemindersQuery, M as usePauseRecurrenceMutation, S as usePaymentRemindersQuery, D as useRecurrenceQuery, N as useResumeRecurrenceMutation, k as useUpdateRecurrenceMutation };
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { getAnalyticsReceivablesOptions as e } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
6
+ import { withAuthEpoch as t } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
7
+ import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
9
+ import "../../../shared/data-access/dist/index.js";
10
+ import { useQuery as i } from "@tanstack/react-query";
11
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js
12
+ function a({ enabled: a = !0, ...o }) {
13
+ let { client: s, organizationId: c, widgetToken: l, authEpoch: u, organizationStatus: d } = n(), f = !!(c && l) && a, p = e({
14
+ client: s,
15
+ headers: r(c),
16
+ query: o
17
+ });
18
+ return i({
19
+ ...t(p, {
20
+ authEpoch: u,
21
+ organizationStatus: d
22
+ }),
23
+ enabled: f
24
+ });
25
+ }
26
+ //#endregion
27
+ export { a as useReceivablesAnalyticsQuery };
@@ -2,84 +2,40 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { postBankDetails as e } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
6
- import { getBankDetailsOptions as t } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
- import { OrganizationStatus as n } from "../../../shared/data-access/dist/lib/organizationStatus.js";
8
- import { withAuthEpoch as r } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
9
- import { invalidateAllClients as i } from "../../../shared/data-access/dist/lib/clientRegistry.js";
10
- import { useEmbedApi as a } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
11
- import { organizationHeaders as o } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
12
- import { useAllBankAccountsQuery as s } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
13
- import { useAllExternalBankAccountsQuery as c } from "../../../shared/data-access/dist/lib/external-bank-account/useAllExternalBankAccountsQuery.js";
5
+ import { getEntitiesIdPaymentMethodsOptions as e, getEntitiesIdSettingsOptions as t } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
6
+ import { withAuthEpoch as n } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
7
+ import { useEmbedApi as r } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { organizationHeaders as i } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
14
9
  import "../../../shared/data-access/dist/index.js";
15
- import { entityBankAccountsInvalidationKey as l } from "./index2.js";
16
- import { useMemo as u } from "react";
17
- import { useMutation as d, useQuery as f } from "@tanstack/react-query";
10
+ import { useQuery as a } from "@tanstack/react-query";
18
11
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js
19
- function p({ enabled: e = !0 } = {}) {
20
- let { client: n, organizationId: i, widgetToken: s, authEpoch: c, organizationStatus: l } = a(), u = t({
21
- client: n,
22
- headers: o(i)
12
+ function o({ entityId: t, enabled: o = !0 } = {}) {
13
+ let { client: s, organizationId: c, widgetToken: l, authEpoch: u, organizationStatus: d } = r(), f = e({
14
+ client: s,
15
+ headers: i(c),
16
+ path: { entity_id: t ?? "" }
23
17
  });
24
- return f({
25
- ...r(u, {
26
- authEpoch: c,
27
- organizationStatus: l
18
+ return a({
19
+ ...n(f, {
20
+ authEpoch: u,
21
+ organizationStatus: d
28
22
  }),
29
- enabled: e && !!(i && s)
23
+ enabled: o && !!(c && l && t)
30
24
  });
31
25
  }
32
- function m() {
33
- let { client: t, organizationId: n } = a();
34
- return d({
35
- mutationFn: async ({ body: r }) => {
36
- let { data: i } = await e({
37
- client: t,
38
- headers: o(n),
39
- body: r,
40
- throwOnError: !0
41
- });
42
- return i;
43
- },
44
- onSuccess: async () => {
45
- await i(l({
46
- client: t,
47
- organizationId: n
48
- }));
49
- }
26
+ function s({ entityId: e, enabled: o = !0 } = {}) {
27
+ let { client: s, organizationId: c, widgetToken: l, authEpoch: u, organizationStatus: d } = r(), f = t({
28
+ client: s,
29
+ headers: i(c),
30
+ path: { entity_id: e ?? "" }
31
+ });
32
+ return a({
33
+ ...n(f, {
34
+ authEpoch: u,
35
+ organizationStatus: d
36
+ }),
37
+ enabled: o && !!(c && l && e)
50
38
  });
51
- }
52
- var h = (e) => e ? e.slice(-4) : null;
53
- function g({ enabled: e = !0, canReadEmbedded: t = !1, canReadExternal: r = !1 } = {}) {
54
- let { organizationId: i, widgetToken: o, organizationStatus: l } = a(), d = l === n.Rotating, f = e && !!(o && (i || d)), m = f && t, g = f && r, _ = p({ enabled: e }), v = s({ enabled: m }), y = c({ enabled: g }), b = f ? _.data?.data : void 0, x = m ? v.data?.data : void 0, S = g ? y.data?.data : void 0, C = u(() => [
55
- ...(b ?? []).map((e) => ({
56
- id: e.id,
57
- type: "BANK_DETAILS",
58
- displayName: e.display_name ?? null,
59
- accountNumberLast4: h(e.account_number) ?? e.account_number_last4 ?? null
60
- })),
61
- ...(x ?? []).filter((e) => e.status === "ACTIVE").map((e) => ({
62
- id: e.id,
63
- type: "INTERNAL",
64
- displayName: e.nickname ?? null,
65
- accountNumberLast4: h(e.accountNumber)
66
- })),
67
- ...(S ?? []).filter((e) => e.accountStatus === "ACTIVE" && e.verificationStatus === "VERIFIED").map((e) => ({
68
- id: e.id,
69
- type: "EXTERNAL",
70
- displayName: e.nickname || e.nameOnAccount || null,
71
- accountNumberLast4: h(e.accountNumber)
72
- }))
73
- ], [
74
- b,
75
- x,
76
- S
77
- ]), w = f && _.isLoading || m && v.isLoading || g && y.isLoading;
78
- return {
79
- paymentAccounts: C,
80
- isLoading: w,
81
- isIncomplete: w || f && d || f && (_.isFetching || _.isError) || m && (v.isFetching || v.isError || v.hasNextPage) || g && (y.isFetching || y.isError || y.hasNextPage) || !!(f && _.data?.next_pagination_token)
82
- };
83
39
  }
84
40
  //#endregion
85
- export { m as useCreateEntityBankAccountMutation, p as useEntityBankAccountsQuery, g as usePaymentAccountsQuery };
41
+ export { o as useEntityPaymentMethodsQuery, s as useEntitySettingsQuery };
@@ -2,69 +2,144 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { deleteFilesId as e, postFiles as t } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
6
- import { invalidateAllClients as n } from "../../../shared/data-access/dist/lib/clientRegistry.js";
7
- import { useEmbedApi as r } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
- import { organizationHeaders as i } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
5
+ import { postBankDetails as e } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
6
+ import { getBankAccountOptions as t, getBankDetailsIdOptions as n, getBankDetailsOptions as r, getExternalBankAccountOptions as i } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
+ import { OrganizationStatus as a } from "../../../shared/data-access/dist/lib/organizationStatus.js";
8
+ import { withAuthEpoch as o } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
9
+ import { invalidateAllClients as s } from "../../../shared/data-access/dist/lib/clientRegistry.js";
10
+ import { useEmbedApi as c } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
11
+ import { organizationHeaders as l } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
12
+ import { useAllBankAccountsQuery as u } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
13
+ import { useAllExternalBankAccountsQuery as d } from "../../../shared/data-access/dist/lib/external-bank-account/useAllExternalBankAccountsQuery.js";
9
14
  import "../../../shared/data-access/dist/index.js";
10
- import { receivableAttachmentsInvalidationKey as a, receivableInvalidationKey as o } from "./index2.js";
11
- import { useMutation as s } from "@tanstack/react-query";
15
+ import { entityBankAccountsInvalidationKey as f } from "./index2.js";
16
+ import { useMemo as p } from "react";
17
+ import { useMutation as m, useQuery as h } from "@tanstack/react-query";
12
18
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js
13
- var c = "attachments";
14
- async function l({ client: e, organizationId: t, receivableId: r }) {
15
- let i = [a({
16
- client: e,
17
- organizationId: t
18
- }), ...r ? [o({
19
- client: e,
20
- organizationId: t,
21
- receivableId: r
22
- })] : []];
23
- await Promise.all(i.map((e) => n(e)));
24
- }
25
- function u() {
26
- let { client: e, organizationId: n } = r();
27
- return s({
28
- mutationFn: async ({ file: r }) => {
29
- let { data: a } = await t({
30
- client: e,
31
- headers: i(n),
32
- body: {
33
- file: r,
34
- file_type: c
35
- },
36
- throwOnError: !0
37
- });
38
- return a;
39
- },
40
- onSuccess: async (t, r) => {
41
- await l({
42
- client: e,
43
- organizationId: n,
44
- receivableId: r.receivableId
45
- });
46
- }
19
+ function g({ enabled: e = !0 } = {}) {
20
+ let { client: t, organizationId: n, widgetToken: i, authEpoch: a, organizationStatus: s } = c(), u = r({
21
+ client: t,
22
+ headers: l(n)
23
+ });
24
+ return h({
25
+ ...o(u, {
26
+ authEpoch: a,
27
+ organizationStatus: s
28
+ }),
29
+ enabled: e && !!(n && i)
47
30
  });
48
31
  }
49
- function d() {
50
- let { client: t, organizationId: n } = r();
51
- return s({
52
- mutationFn: async ({ path: r }) => {
53
- await e({
32
+ function _() {
33
+ let { client: t, organizationId: n } = c();
34
+ return m({
35
+ mutationFn: async ({ body: r }) => {
36
+ let { data: i } = await e({
54
37
  client: t,
55
- headers: i(n),
56
- path: r,
38
+ headers: l(n),
39
+ body: r,
57
40
  throwOnError: !0
58
41
  });
42
+ return i;
59
43
  },
60
- onSuccess: async (e, r) => {
61
- await l({
44
+ onSuccess: async () => {
45
+ await s(f({
62
46
  client: t,
63
- organizationId: n,
64
- receivableId: r.receivableId
65
- });
47
+ organizationId: n
48
+ }));
66
49
  }
67
50
  });
68
51
  }
52
+ var v = (e) => e ? e.slice(-4) : null;
53
+ function y(e) {
54
+ return {
55
+ id: e.id,
56
+ type: "BANK_DETAILS",
57
+ displayName: e.display_name ?? null,
58
+ accountNumberLast4: v(e.account_number) ?? e.account_number_last4 ?? null,
59
+ accountHolderName: e.account_holder_name ?? null,
60
+ routingNumber: e.routing_number ?? null,
61
+ accountNumber: e.account_number ?? null
62
+ };
63
+ }
64
+ function b(e) {
65
+ return {
66
+ id: e.id,
67
+ type: "INTERNAL",
68
+ displayName: e.nickname ?? null,
69
+ accountNumberLast4: v(e.accountNumber),
70
+ accountHolderName: e.nameOnAccount ?? null,
71
+ routingNumber: e.routingNumber ?? null,
72
+ accountNumber: e.accountNumber ?? null
73
+ };
74
+ }
75
+ function x(e) {
76
+ return {
77
+ id: e.id,
78
+ type: "EXTERNAL",
79
+ displayName: e.nickname || e.nameOnAccount || null,
80
+ accountNumberLast4: v(e.accountNumber),
81
+ accountHolderName: e.nameOnAccount ?? null,
82
+ routingNumber: e.routingNumber ?? null,
83
+ accountNumber: e.accountNumber ?? null
84
+ };
85
+ }
86
+ function S({ enabled: e = !0, canReadEmbedded: t = !1, canReadExternal: n = !1 } = {}) {
87
+ let { organizationId: r, widgetToken: i, organizationStatus: o } = c(), s = o === a.Rotating, l = e && !!(i && (r || s)), f = l && t, m = l && n, h = g({ enabled: e }), _ = u({ enabled: f }), v = d({ enabled: m }), S = l ? h.data?.data : void 0, C = f ? _.data?.data : void 0, w = m ? v.data?.data : void 0, T = p(() => [
88
+ ...(S ?? []).map(y),
89
+ ...(C ?? []).filter((e) => e.status === "ACTIVE").map(b),
90
+ ...(w ?? []).filter((e) => e.accountStatus === "ACTIVE" && e.verificationStatus === "VERIFIED").map(x)
91
+ ], [
92
+ S,
93
+ C,
94
+ w
95
+ ]), E = l && h.isLoading || f && _.isLoading || m && v.isLoading;
96
+ return {
97
+ paymentAccounts: T,
98
+ isLoading: E,
99
+ isIncomplete: E || l && s || l && (h.isFetching || h.isError) || f && (_.isFetching || _.isError || _.hasNextPage) || m && (v.isFetching || v.isError || v.hasNextPage) || !!(l && h.data?.next_pagination_token)
100
+ };
101
+ }
102
+ function C({ id: e, type: r, enabled: a = !0 }) {
103
+ let { client: s, organizationId: u, widgetToken: d, authEpoch: f, organizationStatus: m } = c(), g = l(u), _ = a && !!(e && u && d), v = {
104
+ authEpoch: f,
105
+ organizationStatus: m
106
+ }, S = h({
107
+ ...o(n({
108
+ client: s,
109
+ headers: g,
110
+ path: { bank_account_id: e ?? "" }
111
+ }), v),
112
+ enabled: _ && r === "BANK_DETAILS",
113
+ retry: !1
114
+ }), C = h({
115
+ ...o(t({
116
+ client: s,
117
+ headers: g,
118
+ path: { id: e ?? "" }
119
+ }), v),
120
+ enabled: _ && r === "INTERNAL",
121
+ retry: !1
122
+ }), w = h({
123
+ ...o(i({
124
+ client: s,
125
+ headers: g,
126
+ path: { id: e ?? "" }
127
+ }), v),
128
+ enabled: _ && r === "EXTERNAL",
129
+ retry: !1
130
+ }), T = r === "BANK_DETAILS" ? S.data : void 0, E = r === "INTERNAL" ? C.data : void 0, D = r === "EXTERNAL" ? w.data : void 0;
131
+ return { paymentAccount: p(() => {
132
+ if (_) {
133
+ if (T) return y(T);
134
+ if (E) return b(E);
135
+ if (D) return x(D);
136
+ }
137
+ }, [
138
+ E,
139
+ T,
140
+ D,
141
+ _
142
+ ]) };
143
+ }
69
144
  //#endregion
70
- export { d as useDeleteReceivableAttachmentMutation, u as useUploadReceivableAttachmentMutation };
145
+ export { _ as useCreateEntityBankAccountMutation, g as useEntityBankAccountsQuery, C as usePaymentAccountQuery, S as usePaymentAccountsQuery };
@@ -1,32 +1,70 @@
1
- import { invalidateAllClients as e, resetAllClients as t } from "../../../shared/data-access/dist/lib/clientRegistry.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { deleteFilesId as e, postFiles as t } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
6
+ import { invalidateAllClients as n } from "../../../shared/data-access/dist/lib/clientRegistry.js";
7
+ import { useEmbedApi as r } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { organizationHeaders as i } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
2
9
  import "../../../shared/data-access/dist/index.js";
3
- import { receivableHistoryInvalidationKey as n, receivableInvalidationKey as r, receivablePdfInvalidationKey as i, receivablesAnalyticsInvalidationKey as a, receivablesInvalidationKey as o } from "./index2.js";
10
+ import { receivableAttachmentsInvalidationKey as a, receivableInvalidationKey as o } from "./index2.js";
11
+ import { useMutation as s } from "@tanstack/react-query";
4
12
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js
5
- async function s({ client: s, organizationId: c, receivableId: l, resetPdf: u = !1 }) {
6
- let d = [
7
- o({
8
- client: s,
9
- organizationId: c
10
- }),
11
- a({
12
- client: s,
13
- organizationId: c
14
- }),
15
- ...l ? [r({
16
- client: s,
17
- organizationId: c,
18
- receivableId: l
19
- }), n({
20
- client: s,
21
- organizationId: c,
22
- receivableId: l
23
- })] : []
24
- ], f = l ? i({
25
- client: s,
26
- organizationId: c,
27
- receivableId: l
28
- }) : void 0;
29
- await Promise.all([...d.map((t) => e(t)), ...f ? [u ? t(f) : e(f)] : []]);
13
+ var c = "attachments";
14
+ async function l({ client: e, organizationId: t, receivableId: r }) {
15
+ let i = [a({
16
+ client: e,
17
+ organizationId: t
18
+ }), ...r ? [o({
19
+ client: e,
20
+ organizationId: t,
21
+ receivableId: r
22
+ })] : []];
23
+ await Promise.all(i.map((e) => n(e)));
24
+ }
25
+ function u() {
26
+ let { client: e, organizationId: n } = r();
27
+ return s({
28
+ mutationFn: async ({ file: r }) => {
29
+ let { data: a } = await t({
30
+ client: e,
31
+ headers: i(n),
32
+ body: {
33
+ file: r,
34
+ file_type: c
35
+ },
36
+ throwOnError: !0
37
+ });
38
+ return a;
39
+ },
40
+ onSuccess: async (t, r) => {
41
+ await l({
42
+ client: e,
43
+ organizationId: n,
44
+ receivableId: r.receivableId
45
+ });
46
+ }
47
+ });
48
+ }
49
+ function d() {
50
+ let { client: t, organizationId: n } = r();
51
+ return s({
52
+ mutationFn: async ({ path: r }) => {
53
+ await e({
54
+ client: t,
55
+ headers: i(n),
56
+ path: r,
57
+ throwOnError: !0
58
+ });
59
+ },
60
+ onSuccess: async (e, r) => {
61
+ await l({
62
+ client: t,
63
+ organizationId: n,
64
+ receivableId: r.receivableId
65
+ });
66
+ }
67
+ });
30
68
  }
31
69
  //#endregion
32
- export { s as invalidateReceivable };
70
+ export { d as useDeleteReceivableAttachmentMutation, u as useUploadReceivableAttachmentMutation };