@tesouro/embedded-components-react 0.9.41 → 0.9.43
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 +15 -1
- package/dist/experimental/index.d.ts +15 -1
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index2.js +9 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index4.js +29 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index5.js +30 -2
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js +45 -35
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js +17 -14
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/canDecideApprovalRequest.js +8 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js +76 -0
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsFilters.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js +53 -44
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js +13 -1
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index4.js +91 -58
- package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index5.js +44 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +3432 -3332
- package/package.json +1 -1
|
@@ -638,6 +638,10 @@ interface ApprovalRequestsScreenLabels {
|
|
|
638
638
|
columnStatus: string;
|
|
639
639
|
columnAmount: string;
|
|
640
640
|
columnAddedBy: string;
|
|
641
|
+
columnActions: string;
|
|
642
|
+
rowActions: string;
|
|
643
|
+
approve: string;
|
|
644
|
+
reject: string;
|
|
641
645
|
/** Read by screen readers in a cell whose name is still loading. */
|
|
642
646
|
loadingValue: string;
|
|
643
647
|
errorTitle: string;
|
|
@@ -647,6 +651,15 @@ interface ApprovalRequestsScreenLabels {
|
|
|
647
651
|
accessRestrictedTitle: string;
|
|
648
652
|
accessRestrictedDescription: string;
|
|
649
653
|
}
|
|
654
|
+
interface RejectApprovalRequestDialogLabels {
|
|
655
|
+
title: string;
|
|
656
|
+
description: string;
|
|
657
|
+
reason: string;
|
|
658
|
+
optionalNote: string;
|
|
659
|
+
confirm: string;
|
|
660
|
+
cancel: string;
|
|
661
|
+
close: string;
|
|
662
|
+
}
|
|
650
663
|
|
|
651
664
|
interface ApprovalRequestsFilterLabels {
|
|
652
665
|
statusChip: (value: string) => string;
|
|
@@ -671,6 +684,7 @@ interface ApprovalRequestsListLabels {
|
|
|
671
684
|
interface ApprovalRequestsWidgetOwnProps {
|
|
672
685
|
screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
|
|
673
686
|
listLabels?: PartialDeep<ApprovalRequestsListLabels>;
|
|
687
|
+
rejectDialogLabels?: Partial<RejectApprovalRequestDialogLabels>;
|
|
674
688
|
}
|
|
675
689
|
/** Public props for {@link ApprovalRequestsWidget}. */
|
|
676
690
|
type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
|
|
@@ -678,7 +692,7 @@ type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetO
|
|
|
678
692
|
* Self-contained approval requests widget, a native port of Monite's approval
|
|
679
693
|
* requests (FOPS-97). Exported only from the package's `/experimental` entry.
|
|
680
694
|
*/
|
|
681
|
-
declare function ApprovalRequestsWidget({ screenLabels, listLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
|
|
695
|
+
declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
|
|
682
696
|
|
|
683
697
|
export { ApprovalRequestsWidget };
|
|
684
698
|
export type { ApprovalRequestsWidgetProps };
|
|
@@ -638,6 +638,10 @@ interface ApprovalRequestsScreenLabels {
|
|
|
638
638
|
columnStatus: string;
|
|
639
639
|
columnAmount: string;
|
|
640
640
|
columnAddedBy: string;
|
|
641
|
+
columnActions: string;
|
|
642
|
+
rowActions: string;
|
|
643
|
+
approve: string;
|
|
644
|
+
reject: string;
|
|
641
645
|
/** Read by screen readers in a cell whose name is still loading. */
|
|
642
646
|
loadingValue: string;
|
|
643
647
|
errorTitle: string;
|
|
@@ -647,6 +651,15 @@ interface ApprovalRequestsScreenLabels {
|
|
|
647
651
|
accessRestrictedTitle: string;
|
|
648
652
|
accessRestrictedDescription: string;
|
|
649
653
|
}
|
|
654
|
+
interface RejectApprovalRequestDialogLabels {
|
|
655
|
+
title: string;
|
|
656
|
+
description: string;
|
|
657
|
+
reason: string;
|
|
658
|
+
optionalNote: string;
|
|
659
|
+
confirm: string;
|
|
660
|
+
cancel: string;
|
|
661
|
+
close: string;
|
|
662
|
+
}
|
|
650
663
|
|
|
651
664
|
interface ApprovalRequestsFilterLabels {
|
|
652
665
|
statusChip: (value: string) => string;
|
|
@@ -671,6 +684,7 @@ interface ApprovalRequestsListLabels {
|
|
|
671
684
|
interface ApprovalRequestsWidgetOwnProps {
|
|
672
685
|
screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
|
|
673
686
|
listLabels?: PartialDeep<ApprovalRequestsListLabels>;
|
|
687
|
+
rejectDialogLabels?: Partial<RejectApprovalRequestDialogLabels>;
|
|
674
688
|
}
|
|
675
689
|
/** Public props for {@link ApprovalRequestsWidget}. */
|
|
676
690
|
type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
|
|
@@ -678,7 +692,7 @@ type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetO
|
|
|
678
692
|
* Self-contained approval requests widget, a native port of Monite's approval
|
|
679
693
|
* requests (FOPS-97). Exported only from the package's `/experimental` entry.
|
|
680
694
|
*/
|
|
681
|
-
declare function ApprovalRequestsWidget({ screenLabels, listLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
|
|
695
|
+
declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
|
|
682
696
|
|
|
683
697
|
interface CheckAmountAndDetailScreenLabels {
|
|
684
698
|
title: string;
|
|
@@ -2,8 +2,8 @@ import "../../../shared/data-access/dist/lib/useCurrentUserQuery.js";
|
|
|
2
2
|
import "../../../shared/data-access/dist/index.js";
|
|
3
3
|
import "./index2.js";
|
|
4
4
|
import { useApprovalRequestsQuery as e } from "./index3.js";
|
|
5
|
-
import "./index4.js";
|
|
6
|
-
import "./index5.js";
|
|
7
|
-
import { useEntityUsersSearchQuery as
|
|
8
|
-
import { useEntityUsersByIdsQuery as
|
|
9
|
-
export { e as useApprovalRequestsQuery,
|
|
5
|
+
import { useApproveApprovalRequestMutation as t } from "./index4.js";
|
|
6
|
+
import { useRejectApprovalRequestMutation as n } from "./index5.js";
|
|
7
|
+
import { useEntityUsersSearchQuery as r } from "./index6.js";
|
|
8
|
+
import { useEntityUsersByIdsQuery as i } from "./index7.js";
|
|
9
|
+
export { e as useApprovalRequestsQuery, t as useApproveApprovalRequestMutation, i as useEntityUsersByIdsQuery, r as useEntityUsersSearchQuery, n as useRejectApprovalRequestMutation };
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import { getApprovalRequestsQueryKey as e } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
|
|
2
|
+
import { organizationHeaders as t } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
|
|
1
3
|
import "../../../shared/data-access/dist/index.js";
|
|
4
|
+
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index2.js
|
|
5
|
+
var n = ({ client: n, organizationId: r }) => e({
|
|
6
|
+
client: n,
|
|
7
|
+
headers: t(r)
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { n as approvalRequestsInvalidationKey };
|
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
+
import { postApprovalRequestsIdApprove as e } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
|
|
6
|
+
import { invalidateAllClients as t } from "../../../shared/data-access/dist/lib/clientRegistry.js";
|
|
7
|
+
import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
8
|
+
import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
|
|
5
9
|
import "../../../shared/data-access/dist/index.js";
|
|
6
|
-
import "./index2.js";
|
|
7
|
-
import "@tanstack/react-query";
|
|
10
|
+
import { approvalRequestsInvalidationKey as i } from "./index2.js";
|
|
11
|
+
import { useMutation as a } from "@tanstack/react-query";
|
|
12
|
+
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index4.js
|
|
13
|
+
function o() {
|
|
14
|
+
let { client: o, organizationId: s } = n();
|
|
15
|
+
return a({
|
|
16
|
+
mutationFn: async ({ approvalRequestId: t }) => {
|
|
17
|
+
let { data: n } = await e({
|
|
18
|
+
client: o,
|
|
19
|
+
headers: r(s),
|
|
20
|
+
path: { approval_request_id: t },
|
|
21
|
+
throwOnError: !0
|
|
22
|
+
});
|
|
23
|
+
return n;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: async () => {
|
|
26
|
+
await t(i({
|
|
27
|
+
client: o,
|
|
28
|
+
organizationId: s
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { o as useApproveApprovalRequestMutation };
|
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
+
import { postApprovalRequestsIdReject as e } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
|
|
6
|
+
import { invalidateAllClients as t } from "../../../shared/data-access/dist/lib/clientRegistry.js";
|
|
7
|
+
import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
8
|
+
import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
|
|
5
9
|
import "../../../shared/data-access/dist/index.js";
|
|
6
|
-
import "./index2.js";
|
|
7
|
-
import "@tanstack/react-query";
|
|
10
|
+
import { approvalRequestsInvalidationKey as i } from "./index2.js";
|
|
11
|
+
import { useMutation as a } from "@tanstack/react-query";
|
|
12
|
+
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index5.js
|
|
13
|
+
function o() {
|
|
14
|
+
let { client: o, organizationId: s } = n();
|
|
15
|
+
return a({
|
|
16
|
+
mutationFn: async ({ approvalRequestId: t, rejectReason: n }) => {
|
|
17
|
+
let i = n?.trim(), { data: a } = await e({
|
|
18
|
+
client: o,
|
|
19
|
+
headers: r(s),
|
|
20
|
+
path: { approval_request_id: t },
|
|
21
|
+
body: i ? { reject_reason: i } : void 0,
|
|
22
|
+
throwOnError: !0
|
|
23
|
+
});
|
|
24
|
+
return a;
|
|
25
|
+
},
|
|
26
|
+
onSuccess: async () => {
|
|
27
|
+
await t(i({
|
|
28
|
+
client: o,
|
|
29
|
+
organizationId: s
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { o as useRejectApprovalRequestMutation };
|
|
@@ -12,18 +12,20 @@ import "../../../../../shared/feature/dist/index.js";
|
|
|
12
12
|
import { ApprovalRequestsWidgetAnalyticsEvent as l, WIDGET_NAME as u } from "../analytics/events.js";
|
|
13
13
|
import { APPROVAL_REQUESTS_LIST_LABELS_EN as d } from "./labels.js";
|
|
14
14
|
import { getApprovalRequestPermissions as f } from "./permissions.js";
|
|
15
|
-
import {
|
|
15
|
+
import { useApprovalRequestDecisions as p } from "./useApprovalRequestDecisions.js";
|
|
16
|
+
import { ApprovalRequestsScreen as m } from "../../../../ui/dist/index4.js";
|
|
17
|
+
import { RejectApprovalRequestDialog as h } from "../../../../ui/dist/index5.js";
|
|
16
18
|
import "../../../../ui/dist/index.js";
|
|
17
|
-
import { useApprovalRequestsTable as
|
|
18
|
-
import { useEffect as
|
|
19
|
-
import { jsx as
|
|
19
|
+
import { useApprovalRequestsTable as g } from "./useApprovalRequestsTable.js";
|
|
20
|
+
import { useEffect as _, useMemo as v } from "react";
|
|
21
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
20
22
|
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
let
|
|
23
|
+
function S({ screenLabels: r, listLabels: u, rejectDialogLabels: S }) {
|
|
24
|
+
let C = n();
|
|
25
|
+
_(() => {
|
|
26
|
+
C(l.Mounted);
|
|
27
|
+
}, [C]);
|
|
28
|
+
let w = v(() => ({
|
|
27
29
|
...d,
|
|
28
30
|
...u,
|
|
29
31
|
status: {
|
|
@@ -34,37 +36,45 @@ function v({ screenLabels: r, listLabels: u }) {
|
|
|
34
36
|
...d.filters,
|
|
35
37
|
...u?.filters
|
|
36
38
|
}
|
|
37
|
-
}), [u]), { initResponse:
|
|
38
|
-
labels:
|
|
39
|
-
enabled:
|
|
39
|
+
}), [u]), { initResponse: T, widgetToken: E } = a(), D = c(), O = o(), k = s(), A = i(), { organizationStatus: j } = t(), M = v(() => f(k ? void 0 : T?.scopes), [k, T?.scopes]), N = !(!E || T || O) || D && !T || k, P = !!O && (!T || k), F = p(), I = g({
|
|
40
|
+
labels: w,
|
|
41
|
+
enabled: M.canRead,
|
|
42
|
+
pendingRequestIds: F.pendingRequestIds,
|
|
43
|
+
areDecisionsPaused: F.areDecisionsPaused
|
|
40
44
|
});
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
rows:
|
|
43
|
-
isLoading:
|
|
44
|
-
isError:
|
|
45
|
-
isAccessRestricted: !
|
|
46
|
-
pageSize:
|
|
47
|
-
onPageSizeChange:
|
|
48
|
-
pageSizeOptions:
|
|
49
|
-
hasNextPage:
|
|
50
|
-
hasPrevPage:
|
|
51
|
-
onNextPage:
|
|
52
|
-
onPrevPage:
|
|
53
|
-
emptyState:
|
|
54
|
-
filters:
|
|
55
|
-
onRetry:
|
|
45
|
+
return /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(m, {
|
|
46
|
+
rows: I.rows,
|
|
47
|
+
isLoading: I.isLoading || (N || e(j)) && I.rows.length === 0,
|
|
48
|
+
isError: P || I.isError,
|
|
49
|
+
isAccessRestricted: !N && !P && !M.canRead,
|
|
50
|
+
pageSize: I.pageSize,
|
|
51
|
+
onPageSizeChange: I.onPageSizeChange,
|
|
52
|
+
pageSizeOptions: I.pageSizeOptions,
|
|
53
|
+
hasNextPage: I.hasNextPage,
|
|
54
|
+
hasPrevPage: I.hasPrevPage,
|
|
55
|
+
onNextPage: I.onNextPage,
|
|
56
|
+
onPrevPage: I.onPrevPage,
|
|
57
|
+
emptyState: I.emptyState,
|
|
58
|
+
filters: I.filters,
|
|
59
|
+
onRetry: P ? A : I.onRetry,
|
|
60
|
+
onApprove: F.onApprove,
|
|
61
|
+
onReject: F.onReject,
|
|
56
62
|
labels: r
|
|
57
|
-
})
|
|
63
|
+
}), /* @__PURE__ */ b(h, {
|
|
64
|
+
...F.rejectDialog,
|
|
65
|
+
labels: S
|
|
66
|
+
})] });
|
|
58
67
|
}
|
|
59
|
-
function
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
...
|
|
68
|
+
function C({ screenLabels: e, listLabels: t, rejectDialogLabels: n, ...i }) {
|
|
69
|
+
return /* @__PURE__ */ b(r, {
|
|
70
|
+
...i,
|
|
62
71
|
widgetName: u,
|
|
63
|
-
children: /* @__PURE__ */
|
|
72
|
+
children: /* @__PURE__ */ b(S, {
|
|
64
73
|
screenLabels: e,
|
|
65
|
-
listLabels: t
|
|
74
|
+
listLabels: t,
|
|
75
|
+
rejectDialogLabels: n
|
|
66
76
|
})
|
|
67
77
|
});
|
|
68
78
|
}
|
|
69
79
|
//#endregion
|
|
70
|
-
export {
|
|
80
|
+
export { C as ApprovalRequestsWidget, C as default };
|
|
@@ -3,16 +3,17 @@ import { formatCalendarDate as t } from "../../../../../shared/util/dist/lib/for
|
|
|
3
3
|
import "../../../../../shared/util/dist/index.js";
|
|
4
4
|
import { STATUS_TONE as n } from "./constants.js";
|
|
5
5
|
import { NameLookupState as r } from "./useApprovalRequestNames.js";
|
|
6
|
+
import { canDecideApprovalRequest as i } from "./canDecideApprovalRequest.js";
|
|
6
7
|
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js
|
|
7
|
-
var
|
|
8
|
-
function
|
|
8
|
+
var a = { day: "2-digit" };
|
|
9
|
+
function o(t, n) {
|
|
9
10
|
let r = new Intl.NumberFormat("en-US", {
|
|
10
11
|
style: "currency",
|
|
11
12
|
currency: n
|
|
12
13
|
}).resolvedOptions().maximumFractionDigits ?? 2;
|
|
13
14
|
return e(n).format(t / 10 ** r);
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function s(e, t, n) {
|
|
16
17
|
if (!e) return n.missingValue;
|
|
17
18
|
let i = t.names.get(e);
|
|
18
19
|
if (i) return i;
|
|
@@ -22,21 +23,23 @@ function o(e, t, n) {
|
|
|
22
23
|
case r.Settled: return n.missingValue;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
-
return e.map(({ request: e, payable:
|
|
27
|
-
let
|
|
26
|
+
function c(e, r, c, { currentUserId: l, pendingRequestIds: u, areDecisionsPaused: d = !1 } = {}) {
|
|
27
|
+
return e.map(({ request: e, payable: f }) => {
|
|
28
|
+
let p = f?.amount_to_pay, m = f?.currency;
|
|
28
29
|
return {
|
|
29
30
|
id: e.id,
|
|
30
|
-
invoiceNumber:
|
|
31
|
-
vendor:
|
|
32
|
-
issueDate: t(
|
|
33
|
-
dueDate: t(
|
|
34
|
-
statusLabel:
|
|
31
|
+
invoiceNumber: f?.document_id || c.missingValue,
|
|
32
|
+
vendor: s(f?.counterpart_id, r.vendors, c),
|
|
33
|
+
issueDate: t(f?.issued_at, a) || c.missingValue,
|
|
34
|
+
dueDate: t(f?.due_date, a) || c.missingValue,
|
|
35
|
+
statusLabel: c.status[e.status],
|
|
35
36
|
statusTone: n[e.status],
|
|
36
|
-
amount: typeof
|
|
37
|
-
addedBy:
|
|
37
|
+
amount: typeof p == "number" && m ? o(p, m) : c.missingValue,
|
|
38
|
+
addedBy: s(e.created_by, r.users, c),
|
|
39
|
+
canDecide: i(e, l),
|
|
40
|
+
isDecisionPending: d || (u?.has(e.id) ?? !1)
|
|
38
41
|
};
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
44
|
//#endregion
|
|
42
|
-
export {
|
|
45
|
+
export { c as buildApprovalRequestRows };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/canDecideApprovalRequest.js
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (e.status !== "waiting") return !1;
|
|
4
|
+
let n = e.caller_is_policy_approver ?? !!(t && e.user_ids.includes(t)), r = !!(t && (e.approved_by ?? []).includes(t));
|
|
5
|
+
return n && !r;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as canDecideApprovalRequest };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { isOrganizationOnItsWay as e } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
|
|
6
|
+
import { useEmbedApi as t } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
7
|
+
import "../../../../../shared/data-access/dist/index.js";
|
|
8
|
+
import { useWidgetConfig as n, useWidgetInitStaleForToken as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
|
+
import "../../../../../shared/feature/dist/index.js";
|
|
10
|
+
import { useApproveApprovalRequestMutation as i } from "../../../../data-access/dist/index4.js";
|
|
11
|
+
import { useRejectApprovalRequestMutation as a } from "../../../../data-access/dist/index5.js";
|
|
12
|
+
import "../../../../data-access/dist/index.js";
|
|
13
|
+
import { useCallback as o, useState as s } from "react";
|
|
14
|
+
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js
|
|
15
|
+
var c = /* @__PURE__ */ new Set();
|
|
16
|
+
function l() {
|
|
17
|
+
let { mutateAsync: l } = i(), { mutateAsync: u } = a(), [d, f] = s(c), [p, m] = s(), [h, g] = s(""), { client: _, organizationId: v, organizationStatus: y } = t(), b = r(), x = e(y) || b, S = n().initResponse?.userId, C = b ? void 0 : S, [w, T] = s({
|
|
18
|
+
client: _,
|
|
19
|
+
organizationId: v,
|
|
20
|
+
userId: C
|
|
21
|
+
});
|
|
22
|
+
(_ !== w.client || v !== void 0 && v !== w.organizationId || C !== void 0 && C !== w.userId) && (T({
|
|
23
|
+
client: _,
|
|
24
|
+
organizationId: v === void 0 ? w.organizationId : v,
|
|
25
|
+
userId: C === void 0 ? w.userId : C
|
|
26
|
+
}), m(void 0));
|
|
27
|
+
let E = o(async (e, t) => {
|
|
28
|
+
f((t) => new Set(t).add(e));
|
|
29
|
+
try {
|
|
30
|
+
return await t(), !0;
|
|
31
|
+
} catch {
|
|
32
|
+
return !1;
|
|
33
|
+
} finally {
|
|
34
|
+
f((t) => {
|
|
35
|
+
let n = new Set(t);
|
|
36
|
+
return n.delete(e), n;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, []), D = o((e) => {
|
|
40
|
+
E(e, () => l({ approvalRequestId: e }));
|
|
41
|
+
}, [l, E]), O = o((e) => {
|
|
42
|
+
m(e), g("");
|
|
43
|
+
}, []), k = !!(p && d.has(p)), A = o(() => {
|
|
44
|
+
p && !x && E(p, () => u({
|
|
45
|
+
approvalRequestId: p,
|
|
46
|
+
rejectReason: h
|
|
47
|
+
})).then((e) => {
|
|
48
|
+
e && m((e) => e === p ? void 0 : e);
|
|
49
|
+
});
|
|
50
|
+
}, [
|
|
51
|
+
x,
|
|
52
|
+
u,
|
|
53
|
+
h,
|
|
54
|
+
p,
|
|
55
|
+
E
|
|
56
|
+
]), j = o(() => {
|
|
57
|
+
k || m(void 0);
|
|
58
|
+
}, [k]);
|
|
59
|
+
return {
|
|
60
|
+
pendingRequestIds: d,
|
|
61
|
+
areDecisionsPaused: x,
|
|
62
|
+
onApprove: D,
|
|
63
|
+
onReject: O,
|
|
64
|
+
rejectDialog: {
|
|
65
|
+
open: !!p,
|
|
66
|
+
reason: h,
|
|
67
|
+
onReasonChange: g,
|
|
68
|
+
onConfirm: A,
|
|
69
|
+
onCancel: j,
|
|
70
|
+
isPending: k,
|
|
71
|
+
isConfirmDisabled: x
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { l as useApprovalRequestDecisions };
|
|
@@ -7,9 +7,9 @@ import { useEmbedApi as t } from "../../../../../shared/data-access/dist/lib/Emb
|
|
|
7
7
|
import "../../../../../shared/data-access/dist/index.js";
|
|
8
8
|
import { useWidgetConfig as n } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
9
|
import "../../../../../shared/feature/dist/index.js";
|
|
10
|
-
import {
|
|
11
|
-
import { useEntityUsersSearchQuery as i } from "../../../../data-access/dist/index6.js";
|
|
10
|
+
import { useEntityUsersSearchQuery as r } from "../../../../data-access/dist/index6.js";
|
|
12
11
|
import "../../../../data-access/dist/index.js";
|
|
12
|
+
import { APPROVAL_REQUEST_STATUSES as i } from "./constants.js";
|
|
13
13
|
import { ApprovalRequestsFilterField as a } from "../../../../ui/dist/index3.js";
|
|
14
14
|
import "../../../../ui/dist/index.js";
|
|
15
15
|
import { useCallback as o, useEffect as s, useMemo as c, useState as l } from "react";
|
|
@@ -39,7 +39,7 @@ function y({ labels: y, onFiltersChange: b }) {
|
|
|
39
39
|
...e,
|
|
40
40
|
addedBy: void 0
|
|
41
41
|
})));
|
|
42
|
-
let P =
|
|
42
|
+
let P = r({
|
|
43
43
|
search: T,
|
|
44
44
|
enabled: D.activePanelId === a.AddedBy
|
|
45
45
|
}), F = o((e) => {
|
|
@@ -50,7 +50,7 @@ function y({ labels: y, onFiltersChange: b }) {
|
|
|
50
50
|
}, [b]), I = c(() => (P.data?.data ?? []).map((e) => ({
|
|
51
51
|
value: e.id,
|
|
52
52
|
label: v(e)
|
|
53
|
-
})), [P.data?.data]), L = c(() =>
|
|
53
|
+
})), [P.data?.data]), L = c(() => i.map((e) => ({
|
|
54
54
|
value: e,
|
|
55
55
|
label: y.status[e]
|
|
56
56
|
})), [y.status]), R = c(() => {
|
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
"use client";
|
|
5
5
|
import { useEmbedApi as e } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
6
6
|
import "../../../../../shared/data-access/dist/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useWidgetConfig as t } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
8
|
+
import "../../../../../shared/feature/dist/index.js";
|
|
8
9
|
import { useApprovalRequestsQuery as n } from "../../../../data-access/dist/index3.js";
|
|
9
10
|
import "../../../../data-access/dist/index.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { PAGE_SIZE_OPTIONS as r } from "./constants.js";
|
|
12
|
+
import { useApprovalRequestNames as i } from "./useApprovalRequestNames.js";
|
|
13
|
+
import { buildApprovalRequestRows as a } from "./buildApprovalRequestRows.js";
|
|
14
|
+
import { useApprovalRequestsFilters as o } from "./useApprovalRequestsFilters.js";
|
|
15
|
+
import { useCallback as s, useMemo as c, useState as l } from "react";
|
|
14
16
|
//#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js
|
|
15
|
-
function
|
|
17
|
+
function u(e, t) {
|
|
16
18
|
return e ? {
|
|
17
19
|
title: t.filterEmptyTitle,
|
|
18
20
|
description: t.filterEmptyDescription
|
|
@@ -21,45 +23,52 @@ function l(e, t) {
|
|
|
21
23
|
description: t.emptyDescription
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
|
-
function
|
|
25
|
-
let [
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
labels:
|
|
29
|
-
onFiltersChange:
|
|
30
|
-
}),
|
|
31
|
-
...
|
|
32
|
-
limit:
|
|
33
|
-
pagination_token:
|
|
34
|
-
enabled:
|
|
35
|
-
}),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
function d({ labels: d, enabled: f = !0, pendingRequestIds: p, areDecisionsPaused: m = !1 }) {
|
|
27
|
+
let [h, g] = l(r[0]), [_, v] = l(), { organizationId: y } = e(), [b, x] = l(y);
|
|
28
|
+
y && y !== b && (x(y), v(void 0));
|
|
29
|
+
let S = s(() => v(void 0), []), { filters: C, query: w, isFiltering: T } = o({
|
|
30
|
+
labels: d,
|
|
31
|
+
onFiltersChange: S
|
|
32
|
+
}), E = n({
|
|
33
|
+
...w,
|
|
34
|
+
limit: h,
|
|
35
|
+
pagination_token: _,
|
|
36
|
+
enabled: f
|
|
37
|
+
}), D = c(() => E.data?.data ?? [], [E.data]), O = i({ items: D }), k = t().initResponse?.userId ?? void 0, A = m || E.isPlaceholderData, j = c(() => a(D, O, d, {
|
|
38
|
+
currentUserId: k,
|
|
39
|
+
pendingRequestIds: p,
|
|
40
|
+
areDecisionsPaused: A
|
|
41
|
+
}), [
|
|
42
|
+
D,
|
|
43
|
+
O,
|
|
44
|
+
d,
|
|
45
|
+
k,
|
|
46
|
+
p,
|
|
47
|
+
A
|
|
48
|
+
]), M = E.isPlaceholderData ? void 0 : E.data, N = M?.next_pagination_token ?? void 0, P = M?.prev_pagination_token ?? void 0, F = s((e) => {
|
|
49
|
+
g(e), v(void 0);
|
|
50
|
+
}, []), I = s(() => {
|
|
51
|
+
N && v(N);
|
|
52
|
+
}, [N]), L = s(() => {
|
|
53
|
+
P && v(P);
|
|
54
|
+
}, [P]), { refetch: R } = E, z = s(() => {
|
|
55
|
+
R();
|
|
56
|
+
}, [R]);
|
|
48
57
|
return {
|
|
49
|
-
rows:
|
|
50
|
-
isLoading:
|
|
51
|
-
isError:
|
|
52
|
-
pageSize:
|
|
53
|
-
pageSizeOptions:
|
|
54
|
-
onPageSizeChange:
|
|
55
|
-
hasNextPage: !!
|
|
56
|
-
hasPrevPage: !!
|
|
57
|
-
onNextPage:
|
|
58
|
-
onPrevPage:
|
|
59
|
-
filters:
|
|
60
|
-
emptyState:
|
|
61
|
-
onRetry:
|
|
58
|
+
rows: j,
|
|
59
|
+
isLoading: E.isLoading,
|
|
60
|
+
isError: E.isError,
|
|
61
|
+
pageSize: h,
|
|
62
|
+
pageSizeOptions: r,
|
|
63
|
+
onPageSizeChange: F,
|
|
64
|
+
hasNextPage: !!N,
|
|
65
|
+
hasPrevPage: !!P,
|
|
66
|
+
onNextPage: I,
|
|
67
|
+
onPrevPage: L,
|
|
68
|
+
filters: C,
|
|
69
|
+
emptyState: u(T, d),
|
|
70
|
+
onRetry: z
|
|
62
71
|
};
|
|
63
72
|
}
|
|
64
73
|
//#endregion
|
|
65
|
-
export {
|
|
74
|
+
export { u as selectEmptyState, d as useApprovalRequestsTable };
|
package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./index2.js";
|
|
2
2
|
import { ApprovalRequestsFilterField as e } from "./index3.js";
|
|
3
3
|
import { ApprovalRequestsScreen as t } from "./index4.js";
|
|
4
|
-
|
|
4
|
+
import { RejectApprovalRequestDialog as n } from "./index5.js";
|
|
5
|
+
export { e as ApprovalRequestsFilterField, t as ApprovalRequestsScreen, n as RejectApprovalRequestDialog };
|
package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js
CHANGED
|
@@ -24,6 +24,10 @@ var n = {
|
|
|
24
24
|
columnStatus: "Status",
|
|
25
25
|
columnAmount: "Amount",
|
|
26
26
|
columnAddedBy: "Added by",
|
|
27
|
+
columnActions: "Actions",
|
|
28
|
+
rowActions: "Request actions",
|
|
29
|
+
approve: "Approve request",
|
|
30
|
+
reject: "Reject request",
|
|
27
31
|
loadingValue: "Loading",
|
|
28
32
|
errorTitle: "Couldn't load approval requests",
|
|
29
33
|
errorDescription: "Try again.",
|
|
@@ -31,6 +35,14 @@ var n = {
|
|
|
31
35
|
filterBar: n,
|
|
32
36
|
accessRestrictedTitle: "Access restricted",
|
|
33
37
|
accessRestrictedDescription: "You don't have permission to view approval requests."
|
|
38
|
+
}, i = {
|
|
39
|
+
title: "Reject this request?",
|
|
40
|
+
description: "The bill is rejected and nobody else is asked to approve it.",
|
|
41
|
+
reason: "Reason",
|
|
42
|
+
optionalNote: "(optional)",
|
|
43
|
+
confirm: "Reject request",
|
|
44
|
+
cancel: "Cancel",
|
|
45
|
+
close: "Close"
|
|
34
46
|
};
|
|
35
47
|
//#endregion
|
|
36
|
-
export { n as APPROVAL_REQUESTS_FILTER_BAR_LABELS_EN, r as APPROVAL_REQUESTS_SCREEN_LABELS_EN };
|
|
48
|
+
export { n as APPROVAL_REQUESTS_FILTER_BAR_LABELS_EN, r as APPROVAL_REQUESTS_SCREEN_LABELS_EN, i as REJECT_APPROVAL_REQUEST_DIALOG_LABELS_EN };
|