@tesouro/embedded-components-react 0.9.43 → 0.9.45
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/dist/experimental/ApprovalRequests.d.ts +10 -2
- package/dist/experimental/index.d.ts +10 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js +67 -57
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/labels.js +6 -1
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js +72 -54
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index9.js +159 -158
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/feature/dist/index3.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/feature/dist/index4.js +57 -52
- 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/feature/dist/lib/analytics/expectedApiUnprocessable.js +7 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/interceptor.js +41 -38
- package/package.json +1 -1
|
@@ -680,11 +680,19 @@ interface ApprovalRequestsListLabels {
|
|
|
680
680
|
status: Record<ApprovalRequestStatus, string>;
|
|
681
681
|
filters: ApprovalRequestsFilterLabels;
|
|
682
682
|
}
|
|
683
|
+
/** Toast copy for approve and reject; the error copy is the fallback when the API gives no reason. */
|
|
684
|
+
interface ApprovalRequestsMessageLabels {
|
|
685
|
+
approved: string;
|
|
686
|
+
rejected: string;
|
|
687
|
+
approveError: string;
|
|
688
|
+
rejectError: string;
|
|
689
|
+
}
|
|
683
690
|
|
|
684
691
|
interface ApprovalRequestsWidgetOwnProps {
|
|
685
692
|
screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
|
|
686
693
|
listLabels?: PartialDeep<ApprovalRequestsListLabels>;
|
|
687
|
-
rejectDialogLabels?:
|
|
694
|
+
rejectDialogLabels?: PartialDeep<RejectApprovalRequestDialogLabels>;
|
|
695
|
+
messageLabels?: PartialDeep<ApprovalRequestsMessageLabels>;
|
|
688
696
|
}
|
|
689
697
|
/** Public props for {@link ApprovalRequestsWidget}. */
|
|
690
698
|
type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
|
|
@@ -692,7 +700,7 @@ type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetO
|
|
|
692
700
|
* Self-contained approval requests widget, a native port of Monite's approval
|
|
693
701
|
* requests (FOPS-97). Exported only from the package's `/experimental` entry.
|
|
694
702
|
*/
|
|
695
|
-
declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
|
|
703
|
+
declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, messageLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
|
|
696
704
|
|
|
697
705
|
export { ApprovalRequestsWidget };
|
|
698
706
|
export type { ApprovalRequestsWidgetProps };
|
|
@@ -680,11 +680,19 @@ interface ApprovalRequestsListLabels {
|
|
|
680
680
|
status: Record<ApprovalRequestStatus, string>;
|
|
681
681
|
filters: ApprovalRequestsFilterLabels;
|
|
682
682
|
}
|
|
683
|
+
/** Toast copy for approve and reject; the error copy is the fallback when the API gives no reason. */
|
|
684
|
+
interface ApprovalRequestsMessageLabels {
|
|
685
|
+
approved: string;
|
|
686
|
+
rejected: string;
|
|
687
|
+
approveError: string;
|
|
688
|
+
rejectError: string;
|
|
689
|
+
}
|
|
683
690
|
|
|
684
691
|
interface ApprovalRequestsWidgetOwnProps {
|
|
685
692
|
screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
|
|
686
693
|
listLabels?: PartialDeep<ApprovalRequestsListLabels>;
|
|
687
|
-
rejectDialogLabels?:
|
|
694
|
+
rejectDialogLabels?: PartialDeep<RejectApprovalRequestDialogLabels>;
|
|
695
|
+
messageLabels?: PartialDeep<ApprovalRequestsMessageLabels>;
|
|
688
696
|
}
|
|
689
697
|
/** Public props for {@link ApprovalRequestsWidget}. */
|
|
690
698
|
type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
|
|
@@ -692,7 +700,7 @@ type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetO
|
|
|
692
700
|
* Self-contained approval requests widget, a native port of Monite's approval
|
|
693
701
|
* requests (FOPS-97). Exported only from the package's `/experimental` entry.
|
|
694
702
|
*/
|
|
695
|
-
declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
|
|
703
|
+
declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, messageLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
|
|
696
704
|
|
|
697
705
|
interface CheckAmountAndDetailScreenLabels {
|
|
698
706
|
title: string;
|
|
@@ -5,76 +5,86 @@
|
|
|
5
5
|
import { isOrganizationOnItsWay as e } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
|
|
6
6
|
import { useEmbedApi as t } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
7
7
|
import "../../../../../shared/data-access/dist/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
8
|
+
import { EmbeddedToaster as n } from "../../../../../shared/ui/dist/lib/EmbeddedToaster.js";
|
|
9
|
+
import "../../../../../shared/ui/dist/index.js";
|
|
10
|
+
import { useAnalyticsTrack as r } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
11
|
+
import { WidgetProvider as i } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
12
|
+
import { useRefetchWidget as a, useWidgetConfig as o, useWidgetError as s, useWidgetInitStaleForToken as c, useWidgetLoading as l } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
11
13
|
import "../../../../../shared/feature/dist/index.js";
|
|
12
|
-
import { ApprovalRequestsWidgetAnalyticsEvent as
|
|
13
|
-
import { APPROVAL_REQUESTS_LIST_LABELS_EN as
|
|
14
|
-
import { getApprovalRequestPermissions as
|
|
15
|
-
import { useApprovalRequestDecisions as
|
|
16
|
-
import { ApprovalRequestsScreen as
|
|
17
|
-
import { RejectApprovalRequestDialog as
|
|
14
|
+
import { ApprovalRequestsWidgetAnalyticsEvent as u, WIDGET_NAME as d } from "../analytics/events.js";
|
|
15
|
+
import { APPROVAL_REQUESTS_LIST_LABELS_EN as f, APPROVAL_REQUESTS_MESSAGE_LABELS_EN as p } from "./labels.js";
|
|
16
|
+
import { getApprovalRequestPermissions as m } from "./permissions.js";
|
|
17
|
+
import { useApprovalRequestDecisions as h } from "./useApprovalRequestDecisions.js";
|
|
18
|
+
import { ApprovalRequestsScreen as g } from "../../../../ui/dist/index4.js";
|
|
19
|
+
import { RejectApprovalRequestDialog as _ } from "../../../../ui/dist/index5.js";
|
|
18
20
|
import "../../../../ui/dist/index.js";
|
|
19
|
-
import { useApprovalRequestsTable as
|
|
20
|
-
import { useEffect as
|
|
21
|
-
import { Fragment as
|
|
21
|
+
import { useApprovalRequestsTable as v } from "./useApprovalRequestsTable.js";
|
|
22
|
+
import { useEffect as y, useMemo as b } from "react";
|
|
23
|
+
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
22
24
|
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js
|
|
23
|
-
function
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
let
|
|
25
|
+
function w({ screenLabels: i, listLabels: d, rejectDialogLabels: w, messageLabels: T }) {
|
|
26
|
+
let E = r();
|
|
27
|
+
y(() => {
|
|
28
|
+
E(u.Mounted);
|
|
29
|
+
}, [E]);
|
|
30
|
+
let D = b(() => ({
|
|
31
|
+
...f,
|
|
29
32
|
...d,
|
|
30
|
-
...u,
|
|
31
33
|
status: {
|
|
32
|
-
...
|
|
33
|
-
...
|
|
34
|
+
...f.status,
|
|
35
|
+
...d?.status
|
|
34
36
|
},
|
|
35
37
|
filters: {
|
|
36
|
-
...
|
|
37
|
-
...
|
|
38
|
+
...f.filters,
|
|
39
|
+
...d?.filters
|
|
38
40
|
}
|
|
39
|
-
}), [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
}), [d]), { initResponse: O, widgetToken: k } = o(), A = l(), j = s(), M = c(), N = a(), { organizationStatus: P } = t(), F = b(() => m(M ? void 0 : O?.scopes), [M, O?.scopes]), I = !(!k || O || j) || A && !O || M, L = !!j && (!O || M), R = b(() => ({
|
|
42
|
+
...p,
|
|
43
|
+
...T
|
|
44
|
+
}), [T]), z = h({ messages: R }), B = v({
|
|
45
|
+
labels: D,
|
|
46
|
+
enabled: F.canRead,
|
|
47
|
+
pendingRequestIds: z.pendingRequestIds,
|
|
48
|
+
areDecisionsPaused: z.areDecisionsPaused
|
|
44
49
|
});
|
|
45
|
-
return /* @__PURE__ */ x
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
50
|
+
return /* @__PURE__ */ C(x, { children: [
|
|
51
|
+
/* @__PURE__ */ S(n, {}),
|
|
52
|
+
/* @__PURE__ */ S(g, {
|
|
53
|
+
rows: B.rows,
|
|
54
|
+
isLoading: B.isLoading || (I || e(P)) && B.rows.length === 0,
|
|
55
|
+
isError: L || B.isError,
|
|
56
|
+
isAccessRestricted: !I && !L && !F.canRead,
|
|
57
|
+
pageSize: B.pageSize,
|
|
58
|
+
onPageSizeChange: B.onPageSizeChange,
|
|
59
|
+
pageSizeOptions: B.pageSizeOptions,
|
|
60
|
+
hasNextPage: B.hasNextPage,
|
|
61
|
+
hasPrevPage: B.hasPrevPage,
|
|
62
|
+
onNextPage: B.onNextPage,
|
|
63
|
+
onPrevPage: B.onPrevPage,
|
|
64
|
+
emptyState: B.emptyState,
|
|
65
|
+
filters: B.filters,
|
|
66
|
+
onRetry: L ? N : B.onRetry,
|
|
67
|
+
onApprove: z.onApprove,
|
|
68
|
+
onReject: z.onReject,
|
|
69
|
+
labels: i
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ S(_, {
|
|
72
|
+
...z.rejectDialog,
|
|
73
|
+
labels: w
|
|
74
|
+
})
|
|
75
|
+
] });
|
|
67
76
|
}
|
|
68
|
-
function
|
|
69
|
-
return /* @__PURE__ */
|
|
70
|
-
...
|
|
71
|
-
widgetName:
|
|
72
|
-
children: /* @__PURE__ */
|
|
77
|
+
function T({ screenLabels: e, listLabels: t, rejectDialogLabels: n, messageLabels: r, ...a }) {
|
|
78
|
+
return /* @__PURE__ */ S(i, {
|
|
79
|
+
...a,
|
|
80
|
+
widgetName: d,
|
|
81
|
+
children: /* @__PURE__ */ S(w, {
|
|
73
82
|
screenLabels: e,
|
|
74
83
|
listLabels: t,
|
|
75
|
-
rejectDialogLabels: n
|
|
84
|
+
rejectDialogLabels: n,
|
|
85
|
+
messageLabels: r
|
|
76
86
|
})
|
|
77
87
|
});
|
|
78
88
|
}
|
|
79
89
|
//#endregion
|
|
80
|
-
export {
|
|
90
|
+
export { T as ApprovalRequestsWidget, T as default };
|
|
@@ -19,6 +19,11 @@ var e = {
|
|
|
19
19
|
moreSelected: (e, t) => `${e} + ${t} more`,
|
|
20
20
|
dateRange: (e, t) => `${e} - ${t}`
|
|
21
21
|
}
|
|
22
|
+
}, t = {
|
|
23
|
+
approved: "Request was approved",
|
|
24
|
+
rejected: "Request was rejected",
|
|
25
|
+
approveError: "Couldn't approve the request. Try again.",
|
|
26
|
+
rejectError: "Couldn't reject the request. Try again."
|
|
22
27
|
};
|
|
23
28
|
//#endregion
|
|
24
|
-
export { e as APPROVAL_REQUESTS_LIST_LABELS_EN };
|
|
29
|
+
export { e as APPROVAL_REQUESTS_LIST_LABELS_EN, t as APPROVAL_REQUESTS_MESSAGE_LABELS_EN };
|
|
@@ -2,75 +2,93 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
+
import "../../../../../shared/util/dist/index.js";
|
|
8
|
+
import { isOrganizationOnItsWay as n } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
|
|
9
|
+
import { useEmbedApi as r } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
7
10
|
import "../../../../../shared/data-access/dist/index.js";
|
|
8
|
-
import
|
|
11
|
+
import "../../../../../shared/ui/dist/index.js";
|
|
12
|
+
import { useWidgetConfig as i, useWidgetInitStaleForToken as a } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
13
|
import "../../../../../shared/feature/dist/index.js";
|
|
10
|
-
import { useApproveApprovalRequestMutation as
|
|
11
|
-
import { useRejectApprovalRequestMutation as
|
|
14
|
+
import { useApproveApprovalRequestMutation as o } from "../../../../data-access/dist/index4.js";
|
|
15
|
+
import { useRejectApprovalRequestMutation as s } from "../../../../data-access/dist/index5.js";
|
|
12
16
|
import "../../../../data-access/dist/index.js";
|
|
13
|
-
import { useCallback as
|
|
17
|
+
import { useCallback as c, useState as l } from "react";
|
|
14
18
|
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
let { mutateAsync:
|
|
18
|
-
client:
|
|
19
|
-
organizationId:
|
|
20
|
-
userId:
|
|
19
|
+
var u = /* @__PURE__ */ new Set();
|
|
20
|
+
function d({ messages: d }) {
|
|
21
|
+
let { mutateAsync: f } = o(), { mutateAsync: p } = s(), [m, h] = l(u), [g, _] = l(), [v, y] = l(""), { client: b, organizationId: x, organizationStatus: S } = r(), C = a(), w = n(S) || C, T = i().initResponse?.userId, E = C ? void 0 : T, [D, O] = l({
|
|
22
|
+
client: b,
|
|
23
|
+
organizationId: x,
|
|
24
|
+
userId: E
|
|
21
25
|
});
|
|
22
|
-
(
|
|
23
|
-
client:
|
|
24
|
-
organizationId:
|
|
25
|
-
userId:
|
|
26
|
-
}),
|
|
27
|
-
let
|
|
28
|
-
|
|
26
|
+
(b !== D.client || x !== void 0 && x !== D.organizationId || E !== void 0 && E !== D.userId) && (O({
|
|
27
|
+
client: b,
|
|
28
|
+
organizationId: x === void 0 ? D.organizationId : x,
|
|
29
|
+
userId: E === void 0 ? D.userId : E
|
|
30
|
+
}), _(void 0));
|
|
31
|
+
let k = c(async (n, { decide: r, successMessage: i, errorFallback: a }) => {
|
|
32
|
+
h((e) => new Set(e).add(n));
|
|
29
33
|
try {
|
|
30
|
-
return await
|
|
31
|
-
} catch {
|
|
32
|
-
return !1;
|
|
34
|
+
return await r(), e.success(i), !0;
|
|
35
|
+
} catch (n) {
|
|
36
|
+
return e.error(t(n) ?? a), !1;
|
|
33
37
|
} finally {
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
return
|
|
38
|
+
h((e) => {
|
|
39
|
+
let t = new Set(e);
|
|
40
|
+
return t.delete(n), t;
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
|
-
}, []),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
p && !x && E(p, () => u({
|
|
45
|
-
approvalRequestId: p,
|
|
46
|
-
rejectReason: h
|
|
47
|
-
})).then((e) => {
|
|
48
|
-
e && m((e) => e === p ? void 0 : e);
|
|
43
|
+
}, []), A = c((e) => {
|
|
44
|
+
w || k(e, {
|
|
45
|
+
decide: () => f({ approvalRequestId: e }),
|
|
46
|
+
successMessage: d.approved,
|
|
47
|
+
errorFallback: d.approveError
|
|
49
48
|
});
|
|
50
49
|
}, [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
f,
|
|
51
|
+
w,
|
|
52
|
+
d,
|
|
53
|
+
k
|
|
54
|
+
]), j = c((e) => {
|
|
55
|
+
_(e), y("");
|
|
56
|
+
}, []), M = !!(g && m.has(g)), N = c(() => {
|
|
57
|
+
g && !w && k(g, {
|
|
58
|
+
decide: () => p({
|
|
59
|
+
approvalRequestId: g,
|
|
60
|
+
rejectReason: v
|
|
61
|
+
}),
|
|
62
|
+
successMessage: d.rejected,
|
|
63
|
+
errorFallback: d.rejectError
|
|
64
|
+
}).then((e) => {
|
|
65
|
+
e && _((e) => e === g ? void 0 : e);
|
|
66
|
+
});
|
|
67
|
+
}, [
|
|
68
|
+
w,
|
|
69
|
+
d,
|
|
54
70
|
p,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
k
|
|
58
|
-
|
|
71
|
+
v,
|
|
72
|
+
g,
|
|
73
|
+
k
|
|
74
|
+
]), P = c(() => {
|
|
75
|
+
M || _(void 0);
|
|
76
|
+
}, [M]);
|
|
59
77
|
return {
|
|
60
|
-
pendingRequestIds:
|
|
61
|
-
areDecisionsPaused:
|
|
62
|
-
onApprove:
|
|
63
|
-
onReject:
|
|
78
|
+
pendingRequestIds: m,
|
|
79
|
+
areDecisionsPaused: w,
|
|
80
|
+
onApprove: A,
|
|
81
|
+
onReject: j,
|
|
64
82
|
rejectDialog: {
|
|
65
|
-
open: !!
|
|
66
|
-
reason:
|
|
67
|
-
onReasonChange:
|
|
68
|
-
onConfirm:
|
|
69
|
-
onCancel:
|
|
70
|
-
isPending:
|
|
71
|
-
isConfirmDisabled:
|
|
83
|
+
open: !!g,
|
|
84
|
+
reason: v,
|
|
85
|
+
onReasonChange: y,
|
|
86
|
+
onConfirm: N,
|
|
87
|
+
onCancel: P,
|
|
88
|
+
isPending: M,
|
|
89
|
+
isConfirmDisabled: w
|
|
72
90
|
}
|
|
73
91
|
};
|
|
74
92
|
}
|
|
75
93
|
//#endregion
|
|
76
|
-
export {
|
|
94
|
+
export { d as useApprovalRequestDecisions };
|
|
@@ -5,18 +5,19 @@
|
|
|
5
5
|
import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
6
|
import { isOrganizationOnItsWay as t } from "../../../../shared/data-access/dist/lib/organizationStatus.js";
|
|
7
7
|
import { useEmbedApi as n } from "../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
8
|
+
import { isApiUnprocessableError as r } from "../../../../shared/data-access/dist/lib/isApiUnprocessableError.js";
|
|
8
9
|
import "../../../../shared/data-access/dist/index.js";
|
|
9
10
|
import "../../../../shared/ui/dist/index.js";
|
|
10
|
-
import { useAnalyticsTrack as
|
|
11
|
-
import { useWidgetConfig as
|
|
11
|
+
import { useAnalyticsTrack as ee } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
12
|
+
import { useWidgetConfig as te, useWidgetError as ne, useWidgetLoading as re } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
12
13
|
import "../../../../shared/feature/dist/index.js";
|
|
13
14
|
import { AccountDetailsWidgetAnalyticsEvent as i } from "./index2.js";
|
|
14
|
-
import { formatDateParam as
|
|
15
|
-
import { copyTextToClipboard as oe, formatAmountLabel as
|
|
15
|
+
import { formatDateParam as a, getDefaultExportDateRange as ie, isExportRangeValid as o, startOfLocalDay as s, triggerCsvDownload as ae, yesterdayLocal as c } from "./index3.js";
|
|
16
|
+
import { copyTextToClipboard as oe, formatAmountLabel as l, formatSignedTransactionAmountLabel as se, formatStatementPeriodLabel as ce, formatTransactionDateLabel as le, maskAccountNumber as ue } from "./index4.js";
|
|
16
17
|
import { DEFAULT_FEATURE_LABELS as de } from "./index5.js";
|
|
17
18
|
import { getBankAccountsPermissions as fe } from "./index6.js";
|
|
18
19
|
import { getStatementsStartDate as pe } from "./index7.js";
|
|
19
|
-
import { interpolateLabel as
|
|
20
|
+
import { interpolateLabel as u } from "./index8.js";
|
|
20
21
|
import { useBankAccountDetailsQuery as me } from "../../data-access/dist/index2.js";
|
|
21
22
|
import { useBankAccountStatementsQuery as he } from "../../data-access/dist/index3.js";
|
|
22
23
|
import { useBankAccountTransactionsQuery as ge } from "../../data-access/dist/index4.js";
|
|
@@ -27,7 +28,7 @@ import "../../data-access/dist/index.js";
|
|
|
27
28
|
import { DEFAULT_LABELS as be } from "../../ui/dist/index7.js";
|
|
28
29
|
import { AccountDetailsWidgetUi as xe } from "../../ui/dist/index8.js";
|
|
29
30
|
import "../../ui/dist/index.js";
|
|
30
|
-
import { useCallback as
|
|
31
|
+
import { useCallback as d, useEffect as Se, useMemo as f, useState as p } from "react";
|
|
31
32
|
import { jsx as Ce } from "react/jsx-runtime";
|
|
32
33
|
//#region ../../libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index9.js
|
|
33
34
|
var we = 3e3, Te = 5e3, Ee = [
|
|
@@ -35,255 +36,255 @@ var we = 3e3, Te = 5e3, Ee = [
|
|
|
35
36
|
25,
|
|
36
37
|
50
|
|
37
38
|
], De = 10, Oe = 6e5, ke = { nickname: "" };
|
|
38
|
-
function
|
|
39
|
-
let
|
|
39
|
+
function m({ accountId: m, onBack: Ae, labels: je, featureLabels: Me, isBankingTaglineVisible: Ne = !0, bankLogoSrc: Pe, bankLogoAlt: Fe, bankAddress: Ie, supportTeamUrl: Le }) {
|
|
40
|
+
let h = {
|
|
40
41
|
...be,
|
|
41
42
|
...je
|
|
42
|
-
},
|
|
43
|
+
}, g = {
|
|
43
44
|
...de,
|
|
44
45
|
...Me
|
|
45
|
-
},
|
|
46
|
-
accountId:
|
|
46
|
+
}, _ = ee(), { organizationId: Re, widgetToken: ze, initResponse: v } = te(), Be = re(), Ve = t(n().organizationStatus), y = !!ne(), b = !!(Re && ze), x = f(() => fe(v?.scopes), [v?.scopes]), S = x.canRead && !!v, C = b && S, w = S && !b, [T, He] = p("transactions"), [Ue, E] = p(!1), [D, O] = p(ke), [We, Ge] = p(!1), [Ke, k] = p(!1), [qe, A] = p(!1), [Je, Ye] = p(!1), [Xe, j] = p(!1), [M, N] = p(), [P, F] = p(), [I, Ze] = p(De), [L, R] = p(() => ({
|
|
47
|
+
accountId: m,
|
|
47
48
|
token: void 0
|
|
48
49
|
}));
|
|
49
|
-
|
|
50
|
-
accountId:
|
|
50
|
+
L.accountId !== m && R({
|
|
51
|
+
accountId: m,
|
|
51
52
|
token: void 0
|
|
52
53
|
});
|
|
53
|
-
let
|
|
54
|
-
|
|
54
|
+
let Qe = L.accountId === m ? L.token : void 0, z = d((e) => {
|
|
55
|
+
R((t) => ({
|
|
55
56
|
...t,
|
|
56
57
|
token: e
|
|
57
58
|
}));
|
|
58
|
-
}, []), [
|
|
59
|
+
}, []), [B, V] = p(() => /* @__PURE__ */ new Set());
|
|
59
60
|
Se(() => {
|
|
60
|
-
|
|
61
|
-
}, [
|
|
62
|
-
let
|
|
63
|
-
id:
|
|
64
|
-
enabled:
|
|
65
|
-
}),
|
|
66
|
-
id:
|
|
67
|
-
enabled:
|
|
61
|
+
_(i.Mounted);
|
|
62
|
+
}, [_]);
|
|
63
|
+
let H = me({
|
|
64
|
+
id: m,
|
|
65
|
+
enabled: C
|
|
66
|
+
}), U = ge({
|
|
67
|
+
id: m,
|
|
68
|
+
enabled: C && T === "transactions",
|
|
68
69
|
limit: 25,
|
|
69
70
|
sortBy: "DATE",
|
|
70
71
|
sortOrder: "DESC"
|
|
71
|
-
}), [
|
|
72
|
-
id:
|
|
73
|
-
startDate:
|
|
74
|
-
enabled:
|
|
75
|
-
limit:
|
|
76
|
-
pagination_token:
|
|
72
|
+
}), [$e] = p(pe), W = he({
|
|
73
|
+
id: m,
|
|
74
|
+
startDate: $e,
|
|
75
|
+
enabled: C && T === "statements",
|
|
76
|
+
limit: I,
|
|
77
|
+
pagination_token: Qe,
|
|
77
78
|
category: "STATEMENTS"
|
|
78
|
-
}),
|
|
79
|
+
}), et = ye(), tt = _e(), nt = ve(), { mutate: rt, isPending: it, isError: G, reset: K } = et, { mutateAsync: at, isPending: ot } = tt, { mutateAsync: st } = nt, q = S ? H.data : void 0, J = v?.bankName?.trim() ?? "", ct = Ie?.trim() || void 0, Y = { bankName: J }, lt = f(() => u(h.domesticWireIntro, Y), [h.domesticWireIntro, J]), ut = f(() => u(h.domesticWireNote, Y), [h.domesticWireNote, J]), dt = f(() => u(h.thingsToKnowBody, Y), [h.thingsToKnowBody, J]), ft = q?.nickname?.trim() || g.accountFallback, pt = l(q?.balance), mt = f(() => (U.data?.data ?? []).map((e, t) => ({
|
|
79
80
|
key: `${e.date}-${t}`,
|
|
80
81
|
descriptionLabel: e.description,
|
|
81
82
|
dateLabel: le(e.date),
|
|
82
83
|
amountLabel: se(e.amount, e.direction),
|
|
83
84
|
amountVariant: e.direction === "CREDIT" ? "positive" : "default",
|
|
84
|
-
balanceLabel:
|
|
85
|
-
})), [
|
|
86
|
-
if (!
|
|
85
|
+
balanceLabel: l(e.runningBalance)
|
|
86
|
+
})), [U.data?.data]), ht = x.canRead && mt.length > 0, gt = d((t) => {
|
|
87
|
+
if (!b || !x.canRead) return;
|
|
87
88
|
let n = window.open("", "_blank");
|
|
88
89
|
if (!n) {
|
|
89
|
-
e.error(
|
|
90
|
+
e.error(g.viewStatementErrorToast);
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
|
-
n.opener = null,
|
|
93
|
-
id:
|
|
93
|
+
n.opener = null, V((e) => new Set(e).add(t)), st({
|
|
94
|
+
id: m,
|
|
94
95
|
statementId: t
|
|
95
96
|
}).then((e) => {
|
|
96
97
|
let t = URL.createObjectURL(e);
|
|
97
98
|
n.location.href = t, window.setTimeout(() => URL.revokeObjectURL(t), Oe);
|
|
98
99
|
}).catch(() => {
|
|
99
|
-
n.close(), e.error(
|
|
100
|
+
n.close(), e.error(g.viewStatementErrorToast);
|
|
100
101
|
}).finally(() => {
|
|
101
|
-
|
|
102
|
+
V((e) => {
|
|
102
103
|
if (!e.has(t)) return e;
|
|
103
104
|
let n = new Set(e);
|
|
104
105
|
return n.delete(t), n;
|
|
105
106
|
});
|
|
106
107
|
});
|
|
107
108
|
}, [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
]),
|
|
109
|
+
m,
|
|
110
|
+
g.viewStatementErrorToast,
|
|
111
|
+
b,
|
|
112
|
+
x.canRead,
|
|
113
|
+
st
|
|
114
|
+
]), _t = f(() => (W.data?.data ?? []).map((e) => {
|
|
114
115
|
let t = ce(e.statementDate);
|
|
115
116
|
return {
|
|
116
117
|
key: e.statementId,
|
|
117
118
|
label: t,
|
|
118
|
-
viewButtonAriaLabel:
|
|
119
|
-
isViewDisabled:
|
|
120
|
-
onView: () =>
|
|
119
|
+
viewButtonAriaLabel: u(h.viewStatementButtonAriaLabel, { date: t }),
|
|
120
|
+
isViewDisabled: B.has(e.statementId),
|
|
121
|
+
onView: () => gt(e.statementId)
|
|
121
122
|
};
|
|
122
123
|
}), [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]),
|
|
128
|
-
|
|
129
|
-
}, [
|
|
130
|
-
|
|
131
|
-
}, []),
|
|
132
|
-
|
|
133
|
-
}, [
|
|
134
|
-
|
|
135
|
-
}, [
|
|
136
|
-
let e = [{ after:
|
|
137
|
-
return
|
|
138
|
-
}, [
|
|
139
|
-
let e = [{ after:
|
|
140
|
-
return
|
|
141
|
-
}, [
|
|
124
|
+
W.data?.data,
|
|
125
|
+
h.viewStatementButtonAriaLabel,
|
|
126
|
+
B,
|
|
127
|
+
gt
|
|
128
|
+
]), X = W.data?.nextPaginationToken ?? void 0, Z = W.data?.prevPaginationToken ?? void 0, vt = C && T === "statements" && !!W.data && !W.isError, yt = C && T === "statements" && W.isLoading, bt = C && T === "statements" && W.isError && !r(W.error), xt = d(() => {
|
|
129
|
+
W.refetch();
|
|
130
|
+
}, [W.refetch]), St = d((e) => {
|
|
131
|
+
Ze(e), z(void 0);
|
|
132
|
+
}, []), Ct = d(() => {
|
|
133
|
+
z(Z);
|
|
134
|
+
}, [Z]), wt = d(() => {
|
|
135
|
+
z(X);
|
|
136
|
+
}, [X]), Tt = w || !o(M, P), Et = f(() => {
|
|
137
|
+
let e = [{ after: c() }];
|
|
138
|
+
return P && e.push({ after: s(P) }), e;
|
|
139
|
+
}, [P]), Dt = f(() => {
|
|
140
|
+
let e = [{ after: c() }];
|
|
141
|
+
return M && e.push({ before: s(M) }), e;
|
|
142
|
+
}, [M]), Ot = d((e) => {
|
|
142
143
|
if (e) {
|
|
143
144
|
let { startDate: e, endDate: t } = ie();
|
|
144
|
-
|
|
145
|
+
N(e), F(t);
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
}, []),
|
|
148
|
-
if (!
|
|
149
|
-
|
|
150
|
-
let t = e.loading(
|
|
147
|
+
j(e);
|
|
148
|
+
}, []), kt = d(async () => {
|
|
149
|
+
if (!b || !x.canRead || !M || !P || !o(M, P)) return;
|
|
150
|
+
j(!1);
|
|
151
|
+
let t = e.loading(g.exportLoadingToast);
|
|
151
152
|
try {
|
|
152
|
-
let n = await
|
|
153
|
-
id:
|
|
154
|
-
startDate:
|
|
155
|
-
endDate:
|
|
153
|
+
let n = await at({
|
|
154
|
+
id: m,
|
|
155
|
+
startDate: a(M),
|
|
156
|
+
endDate: a(P)
|
|
156
157
|
});
|
|
157
|
-
ae(n.csv, n.filename), e.success(
|
|
158
|
+
ae(n.csv, n.filename), e.success(g.exportSuccessToast, {
|
|
158
159
|
id: t,
|
|
159
160
|
duration: we
|
|
160
161
|
});
|
|
161
162
|
} catch {
|
|
162
|
-
e.error(
|
|
163
|
+
e.error(g.exportErrorToast, {
|
|
163
164
|
id: t,
|
|
164
165
|
duration: Te
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
168
|
}, [
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
]),
|
|
169
|
+
m,
|
|
170
|
+
at,
|
|
171
|
+
P,
|
|
172
|
+
M,
|
|
173
|
+
g.exportErrorToast,
|
|
174
|
+
g.exportLoadingToast,
|
|
175
|
+
g.exportSuccessToast,
|
|
176
|
+
b,
|
|
177
|
+
x.canRead
|
|
178
|
+
]), Q = d(async (t, n) => {
|
|
178
179
|
if (!await oe(t)) return;
|
|
179
180
|
let r = {
|
|
180
|
-
account:
|
|
181
|
-
routing:
|
|
182
|
-
bankName:
|
|
183
|
-
bankAddress:
|
|
181
|
+
account: g.copyAccountNumberToast,
|
|
182
|
+
routing: g.copyRoutingNumberToast,
|
|
183
|
+
bankName: g.copyBankNameToast,
|
|
184
|
+
bankAddress: g.copyBankAddressToast
|
|
184
185
|
};
|
|
185
186
|
if (e.success(r[n]), n === "account") {
|
|
186
|
-
|
|
187
|
+
k(!0), window.setTimeout(() => k(!1), 2e3);
|
|
187
188
|
return;
|
|
188
189
|
}
|
|
189
|
-
n === "routing" && (
|
|
190
|
+
n === "routing" && (A(!0), window.setTimeout(() => A(!1), 2e3));
|
|
190
191
|
}, [
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
]),
|
|
196
|
-
e && (
|
|
192
|
+
g.copyAccountNumberToast,
|
|
193
|
+
g.copyBankAddressToast,
|
|
194
|
+
g.copyBankNameToast,
|
|
195
|
+
g.copyRoutingNumberToast
|
|
196
|
+
]), $ = (e) => {
|
|
197
|
+
e && (O({ nickname: q?.nickname?.trim() ?? "" }), K()), E(e);
|
|
197
198
|
};
|
|
198
199
|
return /* @__PURE__ */ Ce(xe, {
|
|
199
|
-
labels:
|
|
200
|
+
labels: h,
|
|
200
201
|
title: ft,
|
|
201
|
-
bankDisplayName:
|
|
202
|
+
bankDisplayName: J,
|
|
202
203
|
bankLogoSrc: Pe,
|
|
203
204
|
bankLogoAlt: Fe,
|
|
204
205
|
balanceLabel: pt,
|
|
205
206
|
balanceTestId: "bank-accounts-widget-detail-balance",
|
|
206
207
|
isBankingTaglineVisible: Ne,
|
|
207
|
-
activeTab:
|
|
208
|
-
transactionRows:
|
|
209
|
-
statementRows:
|
|
210
|
-
isStatementsLoading:
|
|
211
|
-
isStatementsError:
|
|
212
|
-
onStatementsRetry:
|
|
213
|
-
isStatementsPaginationVisible:
|
|
214
|
-
statementsPageSize:
|
|
208
|
+
activeTab: T,
|
|
209
|
+
transactionRows: mt,
|
|
210
|
+
statementRows: _t,
|
|
211
|
+
isStatementsLoading: yt,
|
|
212
|
+
isStatementsError: bt,
|
|
213
|
+
onStatementsRetry: xt,
|
|
214
|
+
isStatementsPaginationVisible: vt,
|
|
215
|
+
statementsPageSize: I,
|
|
215
216
|
statementsPageSizeOptions: Ee,
|
|
216
|
-
isStatementsPreviousPageDisabled: !
|
|
217
|
-
isStatementsNextPageDisabled: !
|
|
218
|
-
onStatementsPageSizeChange:
|
|
219
|
-
onStatementsPreviousPageClick:
|
|
220
|
-
onStatementsNextPageClick:
|
|
221
|
-
showExport:
|
|
222
|
-
isExportOpen:
|
|
223
|
-
exportStartDate:
|
|
224
|
-
exportEndDate:
|
|
225
|
-
isExportDownloading:
|
|
226
|
-
isExportDownloadDisabled:
|
|
227
|
-
disabledExportStartDates:
|
|
228
|
-
disabledExportEndDates:
|
|
229
|
-
accountNumberLabel:
|
|
230
|
-
maskedAccountNumberLabel: ue(
|
|
217
|
+
isStatementsPreviousPageDisabled: !Z,
|
|
218
|
+
isStatementsNextPageDisabled: !X,
|
|
219
|
+
onStatementsPageSizeChange: St,
|
|
220
|
+
onStatementsPreviousPageClick: Ct,
|
|
221
|
+
onStatementsNextPageClick: wt,
|
|
222
|
+
showExport: ht,
|
|
223
|
+
isExportOpen: Xe,
|
|
224
|
+
exportStartDate: M,
|
|
225
|
+
exportEndDate: P,
|
|
226
|
+
isExportDownloading: ot,
|
|
227
|
+
isExportDownloadDisabled: Tt,
|
|
228
|
+
disabledExportStartDates: Et,
|
|
229
|
+
disabledExportEndDates: Dt,
|
|
230
|
+
accountNumberLabel: q?.accountNumber ?? "",
|
|
231
|
+
maskedAccountNumberLabel: ue(q?.accountNumber ?? ""),
|
|
231
232
|
accountNumberTestId: "bank-accounts-widget-detail-account-number",
|
|
232
|
-
wireAccountNumberLabel:
|
|
233
|
-
routingNumberLabel:
|
|
234
|
-
bankAddressLabel:
|
|
233
|
+
wireAccountNumberLabel: q?.accountNumber ?? "",
|
|
234
|
+
routingNumberLabel: q?.routingNumber ?? "",
|
|
235
|
+
bankAddressLabel: ct,
|
|
235
236
|
domesticWireIntroLabel: lt,
|
|
236
237
|
domesticWireNoteLabel: ut,
|
|
237
238
|
thingsToKnowBodyLabel: dt,
|
|
238
239
|
supportTeamHref: Le,
|
|
239
240
|
isAccountNumberVisible: We,
|
|
240
241
|
isAccountNumberCopied: Ke,
|
|
241
|
-
isRoutingNumberCopied:
|
|
242
|
-
isDomesticWireExpanded:
|
|
243
|
-
isLoading: !
|
|
244
|
-
isError:
|
|
242
|
+
isRoutingNumberCopied: qe,
|
|
243
|
+
isDomesticWireExpanded: Je,
|
|
244
|
+
isLoading: !y && (Ve && !q || Be && !v || C && (H.isLoading || T === "transactions" && U.isLoading)),
|
|
245
|
+
isError: y || C && (H.isError || T === "transactions" && U.isError),
|
|
245
246
|
isEditOpen: Ue,
|
|
246
|
-
isEditDisabled: !
|
|
247
|
-
isEditError:
|
|
248
|
-
isSubmitting:
|
|
249
|
-
isEditSaveDisabled:
|
|
250
|
-
editForm:
|
|
251
|
-
canEdit:
|
|
247
|
+
isEditDisabled: !x.canWrite,
|
|
248
|
+
isEditError: G,
|
|
249
|
+
isSubmitting: it,
|
|
250
|
+
isEditSaveDisabled: w,
|
|
251
|
+
editForm: D,
|
|
252
|
+
canEdit: x.canWrite,
|
|
252
253
|
onBack: Ae,
|
|
253
254
|
onTabChange: He,
|
|
254
255
|
onToggleAccountNumberVisibility: () => Ge((e) => !e),
|
|
255
|
-
onCopyAccountNumber: () => void
|
|
256
|
-
onCopyRoutingNumber: () => void
|
|
257
|
-
onCopyBankName: () => void
|
|
258
|
-
onCopyBankAddress: () => void
|
|
259
|
-
onDomesticWireExpandedChange:
|
|
260
|
-
onEditOpenChange:
|
|
256
|
+
onCopyAccountNumber: () => void Q(q?.accountNumber ?? "", "account"),
|
|
257
|
+
onCopyRoutingNumber: () => void Q(q?.routingNumber ?? "", "routing"),
|
|
258
|
+
onCopyBankName: () => void Q(J, "bankName"),
|
|
259
|
+
onCopyBankAddress: () => void Q(ct ?? "", "bankAddress"),
|
|
260
|
+
onDomesticWireExpandedChange: Ye,
|
|
261
|
+
onEditOpenChange: $,
|
|
261
262
|
onEditFormChange: (e) => {
|
|
262
|
-
|
|
263
|
+
G && K(), O(e);
|
|
263
264
|
},
|
|
264
265
|
onEditSubmit: () => {
|
|
265
|
-
if (!
|
|
266
|
-
let t =
|
|
267
|
-
t &&
|
|
268
|
-
path: { id:
|
|
266
|
+
if (!b || !x.canWrite) return;
|
|
267
|
+
let t = D.nickname.trim();
|
|
268
|
+
t && rt({
|
|
269
|
+
path: { id: m },
|
|
269
270
|
body: { nickname: t }
|
|
270
271
|
}, {
|
|
271
272
|
onSuccess: () => {
|
|
272
|
-
|
|
273
|
+
_(i.AccountUpdated, { accountId: m }), e.success(g.editSuccessToast), E(!1);
|
|
273
274
|
},
|
|
274
275
|
onError: () => {
|
|
275
|
-
e.error(
|
|
276
|
+
e.error(g.editErrorToast);
|
|
276
277
|
}
|
|
277
278
|
});
|
|
278
279
|
},
|
|
279
|
-
onEditNicknameClick: () =>
|
|
280
|
-
onExportOpenChange:
|
|
281
|
-
onExportStartDateChange:
|
|
282
|
-
onExportEndDateChange:
|
|
280
|
+
onEditNicknameClick: () => $(!0),
|
|
281
|
+
onExportOpenChange: Ot,
|
|
282
|
+
onExportStartDateChange: N,
|
|
283
|
+
onExportEndDateChange: F,
|
|
283
284
|
onExportDownload: () => {
|
|
284
|
-
|
|
285
|
+
kt();
|
|
285
286
|
}
|
|
286
287
|
});
|
|
287
288
|
}
|
|
288
289
|
//#endregion
|
|
289
|
-
export {
|
|
290
|
+
export { m as AccountDetailsWidget };
|
|
@@ -7,6 +7,7 @@ var e = {
|
|
|
7
7
|
failedCaption: (e) => `${e} failed to upload`,
|
|
8
8
|
tooManyFilesError: (e) => `You can only upload up to ${e} files at a time`,
|
|
9
9
|
remainingCapacityError: (e) => e === 0 ? "Wait for the current uploads to finish before adding more files" : `You can upload ${e} more ${e === 1 ? "file" : "files"} right now`,
|
|
10
|
+
fileTooLargeError: (e) => `Each file must be ${e} MB or smaller`,
|
|
10
11
|
billDeletedError: "This bill was already deleted"
|
|
11
12
|
};
|
|
12
13
|
//#endregion
|
|
@@ -23,110 +23,115 @@ function g({ onOpenBill: g, labels: _ } = {}) {
|
|
|
23
23
|
let v = {
|
|
24
24
|
...s,
|
|
25
25
|
..._
|
|
26
|
-
}, y = _?.tooManyFilesError ?? s.tooManyFilesError, b = _?.remainingCapacityError ?? s.remainingCapacityError, { client:
|
|
27
|
-
queryKey:
|
|
28
|
-
queryFn: () =>
|
|
26
|
+
}, y = _?.tooManyFilesError ?? s.tooManyFilesError, b = _?.remainingCapacityError ?? s.remainingCapacityError, x = _?.fileTooLargeError ?? s.fileTooLargeError, { client: S, organizationId: C, authEpoch: w, organizationStatus: T } = r(), E = h(), D = f(() => o(C), [C]), O = l(), [k, A] = p(!1), { data: j = [] } = m({
|
|
27
|
+
queryKey: D,
|
|
28
|
+
queryFn: () => E.getQueryData(D) ?? [],
|
|
29
29
|
staleTime: Infinity,
|
|
30
30
|
gcTime: Infinity,
|
|
31
31
|
initialData: []
|
|
32
|
-
}),
|
|
33
|
-
|
|
32
|
+
}), M = u((e, t) => {
|
|
33
|
+
E.setQueryData(D, (n) => (n ?? []).map((n) => n.localId === e ? {
|
|
34
34
|
...n,
|
|
35
35
|
...t
|
|
36
36
|
} : n));
|
|
37
|
-
}, [
|
|
38
|
-
|
|
39
|
-
}, [
|
|
40
|
-
let n = (
|
|
37
|
+
}, [E, D]), N = u((e) => {
|
|
38
|
+
E.setQueryData(D, (t) => (t ?? []).filter((t) => t.localId !== e));
|
|
39
|
+
}, [E, D]), P = u((t) => {
|
|
40
|
+
let n = (E.getQueryData(D) ?? []).filter((e) => e.status === "uploading").length;
|
|
41
41
|
if (t.length + n > 10) {
|
|
42
42
|
e.error(n > 0 ? b(10 - n) : y(10));
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
if (t.some((e) => e.size > 20971520)) {
|
|
46
|
+
e.error(x(20));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
A(!1);
|
|
46
50
|
for (let e of t) {
|
|
47
51
|
let t = crypto.randomUUID();
|
|
48
|
-
|
|
52
|
+
E.setQueryData(D, (n) => [...n ?? [], {
|
|
49
53
|
localId: t,
|
|
50
54
|
fileName: e.name,
|
|
51
55
|
status: "uploading"
|
|
52
|
-
}]),
|
|
56
|
+
}]), O.mutateAsync({ file: e }).then((e) => M(t, { payableId: e?.id })).catch(() => M(t, { status: "failed" }));
|
|
53
57
|
}
|
|
54
58
|
}, [
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
x,
|
|
60
|
+
M,
|
|
57
61
|
E,
|
|
62
|
+
D,
|
|
58
63
|
b,
|
|
59
64
|
y,
|
|
60
|
-
|
|
61
|
-
]),
|
|
65
|
+
O
|
|
66
|
+
]), F = c({ payableIds: j.filter((e) => e.status === "uploading" && e.payableId).map((e) => e.payableId) });
|
|
62
67
|
d(() => {
|
|
63
68
|
let e = /* @__PURE__ */ new Set();
|
|
64
|
-
for (let t of
|
|
69
|
+
for (let t of F) if (t.suspectedDuplicateOf.length !== 0) {
|
|
65
70
|
e.add(t.payableId);
|
|
66
71
|
for (let n of t.suspectedDuplicateOf) e.add(n);
|
|
67
72
|
}
|
|
68
|
-
for (let { payableId: t, ocrStatus: n, isError: r } of
|
|
69
|
-
let i =
|
|
70
|
-
i && (n === "success" ?
|
|
73
|
+
for (let { payableId: t, ocrStatus: n, isError: r } of F) {
|
|
74
|
+
let i = j.find((e) => e.payableId === t && e.status === "uploading");
|
|
75
|
+
i && (n === "success" ? M(i.localId, { status: e.has(t) ? "duplicate" : "ready" }) : (r || n === "error" || n === "canceled") && M(i.localId, { status: "failed" }));
|
|
71
76
|
}
|
|
72
|
-
for (let t of
|
|
77
|
+
for (let t of j) t.status === "ready" && t.payableId && e.has(t.payableId) && M(t.localId, { status: "duplicate" });
|
|
73
78
|
}, [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
j,
|
|
80
|
+
F,
|
|
81
|
+
M
|
|
77
82
|
]);
|
|
78
|
-
let
|
|
83
|
+
let I = j.filter((e) => e.status === "uploading"), L = j.filter((e) => e.status === "ready"), R = j.filter((e) => e.status === "duplicate"), z = j.filter((e) => e.status === "failed"), B = (r) => ({
|
|
79
84
|
id: r.localId,
|
|
80
85
|
fileName: r.fileName,
|
|
81
86
|
status: r.status,
|
|
82
87
|
onOpen: (r.status === "ready" || r.status === "duplicate") && r.payableId && g ? () => {
|
|
83
88
|
let o = r.payableId;
|
|
84
|
-
|
|
89
|
+
E.fetchQuery({
|
|
85
90
|
...n(t({
|
|
86
|
-
client:
|
|
87
|
-
headers: i(
|
|
91
|
+
client: S,
|
|
92
|
+
headers: i(C),
|
|
88
93
|
path: { payable_id: o }
|
|
89
94
|
}), {
|
|
90
|
-
authEpoch:
|
|
91
|
-
organizationStatus:
|
|
95
|
+
authEpoch: w,
|
|
96
|
+
organizationStatus: T
|
|
92
97
|
}),
|
|
93
98
|
retry: !1
|
|
94
99
|
}).catch((e) => {
|
|
95
100
|
if (a(e)) return "deleted";
|
|
96
101
|
}).then((t) => {
|
|
97
|
-
t === "deleted" ? e.error(v.billDeletedError) : g(o),
|
|
102
|
+
t === "deleted" ? e.error(v.billDeletedError) : g(o), N(r.localId);
|
|
98
103
|
});
|
|
99
104
|
} : void 0
|
|
100
|
-
}),
|
|
105
|
+
}), V = I.length ? [{
|
|
101
106
|
id: "in-progress",
|
|
102
|
-
items:
|
|
107
|
+
items: j.map(B)
|
|
103
108
|
}] : [
|
|
104
|
-
...
|
|
109
|
+
...L.length ? [{
|
|
105
110
|
id: "ready",
|
|
106
|
-
caption: v.readyCaption(
|
|
107
|
-
items:
|
|
111
|
+
caption: v.readyCaption(L.length),
|
|
112
|
+
items: L.map(B)
|
|
108
113
|
}] : [],
|
|
109
|
-
...
|
|
114
|
+
...R.length ? [{
|
|
110
115
|
id: "duplicate",
|
|
111
|
-
caption: v.duplicateCaption(
|
|
112
|
-
items:
|
|
116
|
+
caption: v.duplicateCaption(R.length),
|
|
117
|
+
items: R.map(B)
|
|
113
118
|
}] : [],
|
|
114
|
-
...
|
|
119
|
+
...z.length ? [{
|
|
115
120
|
id: "failed",
|
|
116
|
-
caption: v.failedCaption(
|
|
117
|
-
items:
|
|
121
|
+
caption: v.failedCaption(z.length),
|
|
122
|
+
items: z.map(B)
|
|
118
123
|
}] : []
|
|
119
|
-
],
|
|
120
|
-
|
|
121
|
-
}, [
|
|
124
|
+
], H = L.length + R.length, U = I.length ? v.uploadingSummary(j.length) : H ? v.completeSummary(H) : v.failedCaption(z.length), W = u(() => {
|
|
125
|
+
E.setQueryData(D, []);
|
|
126
|
+
}, [E, D]);
|
|
122
127
|
return {
|
|
123
|
-
enqueue:
|
|
124
|
-
sections:
|
|
125
|
-
summaryLabel:
|
|
126
|
-
collapsed:
|
|
127
|
-
onToggleCollapsed: u(() =>
|
|
128
|
-
onClose:
|
|
129
|
-
isVisible:
|
|
128
|
+
enqueue: P,
|
|
129
|
+
sections: V,
|
|
130
|
+
summaryLabel: U,
|
|
131
|
+
collapsed: k,
|
|
132
|
+
onToggleCollapsed: u(() => A((e) => !e), []),
|
|
133
|
+
onClose: W,
|
|
134
|
+
isVisible: j.length > 0
|
|
130
135
|
};
|
|
131
136
|
}
|
|
132
137
|
//#endregion
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
|
|
2
|
-
var e = "@tesouro/embedded-components-react", t = "0.9.
|
|
2
|
+
var e = "@tesouro/embedded-components-react", t = "0.9.45", n = "0d9dec8b8927b2abd568eb61986dd26ca14843b6", r = Object.freeze({
|
|
3
3
|
library_name: e,
|
|
4
4
|
library_version: t,
|
|
5
5
|
library_sha: n
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/expectedApiUnprocessable.js
|
|
2
|
+
var e = /* @__PURE__ */ new Set(["GET /embedded-banking/v1/bank-accounts/{id}/statements"]);
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
return t === 422 && n !== void 0 && r !== void 0 && e.has(`${n.toUpperCase()} ${r}`);
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { t as isExpectedApiUnprocessable };
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/interceptor.js
CHANGED
|
@@ -3,65 +3,68 @@ import "../../../../data-access/dist/index.js";
|
|
|
3
3
|
import { EmbeddedAnalyticsEvent as t, MUTATION_METHODS as n } from "./events.js";
|
|
4
4
|
import { captureExceptionWithContext as r, trackWithContext as i } from "./runtime.js";
|
|
5
5
|
import { isExpectedApiNotFound as a } from "./expectedApiNotFound.js";
|
|
6
|
-
import {
|
|
6
|
+
import { isExpectedApiUnprocessable as o } from "./expectedApiUnprocessable.js";
|
|
7
|
+
import { extractTraceIdFromHeaders as s, resolveTraceId as c } from "./traceId.js";
|
|
7
8
|
//#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/interceptor.js
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
return
|
|
9
|
+
function l(l, h) {
|
|
10
|
+
let g = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Set();
|
|
11
|
+
return l.interceptors.request.use((e) => (g.set(e, p()), e)), l.interceptors.response.use((e, r, a) => {
|
|
11
12
|
if (!e.ok || !n.has(r.method.toUpperCase())) return e;
|
|
12
|
-
let
|
|
13
|
+
let o = s(e);
|
|
13
14
|
return i(t.ApiRequestCompleted, {
|
|
14
15
|
method: r.method,
|
|
15
16
|
route: a.url,
|
|
16
17
|
status: e.status,
|
|
17
|
-
duration_ms:
|
|
18
|
-
...
|
|
19
|
-
},
|
|
20
|
-
}),
|
|
21
|
-
if (
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
method:
|
|
25
|
-
route:
|
|
26
|
-
status:
|
|
27
|
-
duration_ms:
|
|
28
|
-
error_kind:
|
|
18
|
+
duration_ms: m(g.get(r)),
|
|
19
|
+
...o ? { trace_id: o } : {}
|
|
20
|
+
}, h.current), e;
|
|
21
|
+
}), l.interceptors.error.use((n, s, l, p) => {
|
|
22
|
+
if (f(n, l)) return n;
|
|
23
|
+
let v = c(s, n);
|
|
24
|
+
i(t.ApiRequestFailed, {
|
|
25
|
+
method: l?.method ?? p.method,
|
|
26
|
+
route: p.url,
|
|
27
|
+
status: s?.status,
|
|
28
|
+
duration_ms: l ? m(g.get(l)) : void 0,
|
|
29
|
+
error_kind: s ? "http" : "network",
|
|
29
30
|
error_name: n instanceof Error ? n.name : "unknown",
|
|
30
|
-
...
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
...v ? { trace_id: v } : {}
|
|
32
|
+
}, h.current);
|
|
33
|
+
let y = l?.method ?? p.method;
|
|
34
|
+
if (a(s?.status, y, p.url) || o(s?.status, y, p.url)) return n;
|
|
35
|
+
if (s?.status === 401) {
|
|
36
|
+
let t = e(d(l));
|
|
37
|
+
if (_.has(t)) return n;
|
|
38
|
+
_.add(t);
|
|
36
39
|
}
|
|
37
|
-
return r(
|
|
38
|
-
method:
|
|
39
|
-
route:
|
|
40
|
-
status:
|
|
41
|
-
error_kind:
|
|
40
|
+
return r(u(s, p.url), {
|
|
41
|
+
method: l?.method ?? p.method,
|
|
42
|
+
route: p.url,
|
|
43
|
+
status: s?.status,
|
|
44
|
+
error_kind: s ? "http" : "network",
|
|
42
45
|
error_name: n instanceof Error ? n.name : "unknown",
|
|
43
|
-
...
|
|
44
|
-
},
|
|
45
|
-
}),
|
|
46
|
+
...v ? { trace_id: v } : {}
|
|
47
|
+
}, h.current), n;
|
|
48
|
+
}), l;
|
|
46
49
|
}
|
|
47
|
-
function
|
|
50
|
+
function u(e, t) {
|
|
48
51
|
let n = /* @__PURE__ */ Error(`API request failed (${e?.status ?? "network"}): ${t ?? "unknown route"}`);
|
|
49
52
|
return n.name = "ApiRequestError", n;
|
|
50
53
|
}
|
|
51
|
-
function
|
|
54
|
+
function d(e) {
|
|
52
55
|
let t = e?.headers.get("X-Widget-Token");
|
|
53
56
|
if (t) return t;
|
|
54
57
|
let n = e?.headers.get("Authorization");
|
|
55
58
|
return n?.startsWith("Bearer ") ? n.slice(7) : void 0;
|
|
56
59
|
}
|
|
57
|
-
function
|
|
60
|
+
function f(e, t) {
|
|
58
61
|
return t?.signal.aborted ? !0 : e instanceof Error && e.name === "AbortError";
|
|
59
62
|
}
|
|
60
|
-
function
|
|
63
|
+
function p() {
|
|
61
64
|
return typeof performance < "u" ? performance.now() : Date.now();
|
|
62
65
|
}
|
|
63
|
-
function
|
|
64
|
-
return e === void 0 ? void 0 : Math.round(
|
|
66
|
+
function m(e) {
|
|
67
|
+
return e === void 0 ? void 0 : Math.round(p() - e);
|
|
65
68
|
}
|
|
66
69
|
//#endregion
|
|
67
|
-
export {
|
|
70
|
+
export { l as attachAnalyticsInterceptors };
|