@tesouro/embedded-components-react 0.7.37 → 0.7.41

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 (36) hide show
  1. package/README.md +2 -2
  2. package/dist/fixtures/index.d.ts +1 -1
  3. package/dist/index.d.ts +21 -14
  4. package/dist/lib/CounterpartsWidget.d.ts +16 -14
  5. package/dist/lib/CounterpartsWidgetPublic.d.ts +16 -14
  6. package/dist/lib/CustomersWidget.d.ts +16 -14
  7. package/dist/lib/TransfersWidget.d.ts +5 -0
  8. package/dist/lib/WidgetSuite.d.ts +5 -0
  9. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/fieldInput/formatPhoneNumberInput.js +2 -2
  10. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/mocks/bankAccounts.js +5 -5
  11. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartsWidget.js +30 -29
  12. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/constants.js +6 -6
  13. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsTable.js +143 -95
  14. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js +60 -48
  15. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/mocks/labels.js +1 -1
  16. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index.js +4 -4
  17. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index2.js +22 -15
  18. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index3.js +137 -135
  19. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +106 -108
  20. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +2 -2
  21. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +50 -50
  22. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +22 -22
  23. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index.js +2 -2
  25. package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index3.js +6 -7
  26. package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index6.js +14 -34
  27. package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index7.js +16 -13
  28. package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index8.js +4 -10
  29. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetInner.js +99 -75
  30. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/featureLabels.js +2 -1
  31. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/useTransfersPageState.js +49 -0
  32. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/mocks/labels.js +2 -1
  33. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/mocks/transfers.js +103 -85
  34. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js +73 -61
  35. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/labels.js +3 -0
  36. package/package.json +1 -1
@@ -7,7 +7,7 @@ import { invalidateAllClients as t } from "../../../shared/data-access/dist/lib/
7
7
  import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
8
  import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
9
9
  import "../../../shared/data-access/dist/index.js";
10
- import { bankAccountInvalidationKeyForAccount as i, bankAccountTransfersInvalidationKeyForAccount as a, bankAccountsInvalidationKey as o } from "./index3.js";
10
+ import { bankAccountInvalidationKeyForAccount as i, bankAccountsInvalidationKey as a, organizationTransfersInvalidationKey as o } from "./index3.js";
11
11
  import { useMutation as s } from "@tanstack/react-query";
12
12
  //#region ../../libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index7.js
13
13
  function c() {
@@ -19,18 +19,21 @@ function c() {
19
19
  }),
20
20
  onSuccess: async (e, n) => {
21
21
  let r = n.body.fromBankAccountId, s = n.body.toBankAccountId, u = [.../* @__PURE__ */ new Set([r, s])];
22
- await Promise.all([t(o({
23
- client: c,
24
- organizationId: l
25
- })), ...u.flatMap((e) => [t(a({
26
- client: c,
27
- organizationId: l,
28
- bankAccountId: e
29
- })), t(i({
30
- client: c,
31
- organizationId: l,
32
- bankAccountId: e
33
- }))])]);
22
+ await Promise.all([
23
+ t(a({
24
+ client: c,
25
+ organizationId: l
26
+ })),
27
+ t(o({
28
+ client: c,
29
+ organizationId: l
30
+ })),
31
+ ...u.map((e) => t(i({
32
+ client: c,
33
+ organizationId: l,
34
+ bankAccountId: e
35
+ })))
36
+ ]);
34
37
  }
35
38
  });
36
39
  }
@@ -7,7 +7,7 @@ import { invalidateAllClients as t } from "../../../shared/data-access/dist/lib/
7
7
  import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
8
  import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
9
9
  import "../../../shared/data-access/dist/index.js";
10
- import { bankAccountInvalidationKeyForAccount as i, bankAccountTransfersInvalidationKeyForAccount as a, bankAccountsInvalidationKey as o } from "./index3.js";
10
+ import { bankAccountInvalidationKeyForAccount as i, bankAccountsInvalidationKey as a, organizationTransfersInvalidationKey as o } from "./index3.js";
11
11
  import { useMutation as s } from "@tanstack/react-query";
12
12
  //#region ../../libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index8.js
