@tesouro/embedded-components-react 0.9.44 → 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/shared/feature/dist/lib/analytics/build-info.js +1 -1
- 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 };
|
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
|