@tesouro/embedded-components-react 0.9.40 → 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 (23) hide show
  1. package/dist/experimental/ApprovalRequests.d.ts +57 -2
  2. package/dist/experimental/index.d.ts +57 -2
  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/data-access/dist/index6.js +22 -1
  8. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js +49 -34
  9. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js +17 -14
  10. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/canDecideApprovalRequest.js +8 -0
  11. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/constants.js +7 -2
  12. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/labels.js +7 -0
  13. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js +76 -0
  14. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsFilters.js +149 -0
  15. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js +53 -38
  16. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js +4 -2
  17. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js +32 -2
  18. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index3.js +136 -92
  19. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index4.js +137 -0
  20. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index5.js +44 -0
  21. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  22. package/dist/packages/shared-ui-shadcn/dist/index.js +3432 -3332
  23. package/package.json +1 -1
@@ -333,6 +333,21 @@ type EmbeddedClient = Client;
333
333
  type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
334
334
  type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
335
335
 
336
+ interface FilterMenuButtonLabels {
337
+ /** Button text, followed by "(N)" when `activeCount` is set. */
338
+ filters: string;
339
+ }
340
+
341
+ interface FilterTagLabels {
342
+ /**
343
+ * Accessible name for the editable tag body. `{label}` is substituted with
344
+ * the tag's own text; keep the placeholder when overriding.
345
+ */
346
+ edit: string;
347
+ /** Accessible name for the × dismiss button. `{label}` is substituted. */
348
+ remove: string;
349
+ }
350
+
336
351
  type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
337
352
  children?: ReactNode;
338
353
  };
@@ -598,6 +613,23 @@ interface WidgetProviderProps extends WidgetProviderBaseProps {
598
613
  providerLabels?: Partial<WidgetProviderLabels>;
599
614
  }
600
615
 
