@tesouro/embedded-components-react 0.5.181 → 0.5.183
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 +32 -32
- package/dist/index.css +6 -0
- package/dist/index.d.ts +48 -20
- package/dist/index.js +2 -2
- package/dist/lib/BankAccountOnboardingWidget.d.ts +30 -1
- package/dist/lib/CreditCardsWidget.d.ts +9 -11
- package/dist/lib/CreditCardsWidget.js +1 -1
- package/dist/lib/DebitCardsWidget.d.ts +14 -15
- package/dist/lib/DebitCardsWidget.js +1 -1
- package/dist/lib/WidgetSuite.d.ts +43 -16
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index.js +5 -4
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index10.js +3 -32
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index11.js +24 -33
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index12.js +44 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index8.js +13 -36
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index9.js +43 -3
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index12.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index23.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index25.js +339 -301
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index27.js +11 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index28.js +64 -0
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index10.js +87 -8
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index11.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index12.js +17 -0
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index4.js +17 -24
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index5.js +23 -24
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index6.js +24 -30
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index7.js +28 -55
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js +53 -222
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +219 -87
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +34 -34
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +188 -181
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +162 -154
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShell.js +67 -55
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/labels.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index9.js +3 -3
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index3.js +0 -19
|
@@ -1,229 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { useAllBankAccountsQuery as e } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
|
|
6
|
-
import "../../../shared/data-access/dist/index.js";
|
|
7
|
-
import { useAnalyticsTrack as t } from "../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
8
|
-
import { useWidgetConfig as n, useWidgetError as ee, useWidgetLoading as te } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
|
-
import { CardProgram as r } from "../../../shared/feature/dist/lib/card/cardProgram.js";
|
|
1
|
+
import { CardProgram as e } from "../../../shared/feature/dist/lib/card/cardProgram.js";
|
|
2
|
+
import { CARD_STATUS_TONE as t } from "../../../shared/feature/dist/lib/card/cardPresentation.js";
|
|
10
3
|
import "../../../shared/feature/dist/index.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import { maskAccountNumber as ae } from "./index5.js";
|
|
15
|
-
import { CARD_COLUMNS_BY_PROGRAM as oe, toCardRows as se, toCreditCardListItems as ce, toDebitCardListItems as le } from "./index7.js";
|
|
16
|
-
import { useCreditCardsQuery as ue } from "../../data-access/dist/index2.js";
|
|
17
|
-
import { useDebitCardsQuery as de } from "../../data-access/dist/index3.js";
|
|
18
|
-
import "../../data-access/dist/index.js";
|
|
19
|
-
import { useCallback as i, useEffect as a, useMemo as o, useRef as fe, useState as s } from "react";
|
|
20
|
-
import { useControllableState as pe } from "@radix-ui/react-use-controllable-state";
|
|
4
|
+
import { formatCardLimit as n, withFallback as r } from "./index6.js";
|
|
5
|
+
import { CARD_COLUMN_KEYS as i } from "../../ui/dist/lib/CardsList/types.js";
|
|
6
|
+
import "../../ui/dist/index.js";
|
|
21
7
|
//#region ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
var a = "PENDING_ACTIVATION", o = {
|
|
9
|
+
[e.Credit]: i.filter((e) => e !== "fundingAccount" && e !== "limit"),
|
|
10
|
+
[e.Debit]: i.filter((e) => e !== "limit")
|
|
11
|
+
};
|
|
12
|
+
function s(e) {
|
|
13
|
+
return e.map((e) => ({
|
|
14
|
+
id: e.id,
|
|
15
|
+
userId: e.userId,
|
|
16
|
+
status: e.cardStatus,
|
|
17
|
+
type: e.cardType,
|
|
18
|
+
cardholderName: e.cardholderName,
|
|
19
|
+
nickname: e.nickname,
|
|
20
|
+
lastFourDigits: e.lastFourDigits,
|
|
21
|
+
limit: e.cardLimit,
|
|
22
|
+
limitCurrencyCode: e.currentBalance?.currencyCode
|
|
23
|
+
}));
|
|
29
24
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
function c(e) {
|
|
26
|
+
return e.map((e) => ({
|
|
27
|
+
id: e.id,
|
|
28
|
+
userId: e.userId,
|
|
29
|
+
status: e.cardStatus,
|
|
30
|
+
type: e.cardType,
|
|
31
|
+
cardholderName: e.cardholderName,
|
|
32
|
+
nickname: e.nickname,
|
|
33
|
+
lastFourDigits: e.lastFourDigits,
|
|
34
|
+
fundingAccountId: e.bankAccountId
|
|
35
|
+
}));
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
].join("\0"), O = d !== void 0, [k, A] = s(() => ({
|
|
58
|
-
resetKey: D,
|
|
59
|
-
paginationToken: C.paginationToken,
|
|
60
|
-
pageSize: C.pageSize
|
|
61
|
-
})), [Oe, j] = s(!1), [ke, M] = pe({
|
|
62
|
-
prop: ge,
|
|
63
|
-
defaultProp: _e ?? null,
|
|
64
|
-
onChange: ve,
|
|
65
|
-
caller: "CardsWidget"
|
|
66
|
-
}), N = fe({
|
|
67
|
-
cardProgram: c,
|
|
68
|
-
organizationId: T,
|
|
69
|
-
userId: w
|
|
70
|
-
}), Ae = N.current.cardProgram !== c || l(N.current.organizationId, T) || l(N.current.userId, w);
|
|
71
|
-
a(() => {
|
|
72
|
-
let e = N.current;
|
|
73
|
-
N.current = {
|
|
74
|
-
cardProgram: c,
|
|
75
|
-
organizationId: T,
|
|
76
|
-
userId: w
|
|
77
|
-
}, (e.cardProgram !== c || l(e.organizationId, T) || l(e.userId, w)) && (M(null), j(!1));
|
|
78
|
-
}, [
|
|
79
|
-
c,
|
|
80
|
-
T,
|
|
81
|
-
w,
|
|
82
|
-
M
|
|
83
|
-
]);
|
|
84
|
-
let P = i((e) => {
|
|
85
|
-
M(e);
|
|
86
|
-
}, [M]), F = Oe && !!v, je = k.resetKey === D;
|
|
87
|
-
a(() => {
|
|
88
|
-
O || A((e) => e.resetKey === D ? e : {
|
|
89
|
-
resetKey: D,
|
|
90
|
-
paginationToken: C.paginationToken,
|
|
91
|
-
pageSize: C.pageSize
|
|
92
|
-
});
|
|
93
|
-
}, [
|
|
94
|
-
C.pageSize,
|
|
95
|
-
C.paginationToken,
|
|
96
|
-
O,
|
|
97
|
-
D
|
|
98
|
-
]);
|
|
99
|
-
let I = O ? Te : je ? k : C, Me = I.paginationToken, L = I.pageSize, R = F ? v : void 0, z = {
|
|
100
|
-
limit: L,
|
|
101
|
-
paginationToken: Me
|
|
102
|
-
}, B = ue({
|
|
103
|
-
...z,
|
|
104
|
-
userId: R,
|
|
105
|
-
enabled: S && c === r.Credit
|
|
106
|
-
}), V = de({
|
|
107
|
-
...z,
|
|
108
|
-
cardholderUserId: R,
|
|
109
|
-
enabled: S && c === r.Debit
|
|
110
|
-
}), H = c === r.Credit ? B : V, U = S && x.canReadFundingAccounts, W = e({ enabled: U }), G = o(() => {
|
|
111
|
-
let e = /* @__PURE__ */ new Map();
|
|
112
|
-
if (!x.canReadFundingAccounts) return e;
|
|
113
|
-
for (let t of W.data?.data ?? []) {
|
|
114
|
-
let n = t.nickname?.trim();
|
|
115
|
-
e.set(t.id, n ? {
|
|
116
|
-
name: n,
|
|
117
|
-
lastFour: t.accountNumber?.trim().slice(-4) || void 0
|
|
118
|
-
} : { name: ae(t.accountNumber) ?? h.untitledFundingAccount });
|
|
119
|
-
}
|
|
120
|
-
return e;
|
|
121
|
-
}, [
|
|
122
|
-
W.data?.data,
|
|
123
|
-
h.untitledFundingAccount,
|
|
124
|
-
x.canReadFundingAccounts
|
|
125
|
-
]), K = U && W.isError, Ne = U && !K && (W.isLoading || W.isFetchingNextPage || !!W.hasNextPage), q = o(() => S ? c === r.Credit ? ce(B.data?.data ?? []) : le(V.data?.data ?? []) : [], [
|
|
126
|
-
S,
|
|
127
|
-
c,
|
|
128
|
-
B.data?.data,
|
|
129
|
-
V.data?.data
|
|
130
|
-
]), Pe = o(() => se(q, {
|
|
131
|
-
labels: h,
|
|
132
|
-
fundingAccountNames: G,
|
|
133
|
-
canActivate: x.canActivate,
|
|
134
|
-
onCardSelect: P,
|
|
135
|
-
onActivateCard: be
|
|
136
|
-
}), [
|
|
137
|
-
q,
|
|
138
|
-
G,
|
|
139
|
-
P,
|
|
140
|
-
h,
|
|
141
|
-
be,
|
|
142
|
-
x.canActivate
|
|
143
|
-
]), J = H.data?.nextPaginationToken ?? void 0, Y = H.data?.prevPaginationToken ?? void 0, Fe = !!H.data, Ie = S && (H.isError || K), [X, Le] = s({
|
|
144
|
-
key: E,
|
|
145
|
-
value: !1
|
|
37
|
+
function l(e, { labels: i, fundingAccountNames: o, canActivate: s, onCardSelect: c, onActivateCard: l }) {
|
|
38
|
+
return e.map((e) => {
|
|
39
|
+
let u = s && e.status === a, d = e.fundingAccountId ? o?.get(e.fundingAccountId) : void 0;
|
|
40
|
+
return {
|
|
41
|
+
key: e.id,
|
|
42
|
+
nickname: r(e.nickname, i.untitledCard),
|
|
43
|
+
lastFour: e.lastFourDigits,
|
|
44
|
+
typeLabel: i.cardType[e.type] ?? i.emptyValue,
|
|
45
|
+
fundingAccount: d?.name ?? i.emptyValue,
|
|
46
|
+
fundingAccountLastFour: d?.lastFour,
|
|
47
|
+
cardholder: r(e.cardholderName, i.emptyValue),
|
|
48
|
+
statusLabel: i.cardStatus[e.status] ?? i.emptyValue,
|
|
49
|
+
statusTone: t[e.status] ?? "neutral",
|
|
50
|
+
limit: n({
|
|
51
|
+
limit: e.limit,
|
|
52
|
+
currencyCode: e.limitCurrencyCode
|
|
53
|
+
}),
|
|
54
|
+
onSelect: c ? () => c(e.id) : void 0,
|
|
55
|
+
onActivate: u && l ? () => l(e.id) : void 0
|
|
56
|
+
};
|
|
146
57
|
});
|
|
147
|
-
if (S && !F && Fe) {
|
|
148
|
-
let e = X.key !== E, t = !!v && q.some((e) => e.userId !== v) || !e && X.value;
|
|
149
|
-
(e || X.value !== t) && Le({
|
|
150
|
-
key: E,
|
|
151
|
-
value: t
|
|
152
|
-
});
|
|
153
|
-
} else X.key !== E && Le({
|
|
154
|
-
key: E,
|
|
155
|
-
value: !1
|
|
156
|
-
});
|
|
157
|
-
let Re = X.value, Z = i((e) => {
|
|
158
|
-
O || A({
|
|
159
|
-
resetKey: D,
|
|
160
|
-
paginationToken: e.paginationToken,
|
|
161
|
-
pageSize: e.pageSize
|
|
162
|
-
}), p?.(e);
|
|
163
|
-
}, [
|
|
164
|
-
O,
|
|
165
|
-
p,
|
|
166
|
-
D
|
|
167
|
-
]), Q = i(() => {
|
|
168
|
-
Z({
|
|
169
|
-
paginationToken: void 0,
|
|
170
|
-
pageSize: L
|
|
171
|
-
});
|
|
172
|
-
}, [Z, L]), ze = i((e) => {
|
|
173
|
-
Z({
|
|
174
|
-
paginationToken: void 0,
|
|
175
|
-
pageSize: e
|
|
176
|
-
});
|
|
177
|
-
}, [Z]), Be = i((e) => {
|
|
178
|
-
j(e), Q();
|
|
179
|
-
}, [Q]), Ve = i(() => {
|
|
180
|
-
Z({
|
|
181
|
-
paginationToken: Y,
|
|
182
|
-
pageSize: L
|
|
183
|
-
});
|
|
184
|
-
}, [
|
|
185
|
-
Z,
|
|
186
|
-
L,
|
|
187
|
-
Y
|
|
188
|
-
]), He = i(() => {
|
|
189
|
-
Z({
|
|
190
|
-
paginationToken: J,
|
|
191
|
-
pageSize: L
|
|
192
|
-
});
|
|
193
|
-
}, [
|
|
194
|
-
Z,
|
|
195
|
-
J,
|
|
196
|
-
L
|
|
197
|
-
]), Ue = H.refetch, $ = W.refetch, We = i(() => {
|
|
198
|
-
Ue(), U && $();
|
|
199
|
-
}, [
|
|
200
|
-
U,
|
|
201
|
-
Ue,
|
|
202
|
-
$
|
|
203
|
-
]);
|
|
204
|
-
return {
|
|
205
|
-
rows: Pe,
|
|
206
|
-
selectedCardId: Ae ? null : ke,
|
|
207
|
-
onSelectCard: P,
|
|
208
|
-
canReadCards: x.canRead,
|
|
209
|
-
columns: oe[c],
|
|
210
|
-
isLoading: !y && (!b || we && !_ || S && (H.isLoading || Ne)),
|
|
211
|
-
isError: y || Ie,
|
|
212
|
-
canToggleShowMyCards: x.canRead && !!v && Re,
|
|
213
|
-
isShowingMyCards: F,
|
|
214
|
-
onShowMyCardsChange: Be,
|
|
215
|
-
canCreateCard: x.canCreate && (!!ye || !!xe && x.canComposeDebitCreate),
|
|
216
|
-
onCreateCardClick: ye,
|
|
217
|
-
onRetry: We,
|
|
218
|
-
isPaginationVisible: S && Fe && !Ie,
|
|
219
|
-
pageSize: L,
|
|
220
|
-
pageSizeOptions: me,
|
|
221
|
-
isPreviousPageDisabled: !Y,
|
|
222
|
-
isNextPageDisabled: !J,
|
|
223
|
-
onPageSizeChange: ze,
|
|
224
|
-
onPreviousPageClick: Ve,
|
|
225
|
-
onNextPageClick: He
|
|
226
|
-
};
|
|
227
58
|
}
|
|
228
59
|
//#endregion
|
|
229
|
-
export {
|
|
60
|
+
export { o as CARD_COLUMNS_BY_PROGRAM, l as toCardRows, s as toCreditCardListItems, c as toDebitCardListItems };
|
|
@@ -2,96 +2,228 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
5
|
+
import { useAllBankAccountsQuery as e } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
|
|
6
|
+
import "../../../shared/data-access/dist/index.js";
|
|
7
|
+
import { useAnalyticsTrack as t } from "../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
8
|
+
import { useWidgetConfig as n, useWidgetError as ee, useWidgetLoading as te } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
|
+
import { CardProgram as r } from "../../../shared/feature/dist/lib/card/cardProgram.js";
|
|
6
10
|
import "../../../shared/feature/dist/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import "../../
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import "
|
|
16
|
-
import {
|
|
17
|
-
import "../../create-card/feature/dist/index.js";
|
|
18
|
-
import { useCallback as u, useMemo as d, useState as f } from "react";
|
|
19
|
-
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
11
|
+
import { resolveCardsFeatureLabels as ne } from "./index5.js";
|
|
12
|
+
import { getCardsPermissions as re } from "./index7.js";
|
|
13
|
+
import { CardsWidgetAnalyticsEvent as ie } from "./index2.js";
|
|
14
|
+
import { maskAccountNumber as ae } from "./index6.js";
|
|
15
|
+
import { CARD_COLUMNS_BY_PROGRAM as oe, toCardRows as se, toCreditCardListItems as ce, toDebitCardListItems as le } from "./index8.js";
|
|
16
|
+
import { useCreditCardsQuery as ue } from "../../data-access/dist/index2.js";
|
|
17
|
+
import { useDebitCardsQuery as de } from "../../data-access/dist/index3.js";
|
|
18
|
+
import "../../data-access/dist/index.js";
|
|
19
|
+
import { useCallback as i, useEffect as a, useMemo as o, useRef as fe, useState as s } from "react";
|
|
20
|
+
import { useControllableState as pe } from "@radix-ui/react-use-controllable-state";
|
|
20
21
|
//#region ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
selectedCardId: b,
|
|
29
|
-
defaultSelectedCardId: x,
|
|
30
|
-
onSelectedCardIdChange: S,
|
|
31
|
-
onCreateCard: j,
|
|
32
|
-
onActivateCard: M,
|
|
33
|
-
cardArtSrc: O
|
|
34
|
-
}), z = d(() => i(v), [v]), [B, V] = f(!1), [H, U] = f(0), [W, G] = f(N), [K, q] = f(null), J = u(() => {
|
|
35
|
-
N !== null && P(null), U((e) => e + 1), V(!0);
|
|
36
|
-
}, [N, P]), Y = u(() => {
|
|
37
|
-
V(!1), N !== null && P(null);
|
|
38
|
-
}, [N, P]), X = u((e) => {
|
|
39
|
-
V(!1), P(e);
|
|
40
|
-
}, [P]), Z = e === "debit" && !!O && !!I && F === void 0, Q = B && N === null && Z;
|
|
41
|
-
B && (N !== null || !Z) && V(!1), Q ? K !== "create" && q("create") : N !== null && (K !== "details" && q("details"), N !== W && G(N));
|
|
42
|
-
let $ = K === "create", te = N !== null || Q;
|
|
43
|
-
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(a, {
|
|
44
|
-
...R,
|
|
45
|
-
canCreateCard: I,
|
|
46
|
-
onCreateCardClick: F ?? J,
|
|
47
|
-
headerStart: ee,
|
|
48
|
-
labels: z,
|
|
49
|
-
testIds: r
|
|
50
|
-
}), /* @__PURE__ */ m(o, {
|
|
51
|
-
isOpen: te,
|
|
52
|
-
labels: $ ? z.createSheet : z.detailsSheet,
|
|
53
|
-
contentClassName: $ ? "ttw:overflow-hidden ttw:p-0 ttw:min-h-0" : void 0,
|
|
54
|
-
onClose: Y,
|
|
55
|
-
testIds: n,
|
|
56
|
-
children: $ && Z && O ? /* @__PURE__ */ m(l, {
|
|
57
|
-
cardArtSrc: O,
|
|
58
|
-
labels: k,
|
|
59
|
-
featureLabels: A,
|
|
60
|
-
onClose: Y,
|
|
61
|
-
onCancel: Y,
|
|
62
|
-
onViewCard: L ? X : void 0,
|
|
63
|
-
className: "ttw:min-h-0 ttw:flex-1"
|
|
64
|
-
}, H) : W === null ? null : /* @__PURE__ */ m(c, {
|
|
65
|
-
cardId: W,
|
|
66
|
-
cardProgram: e,
|
|
67
|
-
labels: C,
|
|
68
|
-
activateLabels: T,
|
|
69
|
-
featureLabels: w,
|
|
70
|
-
cardArtSrc: O,
|
|
71
|
-
bankLogoSrc: E,
|
|
72
|
-
bankLogoAlt: D,
|
|
73
|
-
onClose: Y
|
|
74
|
-
}, W)
|
|
75
|
-
})] });
|
|
22
|
+
var me = [
|
|
23
|
+
10,
|
|
24
|
+
25,
|
|
25
|
+
50
|
|
26
|
+
], c = 10, he = "<none>";
|
|
27
|
+
function l(e, t) {
|
|
28
|
+
return e !== void 0 && t !== void 0 && e !== t;
|
|
76
29
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
30
|
+
function u(e) {
|
|
31
|
+
let t = Number.isInteger(e?.pageSize) && Number(e?.pageSize) > 0 ? Number(e?.pageSize) : c;
|
|
32
|
+
return {
|
|
33
|
+
paginationToken: e?.paginationToken,
|
|
34
|
+
pageSize: t
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function d({ cardProgram: c, pagination: d, defaultPagination: f, onPaginationChange: ge, featureLabels: p, selectedCardId: _e, defaultSelectedCardId: ve, onSelectedCardIdChange: ye, onCreateCard: m, onActivateCard: be }) {
|
|
38
|
+
let h = o(() => ne(p), [p]), g = t();
|
|
39
|
+
a(() => {
|
|
40
|
+
g(ie.Mounted);
|
|
41
|
+
}, [g]);
|
|
42
|
+
let { organizationId: _, widgetToken: xe, initResponse: v } = n(), y = v?.userId ?? void 0, Se = te(), b = !!ee(), x = !!(_ && xe), S = o(() => re({
|
|
43
|
+
cardProgram: c,
|
|
44
|
+
scopes: v?.scopes
|
|
45
|
+
}), [c, v?.scopes]), C = x && S.canRead && !!v, Ce = o(() => u(d), [d?.pageSize, d?.paginationToken]), w = o(() => u(f), [f?.pageSize, f?.paginationToken]), [T, we] = s(y);
|
|
46
|
+
y !== void 0 && y !== T && we(y);
|
|
47
|
+
let [E, Te] = s(_);
|
|
48
|
+
_ !== void 0 && _ !== E && Te(_);
|
|
49
|
+
let D = [
|
|
50
|
+
c,
|
|
51
|
+
E === null ? he : E ?? "",
|
|
52
|
+
T ?? ""
|
|
53
|
+
].join("\0"), O = [
|
|
54
|
+
D,
|
|
55
|
+
w.paginationToken ?? "",
|
|
56
|
+
w.pageSize
|
|
57
|
+
].join("\0"), k = d !== void 0, [A, j] = s(() => ({
|
|
58
|
+
resetKey: O,
|
|
59
|
+
paginationToken: w.paginationToken,
|
|
60
|
+
pageSize: w.pageSize
|
|
61
|
+
})), [Ee, M] = s(!1), [De, N] = pe({
|
|
62
|
+
prop: _e,
|
|
63
|
+
defaultProp: ve ?? null,
|
|
64
|
+
onChange: ye,
|
|
65
|
+
caller: "CardsWidget"
|
|
66
|
+
}), P = fe({
|
|
67
|
+
cardProgram: c,
|
|
68
|
+
organizationId: E,
|
|
69
|
+
userId: T
|
|
70
|
+
}), Oe = P.current.cardProgram !== c || l(P.current.organizationId, E) || l(P.current.userId, T);
|
|
71
|
+
a(() => {
|
|
72
|
+
let e = P.current;
|
|
73
|
+
P.current = {
|
|
74
|
+
cardProgram: c,
|
|
75
|
+
organizationId: E,
|
|
76
|
+
userId: T
|
|
77
|
+
}, (e.cardProgram !== c || l(e.organizationId, E) || l(e.userId, T)) && (N(null), M(!1));
|
|
78
|
+
}, [
|
|
79
|
+
c,
|
|
80
|
+
E,
|
|
81
|
+
T,
|
|
82
|
+
N
|
|
83
|
+
]);
|
|
84
|
+
let F = i((e) => {
|
|
85
|
+
N(e);
|
|
86
|
+
}, [N]), I = Ee && !!y, ke = A.resetKey === O;
|
|
87
|
+
a(() => {
|
|
88
|
+
k || j((e) => e.resetKey === O ? e : {
|
|
89
|
+
resetKey: O,
|
|
90
|
+
paginationToken: w.paginationToken,
|
|
91
|
+
pageSize: w.pageSize
|
|
92
|
+
});
|
|
93
|
+
}, [
|
|
94
|
+
w.pageSize,
|
|
95
|
+
w.paginationToken,
|
|
96
|
+
k,
|
|
97
|
+
O
|
|
98
|
+
]);
|
|
99
|
+
let L = k ? Ce : ke ? A : w, Ae = L.paginationToken, R = L.pageSize, z = I ? y : void 0, B = {
|
|
100
|
+
limit: R,
|
|
101
|
+
paginationToken: Ae
|
|
102
|
+
}, V = ue({
|
|
103
|
+
...B,
|
|
104
|
+
userId: z,
|
|
105
|
+
enabled: C && c === r.Credit
|
|
106
|
+
}), H = de({
|
|
107
|
+
...B,
|
|
108
|
+
cardholderUserId: z,
|
|
109
|
+
enabled: C && c === r.Debit
|
|
110
|
+
}), U = c === r.Credit ? V : H, W = C && S.canReadFundingAccounts, G = e({ enabled: W }), K = o(() => {
|
|
111
|
+
let e = /* @__PURE__ */ new Map();
|
|
112
|
+
if (!S.canReadFundingAccounts) return e;
|
|
113
|
+
for (let t of G.data?.data ?? []) {
|
|
114
|
+
let n = t.nickname?.trim();
|
|
115
|
+
e.set(t.id, n ? {
|
|
116
|
+
name: n,
|
|
117
|
+
lastFour: t.accountNumber?.trim().slice(-4) || void 0
|
|
118
|
+
} : { name: ae(t.accountNumber) ?? h.untitledFundingAccount });
|
|
119
|
+
}
|
|
120
|
+
return e;
|
|
121
|
+
}, [
|
|
122
|
+
G.data?.data,
|
|
123
|
+
h.untitledFundingAccount,
|
|
124
|
+
S.canReadFundingAccounts
|
|
125
|
+
]), q = W && G.isError, je = W && !q && (G.isLoading || G.isFetchingNextPage || !!G.hasNextPage), J = o(() => C ? c === r.Credit ? ce(V.data?.data ?? []) : le(H.data?.data ?? []) : [], [
|
|
126
|
+
C,
|
|
127
|
+
c,
|
|
128
|
+
V.data?.data,
|
|
129
|
+
H.data?.data
|
|
130
|
+
]), Me = o(() => se(J, {
|
|
131
|
+
labels: h,
|
|
132
|
+
fundingAccountNames: K,
|
|
133
|
+
canActivate: S.canActivate,
|
|
134
|
+
onCardSelect: F,
|
|
135
|
+
onActivateCard: be
|
|
136
|
+
}), [
|
|
137
|
+
J,
|
|
138
|
+
K,
|
|
139
|
+
F,
|
|
140
|
+
h,
|
|
141
|
+
be,
|
|
142
|
+
S.canActivate
|
|
143
|
+
]), Y = U.data?.nextPaginationToken ?? void 0, X = U.data?.prevPaginationToken ?? void 0, Z = !!U.data, Ne = C && (U.isError || q), [Q, Pe] = s({
|
|
144
|
+
key: D,
|
|
145
|
+
value: !1
|
|
146
|
+
});
|
|
147
|
+
if (C && !I && Z) {
|
|
148
|
+
let e = Q.key !== D, t = !!y && J.some((e) => e.userId !== y) || !e && Q.value;
|
|
149
|
+
(e || Q.value !== t) && Pe({
|
|
150
|
+
key: D,
|
|
151
|
+
value: t
|
|
152
|
+
});
|
|
153
|
+
} else Q.key !== D && Pe({
|
|
154
|
+
key: D,
|
|
155
|
+
value: !1
|
|
94
156
|
});
|
|
157
|
+
let Fe = Q.value, $ = i((e) => {
|
|
158
|
+
k || j({
|
|
159
|
+
resetKey: O,
|
|
160
|
+
paginationToken: e.paginationToken,
|
|
161
|
+
pageSize: e.pageSize
|
|
162
|
+
}), ge?.(e);
|
|
163
|
+
}, [
|
|
164
|
+
k,
|
|
165
|
+
ge,
|
|
166
|
+
O
|
|
167
|
+
]), Ie = i(() => {
|
|
168
|
+
$({
|
|
169
|
+
paginationToken: void 0,
|
|
170
|
+
pageSize: R
|
|
171
|
+
});
|
|
172
|
+
}, [$, R]), Le = i((e) => {
|
|
173
|
+
$({
|
|
174
|
+
paginationToken: void 0,
|
|
175
|
+
pageSize: e
|
|
176
|
+
});
|
|
177
|
+
}, [$]), Re = i((e) => {
|
|
178
|
+
M(e), Ie();
|
|
179
|
+
}, [Ie]), ze = i(() => {
|
|
180
|
+
$({
|
|
181
|
+
paginationToken: X,
|
|
182
|
+
pageSize: R
|
|
183
|
+
});
|
|
184
|
+
}, [
|
|
185
|
+
$,
|
|
186
|
+
R,
|
|
187
|
+
X
|
|
188
|
+
]), Be = i(() => {
|
|
189
|
+
$({
|
|
190
|
+
paginationToken: Y,
|
|
191
|
+
pageSize: R
|
|
192
|
+
});
|
|
193
|
+
}, [
|
|
194
|
+
$,
|
|
195
|
+
Y,
|
|
196
|
+
R
|
|
197
|
+
]), Ve = U.refetch, He = G.refetch, Ue = i(() => {
|
|
198
|
+
Ve(), W && He();
|
|
199
|
+
}, [
|
|
200
|
+
W,
|
|
201
|
+
Ve,
|
|
202
|
+
He
|
|
203
|
+
]);
|
|
204
|
+
return {
|
|
205
|
+
rows: Me,
|
|
206
|
+
selectedCardId: Oe ? null : De,
|
|
207
|
+
onSelectCard: F,
|
|
208
|
+
canReadCards: S.canRead,
|
|
209
|
+
columns: oe[c],
|
|
210
|
+
isLoading: !b && (!x || Se && !v || C && (U.isLoading || je)),
|
|
211
|
+
isError: b || Ne,
|
|
212
|
+
canToggleShowMyCards: S.canRead && !!y && Fe,
|
|
213
|
+
isShowingMyCards: I,
|
|
214
|
+
onShowMyCardsChange: Re,
|
|
215
|
+
canCreateCard: S.canCreate && (!!m || S.canComposeDebitCreate),
|
|
216
|
+
onCreateCardClick: m,
|
|
217
|
+
onRetry: Ue,
|
|
218
|
+
isPaginationVisible: C && Z && !Ne,
|
|
219
|
+
pageSize: R,
|
|
220
|
+
pageSizeOptions: me,
|
|
221
|
+
isPreviousPageDisabled: !X,
|
|
222
|
+
isNextPageDisabled: !Y,
|
|
223
|
+
onPageSizeChange: Le,
|
|
224
|
+
onPreviousPageClick: ze,
|
|
225
|
+
onNextPageClick: Be
|
|
226
|
+
};
|
|
95
227
|
}
|
|
96
228
|
//#endregion
|
|
97
|
-
export {
|
|
229
|
+
export { d as useCardsWidget };
|