@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.
- package/README.md +2 -2
- package/dist/fixtures/index.d.ts +1 -1
- package/dist/index.d.ts +21 -14
- package/dist/lib/CounterpartsWidget.d.ts +16 -14
- package/dist/lib/CounterpartsWidgetPublic.d.ts +16 -14
- package/dist/lib/CustomersWidget.d.ts +16 -14
- package/dist/lib/TransfersWidget.d.ts +5 -0
- package/dist/lib/WidgetSuite.d.ts +5 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/fieldInput/formatPhoneNumberInput.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/mocks/bankAccounts.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartsWidget.js +30 -29
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/constants.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsTable.js +143 -95
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js +60 -48
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/mocks/labels.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index2.js +22 -15
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index3.js +137 -135
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +106 -108
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +50 -50
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +22 -22
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index3.js +6 -7
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index6.js +14 -34
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index7.js +16 -13
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index8.js +4 -10
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetInner.js +99 -75
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/featureLabels.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/useTransfersPageState.js +49 -0
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/mocks/labels.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/mocks/transfers.js +103 -85
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js +73 -61
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/labels.js +3 -0
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index7.js
CHANGED
|
@@ -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,
|
|
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([
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
}
|
package/dist/libs/tesouro-embedded-components-react/transfers-widget/data-access/dist/index8.js
CHANGED
|
@@ -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,
|
|
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(
|
|
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
|
|
18
|
-
import {
|
|
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
|
|
21
|
-
import { transfersWidgetTestIds as
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
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
|
|
26
|
-
import { jsx as
|
|
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
|
|
29
|
-
function
|
|
29
|
+
var g = [i.TransferWriteOrg, i.BankAccountReadOrg], _ = [t, e];
|
|
30
|
+
function v(e) {
|
|
30
31
|
return e.slice(-4);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
let
|
|
33
|
+
function y({ labels: e, featureLabels: t, isTransferMoneyOpen: y, defaultIsTransferMoneyOpen: le, onTransferMoneyOpenChange: ue }) {
|
|
34
|
+
let b = {
|
|
34
35
|
...o,
|
|
35
36
|
...t
|
|
36
|
-
},
|
|
37
|
-
...
|
|
37
|
+
}, x = {
|
|
38
|
+
...oe,
|
|
38
39
|
...e,
|
|
39
40
|
...t?.routeSeparator === void 0 ? {} : { listAccountsSeparator: t.routeSeparator }
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, [
|
|
44
|
-
let
|
|
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
|
|
47
|
-
let n =
|
|
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
|
|
51
|
-
let n =
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
]),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
]),
|
|
65
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
T,
|
|
91
|
+
L,
|
|
92
|
+
B,
|
|
93
|
+
N
|
|
71
94
|
]);
|
|
72
|
-
|
|
95
|
+
f(() => {
|
|
73
96
|
let e = () => {
|
|
74
|
-
|
|
97
|
+
X();
|
|
75
98
|
};
|
|
76
|
-
for (let t of
|
|
99
|
+
for (let t of _) window.addEventListener(t, e);
|
|
77
100
|
return () => {
|
|
78
|
-
for (let t of
|
|
101
|
+
for (let t of _) window.removeEventListener(t, e);
|
|
79
102
|
};
|
|
80
|
-
}, [
|
|
81
|
-
let { modalProps:
|
|
82
|
-
labels:
|
|
83
|
-
featureLabels:
|
|
84
|
-
embeddedBankAccounts:
|
|
85
|
-
verifiedExternalBankAccounts:
|
|
86
|
-
track:
|
|
87
|
-
isTransferMoneyOpen:
|
|
88
|
-
defaultIsTransferMoneyOpen:
|
|
89
|
-
onTransferMoneyOpenChange:
|
|
90
|
-
}),
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
-
transferRows:
|
|
93
|
-
|
|
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
|
|
96
|
-
showTransferMoneyCta:
|
|
119
|
+
onRetry: Q ? () => void X() : void 0,
|
|
120
|
+
showTransferMoneyCta: D,
|
|
97
121
|
isTransferMoneyCtaDisabled: $,
|
|
98
|
-
onTransferMoneyClick:
|
|
122
|
+
onTransferMoneyClick: D && !$ ? () => Z() : void 0,
|
|
99
123
|
transferMoneyModal: {
|
|
100
|
-
...
|
|
124
|
+
...ve,
|
|
101
125
|
testIds: {
|
|
102
|
-
root:
|
|
103
|
-
closeButton:
|
|
104
|
-
fromAccountTrigger:
|
|
105
|
-
toAccountTrigger:
|
|
106
|
-
accountsConfirm:
|
|
107
|
-
amountInput:
|
|
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:
|
|
110
|
-
goBack:
|
|
133
|
+
confirm: d.modalConfirmTransferButton,
|
|
134
|
+
goBack: d.modalGoBackButton
|
|
111
135
|
},
|
|
112
|
-
resultStep: { backToTransfers:
|
|
136
|
+
resultStep: { backToTransfers: d.modalBackToTransfersButton }
|
|
113
137
|
}
|
|
114
138
|
},
|
|
115
139
|
labels: e,
|
|
116
140
|
testIds: {
|
|
117
|
-
transferMoneyButton:
|
|
118
|
-
skeleton:
|
|
119
|
-
error:
|
|
120
|
-
retry:
|
|
121
|
-
empty:
|
|
122
|
-
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 {
|
|
151
|
+
export { y as TransfersWidgetInner };
|
|
@@ -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 };
|
package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/mocks/labels.js
CHANGED
|
@@ -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: "
|
|
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: {
|
package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/mocks/transfers.js
CHANGED
|
@@ -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,
|
|
6
|
-
import { failedRead as
|
|
7
|
-
import { TRANSFERS_LABELS as
|
|
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
|
|
10
|
-
...
|
|
9
|
+
var _ = [e.TransferWriteOrg, e.BankAccountReadOrg], v = [
|
|
10
|
+
..._,
|
|
11
11
|
e.ExternalBankAccountReadOrg,
|
|
12
12
|
e.PaymentRailAch
|
|
13
|
-
],
|
|
13
|
+
], y = [
|
|
14
14
|
e.BankAccountReadOrg,
|
|
15
15
|
e.ExternalBankAccountReadOrg,
|
|
16
16
|
e.PaymentRailAch
|
|
17
|
-
],
|
|
17
|
+
], b = (e) => `00000000-0000-4000-8000-0000000002${String(e).padStart(2, "0")}`, x = (e) => ({
|
|
18
18
|
currencyCode: "USD",
|
|
19
19
|
value: e
|
|
20
|
-
}),
|
|
20
|
+
}), S = n, C = {
|
|
21
21
|
...n,
|
|
22
|
-
id:
|
|
22
|
+
id: b(6),
|
|
23
23
|
accountNumber: "000000004006",
|
|
24
24
|
nickname: "Payroll",
|
|
25
|
-
balance:
|
|
26
|
-
},
|
|
25
|
+
balance: x(185e4)
|
|
26
|
+
}, w = {
|
|
27
27
|
...n,
|
|
28
|
-
id:
|
|
28
|
+
id: b(7),
|
|
29
29
|
accountNumber: "000000004007",
|
|
30
30
|
nickname: "Tax reserve",
|
|
31
|
-
balance:
|
|
32
|
-
},
|
|
31
|
+
balance: x(625050)
|
|
32
|
+
}, T = [
|
|
33
|
+
S,
|
|
33
34
|
C,
|
|
34
|
-
w
|
|
35
|
-
|
|
36
|
-
], D = t, O = {
|
|
35
|
+
w
|
|
36
|
+
], E = t, D = {
|
|
37
37
|
...t,
|
|
38
|
-
id:
|
|
38
|
+
id: b(8),
|
|
39
39
|
accountNumber: "••••••••4321",
|
|
40
40
|
nickname: "Supplier payouts",
|
|
41
41
|
verificationStatus: "UNVERIFIED"
|
|
42
|
-
},
|
|
42
|
+
}, O = [E, D], k = (e) => ({
|
|
43
43
|
id: e.id,
|
|
44
44
|
nickname: e.nickname ?? null
|
|
45
|
-
}),
|
|
45
|
+
}), A = (e, t) => ({
|
|
46
46
|
...r,
|
|
47
|
-
id:
|
|
47
|
+
id: b(e),
|
|
48
48
|
...t
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
fromAccount:
|
|
52
|
-
toAccount:
|
|
53
|
-
amount:
|
|
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
|
-
|
|
58
|
-
fromAccount:
|
|
59
|
-
toAccount:
|
|
60
|
-
amount:
|
|
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
|
-
|
|
66
|
-
fromAccount:
|
|
67
|
-
toAccount:
|
|
68
|
-
amount:
|
|
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
|
-
|
|
75
|
-
fromAccount:
|
|
76
|
-
toAccount:
|
|
77
|
-
amount:
|
|
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
|
-
|
|
81
|
-
fromAccount:
|
|
82
|
-
toAccount:
|
|
83
|
-
amount:
|
|
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
|
-
],
|
|
86
|
+
], M = (e) => ({
|
|
87
87
|
data: e,
|
|
88
88
|
nextPaginationToken: null,
|
|
89
89
|
prevPaginationToken: null
|
|
90
|
-
}),
|
|
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 =
|
|
94
|
-
},
|
|
95
|
-
await
|
|
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
|
|
105
|
+
if (!l(o) || !l(s) || !(u > 0)) return p(400, "Bad Request", "The transfer is not valid.");
|
|
98
106
|
a += 1;
|
|
99
|
-
let
|
|
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:
|
|
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:
|
|
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(
|
|
136
|
-
s(
|
|
137
|
-
|
|
138
|
-
u("POST", `${o}/money-movements/book`,
|
|
139
|
-
u("POST", `${o}/money-movements/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
|
-
},
|
|
142
|
-
accounts:
|
|
143
|
-
transfers:
|
|
144
|
-
externals:
|
|
145
|
-
},
|
|
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 ? [
|
|
151
|
-
...
|
|
158
|
+
...i ? [h(I)] : [],
|
|
159
|
+
...B(r)
|
|
152
160
|
]
|
|
153
|
-
}),
|
|
161
|
+
}), U = g.blurbs, W = (e) => ({
|
|
154
162
|
label: a[e].label,
|
|
155
|
-
blurb:
|
|
156
|
-
}), [
|
|
157
|
-
scopes:
|
|
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:
|
|
176
|
+
body: M(R),
|
|
177
|
+
pages: z(R)
|
|
161
178
|
},
|
|
162
|
-
supportRoutes: [s(
|
|
163
|
-
blurbs:
|
|
164
|
-
}, ["
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
...
|
|
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
|
-
...
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
178
|
-
accounts: [
|
|
179
|
-
transfers:
|
|
180
|
-
externals: [
|
|
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 {
|
|
202
|
+
export { J as transfersScenarios };
|