616
+ interface ApprovalRequestsFilterBarLabels {
617
+ fields: {
618
+ status: string;
619
+ addedBy: string;
620
+ requestedOn: string;
621
+ };
622
+ fieldMenuLabel: string;
623
+ onlyMine: string;
624
+ userSearchLabel: string;
625
+ userSearchPlaceholder: string;
626
+ userEmpty: string;
627
+ userLoading: string;
628
+ userError: string;
629
+ clearAll: string;
630
+ filterMenuButton: FilterMenuButtonLabels;
631
+ filterTag: FilterTagLabels;
632
+ }
601
633
  interface ApprovalRequestsScreenLabels {
602
634
  columnInvoiceNumber: string;
603
635
  columnVendor: string;
@@ -606,15 +638,36 @@ interface ApprovalRequestsScreenLabels {
606
638
  columnStatus: string;
607
639
  columnAmount: string;
608
640
  columnAddedBy: string;
641
+ columnActions: string;
642
+ rowActions: string;
643
+ approve: string;
644
+ reject: string;
609
645
  /** Read by screen readers in a cell whose name is still loading. */
610
646
  loadingValue: string;
611
647
  errorTitle: string;
612
648
  errorDescription: string;
613
649
  errorRetry: string;
650
+ filterBar: ApprovalRequestsFilterBarLabels;
614
651
  accessRestrictedTitle: string;
615
652
  accessRestrictedDescription: string;
616
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
+ }
617
663
 
664
+ interface ApprovalRequestsFilterLabels {
665
+ statusChip: (value: string) => string;
666
+ addedByChip: (name: string) => string;
667
+ requestedOnChip: (range: string) => string;
668
+ moreSelected: (first: string, count: number) => string;
669
+ dateRange: (from: string, to: string) => string;
670
+ }
618
671
  interface ApprovalRequestsListLabels {
619
672
  emptyTitle: string;
620
673
  emptyDescription: string;
@@ -625,11 +678,13 @@ interface ApprovalRequestsListLabels {
625
678
  /** Shown for a vendor or creator this session may not read, or whose lookup failed. */
626
679
  unavailableValue: string;
627
680
  status: Record<ApprovalRequestStatus, string>;
681
+ filters: ApprovalRequestsFilterLabels;
628
682
  }
629
683
 
630
684
  interface ApprovalRequestsWidgetOwnProps {
631
- screenLabels?: Partial<ApprovalRequestsScreenLabels>;
685
+ screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
632
686
  listLabels?: PartialDeep<ApprovalRequestsListLabels>;
687
+ rejectDialogLabels?: Partial<RejectApprovalRequestDialogLabels>;
633
688
  }
634
689
  /** Public props for {@link ApprovalRequestsWidget}. */
635
690
  type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
@@ -637,7 +692,7 @@ type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetO
637
692
  * Self-contained approval requests widget, a native port of Monite's approval
638
693
  * requests (FOPS-97). Exported only from the package's `/experimental` entry.
639
694
  */
640
- declare function ApprovalRequestsWidget({ screenLabels, listLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
695
+ declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
641
696
 
642
697
  export { ApprovalRequestsWidget };
643
698
  export type { ApprovalRequestsWidgetProps };
@@ -333,6 +333,21 @@ type EmbeddedClient = Client;
333
333
  type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
334
334
  type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
335
335
 
336
+ interface FilterMenuButtonLabels {
337
+ /** Button text, followed by "(N)" when `activeCount` is set. */
338
+ filters: string;
339
+ }
340
+
341
+ interface FilterTagLabels {
342
+ /**
343
+ * Accessible name for the editable tag body. `{label}` is substituted with
344
+ * the tag's own text; keep the placeholder when overriding.
345
+ */
346
+ edit: string;
347
+ /** Accessible name for the × dismiss button. `{label}` is substituted. */
348
+ remove: string;
349
+ }
350
+
336
351
  type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
337
352
  children?: ReactNode;
338
353
  };
@@ -598,6 +613,23 @@ interface WidgetProviderProps extends WidgetProviderBaseProps {
598
613
  providerLabels?: Partial<WidgetProviderLabels>;
599
614
  }
600
615
 
616
+ interface ApprovalRequestsFilterBarLabels {
617
+ fields: {
618
+ status: string;
619
+ addedBy: string;
620
+ requestedOn: string;
621
+ };
622
+ fieldMenuLabel: string;
623
+ onlyMine: string;
624
+ userSearchLabel: string;
625
+ userSearchPlaceholder: string;
626
+ userEmpty: string;
627
+ userLoading: string;
628
+ userError: string;
629
+ clearAll: string;
630
+ filterMenuButton: FilterMenuButtonLabels;
631
+ filterTag: FilterTagLabels;
632
+ }
601
633
  interface ApprovalRequestsScreenLabels {
602
634
  columnInvoiceNumber: string;
603
635
  columnVendor: string;
@@ -606,15 +638,36 @@ interface ApprovalRequestsScreenLabels {
606
638
  columnStatus: string;
607
639
  columnAmount: string;
608
640
  columnAddedBy: string;
641
+ columnActions: string;
642
+ rowActions: string;
643
+ approve: string;
644
+ reject: string;
609
645
  /** Read by screen readers in a cell whose name is still loading. */
610
646
  loadingValue: string;
611
647
  errorTitle: string;
612
648
  errorDescription: string;
613
649
  errorRetry: string;
650
+ filterBar: ApprovalRequestsFilterBarLabels;
614
651
  accessRestrictedTitle: string;
615
652
  accessRestrictedDescription: string;
616
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
+ }
617
663
 
664
+ interface ApprovalRequestsFilterLabels {
665
+ statusChip: (value: string) => string;
666
+ addedByChip: (name: string) => string;
667
+ requestedOnChip: (range: string) => string;
668
+ moreSelected: (first: string, count: number) => string;
669
+ dateRange: (from: string, to: string) => string;
670
+ }
618
671
  interface ApprovalRequestsListLabels {
619
672
  emptyTitle: string;
620
673
  emptyDescription: string;
@@ -625,11 +678,13 @@ interface ApprovalRequestsListLabels {
625
678
  /** Shown for a vendor or creator this session may not read, or whose lookup failed. */
626
679
  unavailableValue: string;
627
680
  status: Record<ApprovalRequestStatus, string>;
681
+ filters: ApprovalRequestsFilterLabels;
628
682
  }
629
683
 
630
684
  interface ApprovalRequestsWidgetOwnProps {
631
- screenLabels?: Partial<ApprovalRequestsScreenLabels>;
685
+ screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
632
686
  listLabels?: PartialDeep<ApprovalRequestsListLabels>;
687
+ rejectDialogLabels?: Partial<RejectApprovalRequestDialogLabels>;
633
688
  }
634
689
  /** Public props for {@link ApprovalRequestsWidget}. */
635
690
  type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
@@ -637,7 +692,7 @@ type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetO
637
692
  * Self-contained approval requests widget, a native port of Monite's approval
638
693
  * requests (FOPS-97). Exported only from the package's `/experimental` entry.
639
694
  */
640
- declare function ApprovalRequestsWidget({ screenLabels, listLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
695
+ declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
641
696
 
642
697
  interface CheckAmountAndDetailScreenLabels {
643
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 "./index6.js";
8
- import { useEntityUsersByIdsQuery as t } from "./index7.js";
9
- export { e as useApprovalRequestsQuery, t as useEntityUsersByIdsQuery };
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 };
@@ -2,5 +2,26 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
+ import { getEntityUsersOptions as e } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
6
+ import { withAuthEpoch as t } from "../../../shared/data-access/dist/lib/withAuthEpoch.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 "@tanstack/react-query";
10
+ import { useQuery as i } from "@tanstack/react-query";
11
+ //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index6.js
12
+ function a({ search: a, enabled: o } = {}) {
13
+ let { client: s, organizationId: c, widgetToken: l, authEpoch: u, organizationStatus: d } = n(), f = e({
14
+ client: s,
15
+ headers: r(c),
16
+ query: { name__istartswith: a || void 0 }
17
+ });
18
+ return i({
19
+ ...t(f, {
20
+ authEpoch: u,
21
+ organizationStatus: d
22
+ }, { carryWithinOrg: !0 }),
23
+ enabled: !!(c && l) && (o === !0 || o === void 0)
24
+ });
25
+ }
26
+ //#endregion
27
+ export { a as useEntityUsersSearchQuery };
@@ -12,54 +12,69 @@ 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 { useApprovalRequestsTable as p } from "./useApprovalRequestsTable.js";
16
- import { ApprovalRequestsScreen as m } from "../../../../ui/dist/index3.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";
17
18
  import "../../../../ui/dist/index.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: {
30
32
  ...d.status,
31
33
  ...u?.status
34
+ },
35
+ filters: {
36
+ ...d.filters,
37
+ ...u?.filters
32
38
  }
33
- }), [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 = p({
34
- labels: y,
35
- 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
36
44
  });
37
- return /* @__PURE__ */ _(m, {
38
- rows: A.rows,
39
- isLoading: A.isLoading || (O || e(E)) && A.rows.length === 0,
40
- isError: k || A.isError,
41
- isAccessRestricted: !O && !k && !D.canRead,
42
- pageSize: A.pageSize,
43
- onPageSizeChange: A.onPageSizeChange,
44
- pageSizeOptions: A.pageSizeOptions,
45
- hasNextPage: A.hasNextPage,
46
- hasPrevPage: A.hasPrevPage,
47
- onNextPage: A.onNextPage,
48
- onPrevPage: A.onPrevPage,
49
- emptyState: A.emptyState,
50
- 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,
51
62
  labels: r
52
- });
63
+ }), /* @__PURE__ */ b(h, {
64
+ ...F.rejectDialog,
65
+ labels: S
66
+ })] });
53
67
  }
