@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.
Files changed (19) hide show
  1. package/dist/experimental/ApprovalRequests.d.ts +15 -1
  2. package/dist/experimental/index.d.ts +15 -1
  3. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index.js +5 -5
  4. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index2.js +9 -0
  5. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index4.js +29 -2
  6. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index5.js +30 -2
  7. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js +45 -35
  8. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js +17 -14
  9. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/canDecideApprovalRequest.js +8 -0
  10. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js +76 -0
  11. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsFilters.js +4 -4
  12. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js +53 -44
  13. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js +2 -1
  14. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js +13 -1
  15. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index4.js +91 -58
  16. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index5.js +44 -0
  17. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  18. package/dist/packages/shared-ui-shadcn/dist/index.js +3432 -3332
  19. 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 t } from "./index6.js";
8
- import { useEntityUsersByIdsQuery as n } from "./index7.js";
9
- export { e as useApprovalRequestsQuery, n as useEntityUsersByIdsQuery, t as useEntityUsersSearchQuery };
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 { ApprovalRequestsScreen as p } from "../../../../ui/dist/index4.js";
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 m } from "./useApprovalRequestsTable.js";
18
- import { useEffect as h, useMemo as g } from "react";
19
- import { jsx as _ } from "react/jsx-runtime";
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 v({ screenLabels: r, listLabels: u }) {
22
- let v = n();
23
- h(() => {
24
- v(l.Mounted);
25
- }, [v]);
26
- let y = g(() => ({
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: b, widgetToken: x } = a(), S = c(), C = o(), w = s(), T = i(), { organizationStatus: E } = t(), D = g(() => f(w ? void 0 : b?.scopes), [w, b?.scopes]), O = !(!x || b || C) || S && !b || w, k = !!C && (!b || w), A = m({
38
- labels: y,
39
- enabled: D.canRead
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__ */ _(p, {
42
- rows: A.rows,
43
- isLoading: A.isLoading || (O || e(E)) && A.rows.length === 0,
44
- isError: k || A.isError,
45
- isAccessRestricted: !O && !k && !D.canRead,
46
- pageSize: A.pageSize,
47
- onPageSizeChange: A.onPageSizeChange,
48
- pageSizeOptions: A.pageSizeOptions,
49
- hasNextPage: A.hasNextPage,
50
- hasPrevPage: A.hasPrevPage,
51
- onNextPage: A.onNextPage,
52
- onPrevPage: A.onPrevPage,
53
- emptyState: A.emptyState,
54
- filters: A.filters,
55
- onRetry: k ? T : A.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 y({ screenLabels: e, listLabels: t, ...n }) {
60
- return /* @__PURE__ */ _(r, {
61
- ...n,
68
+ function C({ screenLabels: e, listLabels: t, rejectDialogLabels: n, ...i }) {
69
+ return /* @__PURE__ */ b(r, {
70
+ ...i,
62
71
  widgetName: u,
63
- children: /* @__PURE__ */ _(v, {
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 { y as ApprovalRequestsWidget, y as default };
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 i = { day: "2-digit" };
8
- function a(t, n) {
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 o(e, t, n) {
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 s(e, r, s) {
26
- return e.map(({ request: e, payable: c }) => {
27
- let l = c?.amount_to_pay, u = c?.currency;
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: c?.document_id || s.missingValue,
31
- vendor: o(c?.counterpart_id, r.vendors, s),
32
- issueDate: t(c?.issued_at, i) || s.missingValue,
33
- dueDate: t(c?.due_date, i) || s.missingValue,
34
- statusLabel: s.status[e.status],
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 l == "number" && u ? a(l, u) : s.missingValue,
37
- addedBy: o(e.created_by, r.users, s)
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 { s as buildApprovalRequestRows };
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 { APPROVAL_REQUEST_STATUSES as r } from "./constants.js";
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 = i({
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(() => r.map((e) => ({
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 { PAGE_SIZE_OPTIONS as t } from "./constants.js";
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 { useApprovalRequestNames as r } from "./useApprovalRequestNames.js";
11
- import { buildApprovalRequestRows as i } from "./buildApprovalRequestRows.js";
12
- import { useApprovalRequestsFilters as a } from "./useApprovalRequestsFilters.js";
13
- import { useCallback as o, useMemo as s, useState as c } from "react";
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 l(e, t) {
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 u({ labels: u, enabled: d = !0 }) {
25
- let [f, p] = c(t[0]), [m, h] = c(), { organizationId: g } = e(), [_, v] = c(g);
26
- g && g !== _ && (v(g), h(void 0));
27
- let y = o(() => h(void 0), []), { filters: b, query: x, isFiltering: S } = a({
28
- labels: u,
29
- onFiltersChange: y
30
- }), C = n({
31
- ...x,
32
- limit: f,
33
- pagination_token: m,
34
- enabled: d
35
- }), w = s(() => C.data?.data ?? [], [C.data]), T = r({ items: w }), E = s(() => i(w, T, u), [
36
- w,
37
- T,
38
- u
39
- ]), D = C.isPlaceholderData ? void 0 : C.data, O = D?.next_pagination_token ?? void 0, k = D?.prev_pagination_token ?? void 0, A = o((e) => {
40
- p(e), h(void 0);
41
- }, []), j = o(() => {
42
- O && h(O);
43
- }, [O]), M = o(() => {
44
- k && h(k);
45
- }, [k]), { refetch: N } = C, P = o(() => {
46
- N();
47
- }, [N]);
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: E,
50
- isLoading: C.isLoading,
51
- isError: C.isError,
52
- pageSize: f,
53
- pageSizeOptions: t,
54
- onPageSizeChange: A,
55
- hasNextPage: !!O,
56
- hasPrevPage: !!k,
57
- onNextPage: j,
58
- onPrevPage: M,
59
- filters: b,
60
- emptyState: l(S, u),
61
- onRetry: P
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 { l as selectEmptyState, u as useApprovalRequestsTable };
74
+ export { u as selectEmptyState, d as useApprovalRequestsTable };
@@ -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
- export { e as ApprovalRequestsFilterField, t as ApprovalRequestsScreen };
4
+ import { RejectApprovalRequestDialog as n } from "./index5.js";
5
+ export { e as ApprovalRequestsFilterField, t as ApprovalRequestsScreen, n as RejectApprovalRequestDialog };
@@ -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 };