13
13
  function c() {
@@ -20,19 +20,13 @@ function c() {
20
20
  onSuccess: async (e, n) => {
21
21
  let r = n.body.fromBankAccountId, s = n.body.toBankAccountId, u = n.body.type === "EXTERNAL_TO_INTERNAL" ? s : r;
22
22
  await Promise.all([
23
- t(o({
24
- client: c,
25
- organizationId: l
26
- })),
27
23
  t(a({
28
24
  client: c,
29
- organizationId: l,
30
- bankAccountId: r
25
+ organizationId: l
31
26
  })),
32
- t(a({
27
+ t(o({
33
28
  client: c,
34
- organizationId: l,
35
- bankAccountId: s
29
+ organizationId: l
36
30
  })),
37
31
  t(i({
38
32
  client: c,
@@ -14,114 +14,138 @@ import { DEFAULT_FEATURE_LABELS as o } from "./featureLabels.js";
14
14
  import { TRANSFERS_ANALYTICS_EVENTS as s } from "../analytics/events.js";
15
15
  import { isPaginatedAccountsQueryInFlight as c } from "../../../../data-access/dist/index2.js";
16
16
  import { useTransferBankAccountsQuery as l } from "../../../../data-access/dist/index4.js";
17
- import { useTransferExternalAccountsQuery as te } from "../../../../data-access/dist/index5.js";
18
- import { useMergedRecentBankAccountTransfersQuery as u } from "../../../../data-access/dist/index6.js";
17
+ import { useTransferExternalAccountsQuery as u } from "../../../../data-access/dist/index5.js";
18
+ import { useOrganizationTransfersQuery as te } from "../../../../data-access/dist/index6.js";
19
19
  import "../../../../data-access/dist/index.js";
20
- import { mapTransferToRowView as d, useTransferMoneyModalController as f } from "./useTransferMoneyModalController.js";
21
- import { transfersWidgetTestIds as p } from "./testIds.js";
22
- import { TRANSFERS_WIDGET_LABELS_EN as ne } from "../../../../ui/dist/lib/TransfersWidget/labels.js";
23
- import { TransfersWidget as m } from "../../../../ui/dist/lib/TransfersWidget/TransfersWidget.js";
20
+ import { mapTransferToRowView as ne, useTransferMoneyModalController as re } from "./useTransferMoneyModalController.js";
21
+ import { transfersWidgetTestIds as d } from "./testIds.js";
22
+ import { TRANSFERS_PAGE_SIZE_OPTIONS as ie, useTransfersPageState as ae } from "./useTransfersPageState.js";
23
+ import { TRANSFERS_WIDGET_LABELS_EN as oe } from "../../../../ui/dist/lib/TransfersWidget/labels.js";
24
+ import { TransfersWidget as se } from "../../../../ui/dist/lib/TransfersWidget/TransfersWidget.js";
24
25
  import "../../../../ui/dist/index.js";
25
- import { useCallback as h, useEffect as g, useMemo as _ } from "react";
26
- import { jsx as v } from "react/jsx-runtime";
26
+ import { useCallback as ce, useEffect as f, useMemo as p, useState as m } from "react";
27
+ import { jsx as h } from "react/jsx-runtime";
27
28
  //#region ../../libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetInner.js
28
- var y = [i.TransferWriteOrg, i.BankAccountReadOrg], b = [t, e];
29
- function x(e) {
29
+ var g = [i.TransferWriteOrg, i.BankAccountReadOrg], _ = [t, e];
30
+ function v(e) {
30
31
  return e.slice(-4);
31
32
  }
32
- function S({ labels: e, featureLabels: t, isTransferMoneyOpen: S, defaultIsTransferMoneyOpen: C, onTransferMoneyOpenChange: w }) {
33
- let T = {
33
+ function y({ labels: e, featureLabels: t, isTransferMoneyOpen: y, defaultIsTransferMoneyOpen: le, onTransferMoneyOpenChange: ue }) {
34
+ let b = {
34
35
  ...o,
35
36
  ...t
36
- }, E = {
37
- ...ne,
37
+ }, x = {
38
+ ...oe,
38
39
  ...e,
39
40
  ...t?.routeSeparator === void 0 ? {} : { listAccountsSeparator: t.routeSeparator }
40
- }, D = a(), { initResponse: O } = ee(), k = n(r().organizationStatus);
41
- g(() => {
42
- D(s.Mounted);
43
- }, [D]);
44
- let A = O?.scopes ?? [], j = A.includes(i.ExternalBankAccountReadOrg), M = A.includes(i.PaymentRailAch), N = j && M, P = y.every((e) => A.includes(e)), { mergedTransfers: F, isLoading: I, isError: L, refetch: R } = u(), z = l(), { data: B, isError: V, refetch: H } = z, U = te({ enabled: j }), { data: W, isError: G, refetch: K } = U, q = B?.data ?? [], J = _(() => N ? (W?.data ?? []).filter((e) => e.verificationStatus === "VERIFIED" && e.accountStatus === "ACTIVE") : [], [N, W?.data]), Y = _(() => {
41
+ }, S = a(), { initResponse: C } = ee(), { organizationId: de, organizationStatus: fe } = r(), pe = n(fe);
42
+ f(() => {
43
+ S(s.Mounted);
44
+ }, [S]);
45
+ let w = C?.scopes ?? [], T = w.includes(i.ExternalBankAccountReadOrg), me = w.includes(i.PaymentRailAch), E = T && me, D = g.every((e) => w.includes(e)), O = ae({
46
+ organizationId: de,
47
+ userId: C?.userId
48
+ }), { data: k, isLoading: A, isError: j, isPlaceholderData: M, refetch: N } = te({
49
+ limit: O.pageSize,
50
+ pagination_token: O.paginationToken
51
+ }), P = l(), { data: F, isError: I, refetch: L } = P, R = u({ enabled: T }), { data: z, isError: he, refetch: B } = R, V = F?.data ?? [], H = p(() => E ? (z?.data ?? []).filter((e) => e.verificationStatus === "VERIFIED" && e.accountStatus === "ACTIVE") : [], [E, z?.data]), U = p(() => {
45
52
  let e = /* @__PURE__ */ new Map();
46
- for (let t of q) {
47
- let n = x(t.accountNumber), r = t.nickname?.trim() || E.accountFallbackName;
53
+ for (let t of V) {
54
+ let n = v(t.accountNumber), r = t.nickname?.trim() || x.accountFallbackName;
48
55
  e.set(t.id, `${r} ···${n}`);
49
56
  }
50
- for (let t of J) {
51
- let n = x(t.accountNumber), r = t.nickname?.trim() || t.nameOnAccount;
57
+ for (let t of H) {
58
+ let n = v(t.accountNumber), r = t.nickname?.trim() || t.nameOnAccount;
52
59
  e.set(t.id, `${r} ···${n}`);
53
60
  }
54
61
  return e;
55
62
  }, [
56
- q,
57
- E.accountFallbackName,
58
- J
59
- ]), X = _(() => F.map((e) => d(e, Y, E, T)), [
60
- Y,
61
- T,
62
- E,
63
- F
64
- ]), Z = h(() => {
65
- R(), H(), j && K();
63
+ V,
64
+ x.accountFallbackName,
65
+ H
66
+ ]), W = k?.data, G = p(() => (W ?? []).map((e) => ne(e, U, x, b)), [
67
+ U,
68
+ b,
69
+ x,
70
+ W
71
+ ]), K = k?.nextPaginationToken ?? void 0, q = k?.prevPaginationToken ?? void 0, [J, ge] = m(O);
72
+ !M && (J.pageIndex !== O.pageIndex || J.pageSize !== O.pageSize) && ge(O);
73
+ let Y = J.pageIndex * J.pageSize, _e = {
74
+ pageSize: O.pageSize,
75
+ pageSizeOptions: ie,
76
+ rangeLabel: `${b.viewingRangeLabel} ${G.length === 0 ? "0-0" : `${Y + 1}-${Y + G.length}`}`,
77
+ isPreviousDisabled: !q,
78
+ isNextDisabled: !K,
79
+ isDisabled: M,
80
+ onPageSizeChange: O.changePageSize,
81
+ onPreviousPageClick: () => {
82
+ q && O.goToPreviousPage(q);
83
+ },
84
+ onNextPageClick: () => {
85
+ K && O.goToNextPage(K);
86
+ }
87
+ }, X = ce(() => {
88
+ N(), L(), T && B();
66
89
  }, [
67
- j,
68
- H,
69
- K,
70
- R
90
+ T,
91
+ L,
92
+ B,
93
+ N
71
94
  ]);
72
- g(() => {
95
+ f(() => {
73
96
  let e = () => {
74
- Z();
97
+ X();
75
98
  };
76
- for (let t of b) window.addEventListener(t, e);
99
+ for (let t of _) window.addEventListener(t, e);
77
100
  return () => {
78
- for (let t of b) window.removeEventListener(t, e);
101
+ for (let t of _) window.removeEventListener(t, e);
79
102
  };
80
- }, [Z]);
81
- let { modalProps: re, openModal: ie } = f({
82
- labels: E,
83
- featureLabels: T,
84
- embeddedBankAccounts: q,
85
- verifiedExternalBankAccounts: J,
86
- track: D,
87
- isTransferMoneyOpen: S,
88
- defaultIsTransferMoneyOpen: C,
89
- onTransferMoneyOpenChange: w
90
- }), ae = c(z), oe = j && c(U), se = k && !B || I || ae || oe, Q = L || V || j && G, ce = q.length + J.length, $ = !(q.length > 0) || ce <= 1;
91
- return /* @__PURE__ */ v(m, {
92
- transferRows: X,
93
- isLoading: se,
103
+ }, [X]);
104
+ let { modalProps: ve, openModal: Z } = re({
105
+ labels: x,
106
+ featureLabels: b,
107
+ embeddedBankAccounts: V,
108
+ verifiedExternalBankAccounts: H,
109
+ track: S,
110
+ isTransferMoneyOpen: y,
111
+ defaultIsTransferMoneyOpen: le,
112
+ onTransferMoneyOpenChange: ue
113
+ }), ye = c(P), be = T && c(R), xe = pe && !F || A || ye || be, Q = j || I || T && he, Se = V.length + H.length, $ = !(V.length > 0) || Se <= 1;
114
+ return /* @__PURE__ */ h(se, {
115
+ transferRows: G,
116
+ pagination: _e,
117
+ isLoading: xe,
94
118
  isError: Q,
95
- onRetry: Q ? () => void Z() : void 0,
96
- showTransferMoneyCta: P,
119
+ onRetry: Q ? () => void X() : void 0,
120
+ showTransferMoneyCta: D,
97
121
  isTransferMoneyCtaDisabled: $,
98
- onTransferMoneyClick: P && !$ ? () => ie() : void 0,
122
+ onTransferMoneyClick: D && !$ ? () => Z() : void 0,
99
123
  transferMoneyModal: {
100
- ...re,
124
+ ...ve,
101
125
  testIds: {
102
- root: p.modal,
103
- closeButton: p.modalCloseButton,
104
- fromAccountTrigger: p.modalFromAccountTrigger,
105
- toAccountTrigger: p.modalToAccountTrigger,
106
- accountsConfirm: p.modalAccountsConfirmButton,
107
- amountInput: p.modalAmountInput,
126
+ root: d.modal,
127
+ closeButton: d.modalCloseButton,
128
+ fromAccountTrigger: d.modalFromAccountTrigger,
129
+ toAccountTrigger: d.modalToAccountTrigger,
130
+ accountsConfirm: d.modalAccountsConfirmButton,
131
+ amountInput: d.modalAmountInput,
108
132
  reviewStep: {
109
- confirm: p.modalConfirmTransferButton,
110
- goBack: p.modalGoBackButton
133
+ confirm: d.modalConfirmTransferButton,
134
+ goBack: d.modalGoBackButton
111
135
  },
112
- resultStep: { backToTransfers: p.modalBackToTransfersButton }
136
+ resultStep: { backToTransfers: d.modalBackToTransfersButton }
113
137
  }
114
138
  },
115
139
  labels: e,
116
140
  testIds: {
117
- transferMoneyButton: p.transferMoneyButton,
118
- skeleton: p.skeleton,
119
- error: p.error,
120
- retry: p.retry,
121
- empty: p.empty,
122
- transferRow: p.transferRow
141
+ transferMoneyButton: d.transferMoneyButton,
142
+ skeleton: d.skeleton,
143
+ error: d.error,
144
+ retry: d.retry,
145
+ empty: d.empty,
146
+ transferRow: d.transferRow
123
147
  }
124
148
  });
125
149
  }
126
150
  //#endregion
127
- export { S as TransfersWidgetInner };
151
+ export { y as TransfersWidgetInner };
@@ -3,7 +3,8 @@ var e = {
3
3
  unavailableLabel: "Unavailable",
4
4
  routeSeparator: "to",
5
5
  defaultCurrencyCode: "USD",
6
- defaultSecCode: "CCD"
6
+ defaultSecCode: "CCD",
7
+ viewingRangeLabel: "Viewing"
7
8
  };
8
9
  //#endregion
9
10
  export { e as DEFAULT_FEATURE_LABELS };
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useCallback as e, useState as t } from "react";
6
+ //#region ../../libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/useTransfersPageState.js
7
+ var n = [
8
+ 10,
9
+ 25,
10
+ 50,
11
+ 100
12
+ ], r = (e) => ({
13
+ paginationToken: void 0,
14
+ pageIndex: 0,
15
+ pageSize: e
16
+ });
17
+ function i({ organizationId: n, userId: i }) {
18
+ let [a, o] = t({
19
+ organizationId: n,
20
+ userId: i
21
+ }), [s, c] = t(() => r(25)), l = n === void 0 ? a.organizationId : n, u = i === void 0 ? a.userId : i;
22
+ (l !== a.organizationId || u !== a.userId) && (o({
23
+ organizationId: l,
24
+ userId: u
25
+ }), c(r(s.pageSize)));
26
+ let d = e((e) => {
27
+ c((t) => ({
28
+ ...t,
29
+ paginationToken: e,
30
+ pageIndex: t.pageIndex + 1
31
+ }));
32
+ }, []), f = e((e) => {
33
+ c((t) => ({
34
+ ...t,
35
+ paginationToken: e,
36
+ pageIndex: Math.max(0, t.pageIndex - 1)
37
+ }));
38
+ }, []), p = e((e) => {
39
+ c(r(e));
40
+ }, []);
41
+ return {
42
+ ...s,
43
+ goToNextPage: d,
44
+ goToPreviousPage: f,
45
+ changePageSize: p
46
+ };
47
+ }
48
+ //#endregion
49
+ export { n as TRANSFERS_PAGE_SIZE_OPTIONS, i as useTransfersPageState };
@@ -4,7 +4,8 @@ var e = {
4
4
  populated: "Recent transfers across three accounts: completed, pending and failed, internal and to or from an external account. Hover a row for its status and type. Transfer money moves money between your accounts or to and from Operating reserve, and the new transfer lands in the list as pending.",
5
5
  empty: "Three accounts and no transfers yet. Transfer money is enabled, and a submitted transfer becomes the first row.",
6
6
  loading: "The accounts read is held open, so the list skeleton stays on screen.",
7
- error: "Every account’s transfers read fails with a 500. The widget shows its own error with Try again; Transfer money still works, because the accounts themselves loaded.",
7
+ error: "The transfers read fails with a 500. The widget shows its own error with Try again; Transfer money still works, because the accounts themselves loaded.",
8
+ paginated: "Fifty-seven transfers, newest first, 25 to a page. Next and previous follow the tokens the transfers read returns.",
8
9
  "control-hidden": "The same transfers, read by a session without transfer:write:org. The Transfer money button is absent."
9
10
  },
10
11
  scenarios: {
@@ -2,103 +2,111 @@ import { Scope as e } from "../../../../shared/data-access/dist/lib/scopes.js";
2
2
  import "../../../../shared/data-access/dist/index.js";
3
3
  import { AN_EXTERNAL_BANK_ACCOUNT as t, A_BANK_ACCOUNT as n, A_BANK_ACCOUNT_TRANSFER as r, A_BOOK_MONEY_MOVEMENT as i } from "../../../../shared/data-access-mocks/dist/lib/fixtures.js";
4
4
  import { SCENARIO_LABELS as a } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/labels.js";
5
- import { PROXY as o, answer as s, bodyOf as c, crossCuttingScenarios as l, endpoint as u, initRoute as d, json as f, matchPath as p, problem as m, wait as h } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/scenario.js";
6
- import { failedRead as g } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/worlds.js";
7
- import { TRANSFERS_LABELS as _ } from "./labels.js";
5
+ import { PROXY as o, answer as s, bodyOf as c, crossCuttingScenarios as l, endpoint as u, initRoute as d, json as f, problem as p, wait as m } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/scenario.js";
6
+ import { failedRead as h } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/worlds.js";
7
+ import { TRANSFERS_LABELS as g } from "./labels.js";
8
8
  //#region ../../libs/tesouro-embedded-components-react/transfers-widget/feature/dist/mocks/transfers.js
9
- var v = [e.TransferWriteOrg, e.BankAccountReadOrg], y = [
10
- ...v,
9
+ var _ = [e.TransferWriteOrg, e.BankAccountReadOrg], v = [
10
+ ..._,
11
11
  e.ExternalBankAccountReadOrg,
12
12
  e.PaymentRailAch
13
- ], b = [
13
+ ], y = [
14
14
  e.BankAccountReadOrg,
15
15
  e.ExternalBankAccountReadOrg,
16
16
  e.PaymentRailAch
17
- ], x = (e) => `00000000-0000-4000-8000-0000000002${String(e).padStart(2, "0")}`, S = (e) => ({
17
+ ], b = (e) => `00000000-0000-4000-8000-0000000002${String(e).padStart(2, "0")}`, x = (e) => ({
18
18
  currencyCode: "USD",
19
19
  value: e
20
- }), C = n, w = {
20
+ }), S = n, C = {
21
21
  ...n,
22
- id: x(6),
22
+ id: b(6),
23
23
  accountNumber: "000000004006",
24
24
  nickname: "Payroll",
25
- balance: S(185e4)
26
- }, T = {
25
+ balance: x(185e4)
26
+ }, w = {
27
27
  ...n,
28
- id: x(7),
28
+ id: b(7),
29
29
  accountNumber: "000000004007",
30
30
  nickname: "Tax reserve",
31
- balance: S(625050)
32
- }, E = [
31
+ balance: x(625050)
32
+ }, T = [
33
+ S,
33
34
  C,
34
- w,
35
- T
36
- ], D = t, O = {
35
+ w
36
+ ], E = t, D = {
37
37
  ...t,
38
- id: x(8),
38
+ id: b(8),
39
39
  accountNumber: "••••••••4321",
40
40
  nickname: "Supplier payouts",
41
41
  verificationStatus: "UNVERIFIED"
42
- }, k = [D, O], A = (e) => ({
42
+ }, O = [E, D], k = (e) => ({
43
43
  id: e.id,
44
44
  nickname: e.nickname ?? null
45
- }), j = (e, t) => ({
45
+ }), A = (e, t) => ({
46
46
  ...r,
47
- id: x(e),
47
+ id: b(e),
48
48
  ...t
49
- }), M = [
50
- j(12, {
51
- fromAccount: A(C),
52
- toAccount: A(w),
53
- amount: S(12e5),
49
+ }), j = [
50
+ A(12, {
51
+ fromAccount: k(S),
52
+ toAccount: k(C),
53
+ amount: x(12e5),
54
54
  date: "2026-02-03T15:00:00.000Z",
55
55
  status: "PENDING"
56
56
  }),
57
- j(13, {
58
- fromAccount: A(C),
59
- toAccount: A(D),
60
- amount: S(35e4),
57
+ A(13, {
58
+ fromAccount: k(S),
59
+ toAccount: k(E),
60
+ amount: x(35e4),
61
61
  date: "2026-02-02T11:30:00.000Z",
62
62
  network: "ACH",
63
63
  type: "INTERNAL_TO_EXTERNAL"
64
64
  }),
65
- j(14, {
66
- fromAccount: A(D),
67
- toAccount: A(T),
68
- amount: S(8e4),
65
+ A(14, {
66
+ fromAccount: k(E),
67
+ toAccount: k(w),
68
+ amount: x(8e4),
69
69
  date: "2026-01-29T10:00:00.000Z",
70
70
  network: "ACH",
71
71
  type: "EXTERNAL_TO_INTERNAL",
72
72
  status: "FAILED"
73
73
  }),
74
- j(15, {
75
- fromAccount: A(w),
76
- toAccount: A(T),
77
- amount: S(62500),
74
+ A(15, {
75
+ fromAccount: k(C),
76
+ toAccount: k(w),
77
+ amount: x(62500),
78
78
  date: "2026-01-27T09:00:00.000Z"
79
79
  }),
80
- j(16, {
81
- fromAccount: A(C),
82
- toAccount: A(T),
83
- amount: S(25e4),
80
+ A(16, {
81
+ fromAccount: k(S),
82
+ toAccount: k(w),
83
+ amount: x(25e4),
84
84
  date: "2026-01-15T09:00:00.000Z"
85
85
  })
86
- ], N = (e) => ({
86
+ ], M = (e) => ({
87
87
  data: e,
88
88
  nextPaginationToken: null,
89
89
  prevPaginationToken: null
90
- }), P = `${o}/bank-accounts`, F = `${o}/bank-accounts/:id/transfers`, I = (e) => e === P, L = (e) => p(F)(e) !== void 0, R = (e) => {
90
+ }), N = `${o}/bank-accounts`, P = `${o}/bank-accounts/transfers`, F = (e) => e === N, I = (e) => e === P, L = (e) => e === `${o}/external-bank-accounts`, R = Array.from({ length: 57 }, (e, t) => {
91
+ let n = j[t % j.length], r = (/* @__PURE__ */ new Date(Date.UTC(2026, 1, 3) - t * 864e5)).toISOString();
92
+ return {
93
+ ...n,
94
+ id: `00000000-0000-4000-8000-0000000004${String(t).padStart(2, "0")}`,
95
+ createdDateTime: r,
96
+ date: r
97
+ };
98
+ }), z = (e, t = 25) => Array.from({ length: Math.ceil(e.length / t) }, (n, r) => e.slice(r * t, (r + 1) * t)), B = (e) => {
91
99
  let t = e.accounts.map((e) => ({ ...e })), n = [...e.transfers], r = e.externals ?? [], a = 0, l = (e) => t.find((t) => t.id === e)?.nickname ?? r.find((t) => t.id === e)?.nickname ?? null, d = (e, n) => {
92
100
  let r = t.find((t) => t.id === e);
93
- r && (r.balance = S(Number(r.balance.value) + n));
94
- }, p = (e) => async (t) => {
95
- await h(600);
101
+ r && (r.balance = x(Number(r.balance.value) + n));
102
+ }, h = (e) => async (t) => {
103
+ await m(600);
96
104
  let r = c(t), o = String(r.fromBankAccountId ?? ""), s = String(r.toBankAccountId ?? ""), u = Number(r.amount ?? 0);
97
- if (!l(o) || !l(s) || !(u > 0)) return m(400, "Bad Request", "The transfer is not valid.");
105
+ if (!l(o) || !l(s) || !(u > 0)) return p(400, "Bad Request", "The transfer is not valid.");
98
106
  a += 1;
99
- let p = `00000000-0000-4000-8000-0000000003${String(a).padStart(2, "0")}`, g = S(u), _ = (/* @__PURE__ */ new Date()).toISOString(), v = e === "BOOK" ? "INTERNAL_TO_INTERNAL" : r.type === "EXTERNAL_TO_INTERNAL" ? "EXTERNAL_TO_INTERNAL" : "INTERNAL_TO_EXTERNAL";
107
+ let h = `00000000-0000-4000-8000-0000000003${String(a).padStart(2, "0")}`, g = x(u), _ = (/* @__PURE__ */ new Date()).toISOString(), v = e === "BOOK" ? "INTERNAL_TO_INTERNAL" : r.type === "EXTERNAL_TO_INTERNAL" ? "EXTERNAL_TO_INTERNAL" : "INTERNAL_TO_EXTERNAL";
100
108
  return n.unshift({
101
- id: p,
109
+ id: h,
102
110
  amount: g,
103
111
  createdDateTime: _,
104
112
  date: _,
@@ -116,7 +124,7 @@ var v = [e.TransferWriteOrg, e.BankAccountReadOrg], y = [
116
124
  type: v
117
125
  }), d(o, -u), d(s, u), f({
118
126
  ...i,
119
- id: p,
127
+ id: h,
120
128
  amount: g,
121
129
  date: _,
122
130
  fromBankAccount: {
@@ -132,53 +140,63 @@ var v = [e.TransferWriteOrg, e.BankAccountReadOrg], y = [
132
140
  }, 201);
133
141
  };
134
142
  return [
135
- s(I, () => f(N(t))),
136
- s((e) => e === `${o}/external-bank-accounts`, () => f(N(r))),
137
- u("GET", F, (e, { id: t }) => f(N(n.filter((e) => e.fromAccount.id === t || e.toAccount.id === t)))),
138
- u("POST", `${o}/money-movements/book`, p("BOOK")),
139
- u("POST", `${o}/money-movements/ach`, p("ACH"))
143
+ s(F, () => f(M(t))),
144
+ s(L, () => f(M(r))),
145
+ s(I, () => f(M(n))),
146
+ u("POST", `${o}/money-movements/book`, h("BOOK")),
147
+ u("POST", `${o}/money-movements/ach`, h("ACH"))
140
148
  ];
141
- }, z = {
142
- accounts: E,
143
- transfers: M,
144
- externals: k
145
- }, B = (e, t, n, r, { transfersFail: i = !1 } = {}) => ({
149
+ }, V = {
150
+ accounts: T,
151
+ transfers: j,
152
+ externals: O
153
+ }, H = (e, t, n, r, { transfersFail: i = !1 } = {}) => ({
146
154
  key: e,
147
155
  ...t,
148
156
  routes: () => [
149
157
  d(n),
150
- ...i ? [g(L)] : [],
151
- ...R(r)
158
+ ...i ? [h(I)] : [],
159
+ ...B(r)
152
160
  ]
153
- }), V = _.blurbs, H = (e) => ({
161
+ }), U = g.blurbs, W = (e) => ({
154
162
  label: a[e].label,
155
- blurb: V[e] ?? a[e].blurb
156
- }), [U] = l({
157
- scopes: y,
163
+ blurb: U[e] ?? a[e].blurb
164
+ }), G = s(L, () => f(M(O))), [K] = l({
165
+ scopes: v,
166
+ read: {
167
+ matches: F,
168
+ body: M(T)
169
+ },
170
+ supportRoutes: [G],
171
+ blurbs: g.blurbs
172
+ }, ["loading"]), [q] = l({
173
+ scopes: v,
158
174
  read: {
159
175
  matches: I,
160
- body: N(E)
176
+ body: M(R),
177
+ pages: z(R)
161
178
  },
162
- supportRoutes: [s((e) => e === `${o}/external-bank-accounts`, () => f(N(k)))],
163
- blurbs: _.blurbs
164
- }, ["loading"]), W = [
165
- B("populated", H("populated"), y, z),
166
- B("empty", H("empty"), y, {
167
- ...z,
179
+ supportRoutes: [s(F, () => f(M(T))), G],
180
+ blurbs: g.blurbs
181
+ }, ["paginated"]), J = [
182
+ H("populated", W("populated"), v, V),
183
+ H("empty", W("empty"), v, {
184
+ ...V,
168
185
  transfers: []
169
186
  }),
170
- ...U ? [U] : [],
171
- B("error", H("error"), y, z, { transfersFail: !0 }),
172
- B("control-hidden", H("control-hidden"), b, z),
173
- B("internal-only", _.scenarios["internal-only"], v, {
174
- accounts: E,
175
- transfers: M
187
+ ...K ? [K] : [],
188
+ ...q ? [q] : [],
189
+ H("error", W("error"), v, V, { transfersFail: !0 }),
190
+ H("control-hidden", W("control-hidden"), y, V),
191
+ H("internal-only", g.scenarios["internal-only"], _, {
192
+ accounts: T,
193
+ transfers: j
176
194
  }),
177
- B("single-account", _.scenarios["single-account"], y, {
178
- accounts: [C],
179
- transfers: M.filter((e) => e.fromAccount.id === C.id || e.toAccount.id === C.id),
180
- externals: [O]
195
+ H("single-account", g.scenarios["single-account"], v, {
196
+ accounts: [S],
197
+ transfers: j.filter((e) => e.fromAccount.id === S.id || e.toAccount.id === S.id),
198
+ externals: [D]
181
199
  })
182
200
  ];
183
201
  //#endregion
184
- export { W as transfersScenarios };
202
+ export { J as transfersScenarios };