54
- function y({ screenLabels: e, listLabels: t, ...n }) {
55
- return /* @__PURE__ */ _(r, {
56
- ...n,
68
+ function C({ screenLabels: e, listLabels: t, rejectDialogLabels: n, ...i }) {
69
+ return /* @__PURE__ */ b(r, {
70
+ ...i,
57
71
  widgetName: u,
58
- children: /* @__PURE__ */ _(v, {
72
+ children: /* @__PURE__ */ b(S, {
59
73
  screenLabels: e,
60
- listLabels: t
74
+ listLabels: t,
75
+ rejectDialogLabels: n
61
76
  })
62
77
  });
63
78
  }
64
79
  //#endregion
65
- 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 };
@@ -9,6 +9,11 @@ var e = [
9
9
  approved: "success",
10
10
  rejected: "destructive",
11
11
  canceled: "neutral"
12
- };
12
+ }, n = [
13
+ "waiting",
14
+ "approved",
15
+ "rejected",
16
+ "canceled"
17
+ ];
13
18
  //#endregion
14
- export { e as PAGE_SIZE_OPTIONS, t as STATUS_TONE };
19
+ export { n as APPROVAL_REQUEST_STATUSES, e as PAGE_SIZE_OPTIONS, t as STATUS_TONE };
@@ -11,6 +11,13 @@ var e = {
11
11
  approved: "Approved",
12
12
  rejected: "Rejected",
13
13
  canceled: "Canceled"
14
+ },
15
+ filters: {
16
+ statusChip: (e) => `Status: ${e}`,
17
+ addedByChip: (e) => `Added by: ${e}`,
18
+ requestedOnChip: (e) => `Requested on: ${e}`,
19
+ moreSelected: (e, t) => `${e} + ${t} more`,
20
+ dateRange: (e, t) => `${e} - ${t}`
14
21
  }
15
22
  };
16
23
  //#endregion
@@ -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 };