@tesouro/embedded-components-react 0.9.59 → 0.10.2

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 (68) hide show
  1. package/README.md +0 -13
  2. package/dist/{lib/AccountsQuickViewWidget.d.ts → experimental/QuickViewWidget.d.ts} +112 -15
  3. package/dist/experimental/QuickViewWidget.js +4 -0
  4. package/dist/experimental/index.d.ts +137 -96
  5. package/dist/experimental/index.js +4 -3
  6. package/dist/index.d.ts +3 -53
  7. package/dist/index.js +7 -9
  8. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/accounts/data-access/dist/index2.js +20 -0
  9. package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/feature/dist/lib/AccountsQuickViewWidget/AccountsQuickViewWidgetFeature.js +15 -15
  10. package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/feature/dist/lib/AccountsQuickViewWidget/labels.js +1 -1
  11. package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/feature/dist/lib/AccountsQuickViewWidget/testIds.js +1 -1
  12. package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/feature/dist/lib/accountsBalanceSummary/summarizeAccountBalances.js +3 -3
  13. package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/feature/dist/lib/accountsBalanceSummary/useAccountsBalanceSummary.js +1 -1
  14. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/accounts/feature/dist/lib/analytics/events.js +4 -0
  15. package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/ui/dist/index2.js +1 -1
  16. package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/ui/dist/index3.js +3 -3
  17. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/feature/dist/index.js +3 -0
  18. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/feature/dist/lib/QuickViewWidget/QuickViewWidget.js +56 -0
  19. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/feature/dist/lib/QuickViewWidget/labels.js +10 -0
  20. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/data-access/dist/index.js +1 -0
  21. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/data-access/dist/index2.js +118 -0
  22. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/feature/dist/index.js +3 -0
  23. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/feature/dist/lib/InvoicesQuickViewWidget/InvoicesQuickViewWidgetFeature.js +106 -0
  24. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/feature/dist/lib/InvoicesQuickViewWidget/labels.js +16 -0
  25. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/feature/dist/lib/InvoicesQuickViewWidget/summarizeOpenInvoices.js +19 -0
  26. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/feature/dist/lib/InvoicesQuickViewWidget/testIds.js +7 -0
  27. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/feature/dist/lib/InvoicesQuickViewWidget/useOpenInvoicesSummary.js +25 -0
  28. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/feature/dist/lib/analytics/events.js +4 -0
  29. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/ui/dist/index.js +3 -0
  30. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/ui/dist/index2.js +8 -0
  31. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/ui/dist/index3.js +32 -0
  32. package/dist/libs/tesouro-embedded-components-react/quick-view-widget/shared/util/dist/lib/widgetName.js +3 -0
  33. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  34. package/dist/libs/tesouro-embedded-components-react/shared/quick-view/ui/dist/index3.js +38 -37
  35. package/dist/packages/shared-ui-shadcn/dist/index.js +3374 -3474
  36. package/package.json +1 -1
  37. package/dist/experimental/ApprovalRequests.d.ts +0 -706
  38. package/dist/experimental/ApprovalRequests.js +0 -2
  39. package/dist/lib/AccountsQuickViewWidget.js +0 -4
  40. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/data-access/dist/index2.js +0 -20
  41. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/analytics/events.js +0 -3
  42. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index.js +0 -9
  43. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index2.js +0 -9
  44. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index3.js +0 -71
  45. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index4.js +0 -33
  46. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index5.js +0 -34
  47. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index6.js +0 -26
  48. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index7.js +0 -30
  49. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/index.js +0 -1
  50. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js +0 -89
  51. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js +0 -44
  52. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/canDecideApprovalRequest.js +0 -7
  53. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/constants.js +0 -18
  54. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/labels.js +0 -28
  55. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/permissions.js +0 -8
  56. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js +0 -93
  57. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestNames.js +0 -65
  58. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsFilters.js +0 -148
  59. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js +0 -73
  60. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/analytics/events.js +0 -3
  61. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js +0 -5
  62. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js +0 -47
  63. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index3.js +0 -142
  64. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index4.js +0 -136
  65. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index5.js +0 -43
  66. /package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/data-access/dist/index.js +0 -0
  67. /package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/feature/dist/index.js +0 -0
  68. /package/dist/libs/tesouro-embedded-components-react/{accounts-quick-view-widget → quick-view-widget/accounts}/ui/dist/index.js +0 -0
@@ -1,2 +0,0 @@
1
- export { ApprovalRequestsWidget } from "../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js";
2
- import "../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/index.js";
@@ -1,4 +0,0 @@
1
- import { ACCOUNTS_QUICK_VIEW_WIDGET_LABELS_EN as e } from "../libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/AccountsQuickViewWidget/labels.js";
2
- import { AccountsQuickViewWidget as t } from "../libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/AccountsQuickViewWidget/AccountsQuickViewWidgetFeature.js";
3
- import "../libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/index.js";
4
- export { e as ACCOUNTS_QUICK_VIEW_WIDGET_LABELS_EN, t as AccountsQuickViewWidget };
@@ -1,20 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { isAllPagesResolving as e } from "../../../shared/data-access/dist/lib/allPages.js";
6
- import { useAllBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
7
- import "../../../shared/data-access/dist/index.js";
8
- // ../../libs/tesouro-embedded-components-react/accounts-quick-view-widget/data-access/dist/index2.js
9
- function n({ enabled: n } = {}) {
10
- let r = t({ enabled: n }), { data: i, isLoading: a, isError: o, isPlaceholderData: s, refetch: c } = r;
11
- return {
12
- accounts: i?.data,
13
- isLoading: a,
14
- isError: o,
15
- isPlaceholderData: s,
16
- isResolving: e(r),
17
- refetch: c
18
- };
19
- }
20
- export { n as useQuickViewBankAccountsQuery };
@@ -1,3 +0,0 @@
1
- // ../../libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/analytics/events.js
2
- var e = { Mounted: "accounts_quick_view_widget.mounted" }, t = "accounts_quick_view_widget";
3
- export { e as AccountsQuickViewWidgetAnalyticsEvent, t as WIDGET_NAME };
@@ -1,9 +0,0 @@
1
- import "../../../shared/data-access/dist/lib/useCurrentUserQuery.js";
2
- import "../../../shared/data-access/dist/index.js";
3
- import "./index2.js";
4
- import { useApprovalRequestsQuery as e } from "./index3.js";
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,9 +0,0 @@
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";
3
- import "../../../shared/data-access/dist/index.js";
4
- // ../../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
- export { n as approvalRequestsInvalidationKey };
@@ -1,71 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { getApprovalRequests as e, getPayables as t } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
6
- import { getApprovalRequestsQueryKey as n } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
- import { withAuthEpoch as r } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
8
- import { useEmbedApi as i } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
9
- import { organizationHeaders as a } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
10
- import "../../../shared/data-access/dist/index.js";
11
- import { queryOptions as o, useQuery as s } from "@tanstack/react-query";
12
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index3.js
13
- var c = "with-payables";
14
- async function l({ client: n, headers: r, query: i, signal: a }) {
15
- let { data: o } = await e({
16
- client: n,
17
- headers: r,
18
- query: i,
19
- signal: a,
20
- throwOnError: !0
21
- }), s = [...new Set(o.data.map((e) => e.object_id))], c = /* @__PURE__ */ new Map();
22
- if (s.length > 0) {
23
- let { data: e } = await t({
24
- client: n,
25
- headers: r,
26
- query: {
27
- id__in: s,
28
- limit: s.length
29
- },
30
- signal: a,
31
- throwOnError: !0
32
- });
33
- for (let t of e.data) c.set(t.id, t);
34
- }
35
- return {
36
- data: o.data.map((e) => ({
37
- request: e,
38
- payable: c.get(e.object_id)
39
- })),
40
- next_pagination_token: o.next_pagination_token,
41
- prev_pagination_token: o.prev_pagination_token
42
- };
43
- }
44
- function u({ enabled: e, ...t } = {}) {
45
- let { client: u, organizationId: d, widgetToken: f, authEpoch: p, organizationStatus: m } = i(), h = a(d), g = {
46
- ...t,
47
- sort: "updated_at",
48
- order: "desc",
49
- object_type: "payable"
50
- };
51
- return s({
52
- ...r(o({
53
- queryKey: [...n({
54
- client: u,
55
- headers: h,
56
- query: g
57
- }), c],
58
- queryFn: ({ signal: e }) => l({
59
- client: u,
60
- headers: h,
61
- query: g,
62
- signal: e
63
- })
64
- }), {
65
- authEpoch: p,
66
- organizationStatus: m
67
- }, { carryWithinOrg: !0 }),
68
- enabled: !!(d && f) && (e === !0 || e === void 0)
69
- });
70
- }
71
- export { u as useApprovalRequestsQuery };
@@ -1,33 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
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";
9
- import "../../../shared/data-access/dist/index.js";
10
- import { approvalRequestsInvalidationKey as i } from "./index2.js";
11
- import { useMutation as a } from "@tanstack/react-query";
12
- // ../../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
- export { o as useApproveApprovalRequestMutation };
@@ -1,34 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
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";
9
- import "../../../shared/data-access/dist/index.js";
10
- import { approvalRequestsInvalidationKey as i } from "./index2.js";
11
- import { useMutation as a } from "@tanstack/react-query";
12
- // ../../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
- export { o as useRejectApprovalRequestMutation };
@@ -1,26 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
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";
9
- import "../../../shared/data-access/dist/index.js";
10
- import { useQuery as i } from "@tanstack/react-query";
11
- // ../../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
- export { a as useEntityUsersSearchQuery };
@@ -1,30 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
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";
9
- import "../../../shared/data-access/dist/index.js";
10
- import { useMemo as i } from "react";
11
- import { useQuery as a } from "@tanstack/react-query";
12
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index7.js
13
- function o({ ids: o, enabled: s }) {
14
- let { client: c, organizationId: l, widgetToken: u, authEpoch: d, organizationStatus: f } = n(), p = i(() => [...new Set(o.filter(Boolean))].sort().slice(0, 100), [o]), m = e({
15
- client: c,
16
- headers: r(l),
17
- query: {
18
- id__in: p,
19
- limit: 100
20
- }
21
- });
22
- return a({
23
- ...t(m, {
24
- authEpoch: d,
25
- organizationStatus: f
26
- }, { carryWithinOrg: !0 }),
27
- enabled: !!(l && u) && (s === !0 || s === void 0) && p.length > 0
28
- });
29
- }
30
- export { o as useEntityUsersByIdsQuery };
@@ -1 +0,0 @@
1
- export { ApprovalRequestsWidget } from "./lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js";
@@ -1,89 +0,0 @@
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 { 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";
13
- import "../../../../../shared/feature/dist/index.js";
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";
20
- import "../../../../ui/dist/index.js";
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";
24
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js
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,
32
- ...d,
33
- status: {
34
- ...f.status,
35
- ...d?.status
36
- },
37
- filters: {
38
- ...f.filters,
39
- ...d?.filters
40
- }
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
49
- });
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
- ] });
76
- }
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, {
82
- screenLabels: e,
83
- listLabels: t,
84
- rejectDialogLabels: n,
85
- messageLabels: r
86
- })
87
- });
88
- }
89
- export { T as ApprovalRequestsWidget, T as default };
@@ -1,44 +0,0 @@
1
- import { createCurrencyFormatter as e } from "../../../../../shared/util/dist/lib/createCurrencyFormatter.js";
2
- import { formatCalendarDate as t } from "../../../../../shared/util/dist/lib/formatCalendarDate.js";
3
- import "../../../../../shared/util/dist/index.js";
4
- import { STATUS_TONE as n } from "./constants.js";
5
- import { NameLookupState as r } from "./useApprovalRequestNames.js";
6
- import { canDecideApprovalRequest as i } from "./canDecideApprovalRequest.js";
7
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js
8
- var a = { day: "2-digit" };
9
- function o(t, n) {
10
- let r = new Intl.NumberFormat("en-US", {
11
- style: "currency",
12
- currency: n
13
- }).resolvedOptions().maximumFractionDigits ?? 2;
14
- return e(n).format(t / 10 ** r);
15
- }
16
- function s(e, t, n) {
17
- if (!e) return n.missingValue;
18
- let i = t.names.get(e);
19
- if (i) return i;
20
- switch (t.state) {
21
- case r.Resolving: return;
22
- case r.Unavailable: return n.unavailableValue;
23
- case r.Settled: return n.missingValue;
24
- }
25
- }
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;
29
- return {
30
- id: e.id,
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],
36
- statusTone: n[e.status],
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)
41
- };
42
- });
43
- }
44
- export { c as buildApprovalRequestRows };
@@ -1,7 +0,0 @@
1
- // ../../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
- export { e as canDecideApprovalRequest };
@@ -1,18 +0,0 @@
1
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/constants.js
2
- var e = [
3
- 10,
4
- 25,
5
- 50,
6
- 100
7
- ], t = {
8
- waiting: "warning",
9
- approved: "success",
10
- rejected: "destructive",
11
- canceled: "neutral"
12
- }, n = [
13
- "waiting",
14
- "approved",
15
- "rejected",
16
- "canceled"
17
- ];
18
- export { n as APPROVAL_REQUEST_STATUSES, e as PAGE_SIZE_OPTIONS, t as STATUS_TONE };
@@ -1,28 +0,0 @@
1
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/labels.js
2
- var e = {
3
- emptyTitle: "No approval requests",
4
- emptyDescription: "You don't have any approval requests yet.",
5
- filterEmptyTitle: "No approval requests found",
6
- filterEmptyDescription: "Try adjusting your filter criteria.",
7
- missingValue: "—",
8
- unavailableValue: "Unavailable",
9
- status: {
10
- waiting: "In approval",
11
- approved: "Approved",
12
- rejected: "Rejected",
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}`
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."
27
- };
28
- export { e as APPROVAL_REQUESTS_LIST_LABELS_EN, t as APPROVAL_REQUESTS_MESSAGE_LABELS_EN };
@@ -1,8 +0,0 @@
1
- import { Scope as e } from "../../../../../shared/data-access/dist/lib/scopes.js";
2
- import "../../../../../shared/data-access/dist/index.js";
3
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/permissions.js
4
- function t(t) {
5
- let n = new Set(t ?? []);
6
- return { canRead: n.has(e.ApprovalRequestReadOrg) && n.has(e.PayableReadOrg) };
7
- }
8
- export { t as getApprovalRequestPermissions };
@@ -1,93 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
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";
10
- import "../../../../../shared/data-access/dist/index.js";
11
- import "../../../../../shared/ui/dist/index.js";
12
- import { useWidgetConfig as i, useWidgetInitStaleForToken as a } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
13
- import "../../../../../shared/feature/dist/index.js";
14
- import { useApproveApprovalRequestMutation as o } from "../../../../data-access/dist/index4.js";
15
- import { useRejectApprovalRequestMutation as s } from "../../../../data-access/dist/index5.js";
16
- import "../../../../data-access/dist/index.js";
17
- import { useCallback as c, useState as l } from "react";
18
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js
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
25
- });
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));
33
- try {
34
- return await r(), e.success(i), !0;
35
- } catch (n) {
36
- return e.error(t(n) ?? a), !1;
37
- } finally {
38
- h((e) => {
39
- let t = new Set(e);
40
- return t.delete(n), t;
41
- });
42
- }
43
- }, []), A = c((e) => {
44
- w || k(e, {
45
- decide: () => f({ approvalRequestId: e }),
46
- successMessage: d.approved,
47
- errorFallback: d.approveError
48
- });
49
- }, [
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,
70
- p,
71
- v,
72
- g,
73
- k
74
- ]), P = c(() => {
75
- M || _(void 0);
76
- }, [M]);
77
- return {
78
- pendingRequestIds: m,
79
- areDecisionsPaused: w,
80
- onApprove: A,
81
- onReject: j,
82
- rejectDialog: {
83
- open: !!g,
84
- reason: v,
85
- onReasonChange: y,
86
- onConfirm: N,
87
- onCancel: P,
88
- isPending: M,
89
- isConfirmDisabled: w
90
- }
91
- };
92
- }
93
- export { d as useApprovalRequestDecisions };
@@ -1,65 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { hasAnyScope as e } from "../../../../../shared/data-access/dist/lib/hasAnyScope.js";
6
- import { Scope as t } from "../../../../../shared/data-access/dist/lib/scopes.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 { getCounterpartName as i } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
11
- import { useCounterpartsByIdsQuery as a } from "../../../../../shared/counterpart-management/data-access/dist/index3.js";
12
- import "../../../../../shared/counterpart-management/feature/dist/index.js";
13
- import { useEntityUsersByIdsQuery as o } from "../../../../data-access/dist/index7.js";
14
- import "../../../../data-access/dist/index.js";
15
- import { useMemo as s } from "react";
16
- // ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestNames.js
17
- var c = {
18
- Resolving: "resolving",
19
- Unavailable: "unavailable",
20
- Settled: "settled"
21
- }, l = /* @__PURE__ */ new Map();
22
- function u(e, t) {
23
- let n = /* @__PURE__ */ new Map();
24
- for (let r of e ?? []) {
25
- let e = t(r);
26
- e && n.set(r.id, e);
27
- }
28
- return n;
29
- }
30
- function d({ isInitResolved: e, canRead: t, isPaused: n }, { isFetching: r, isError: i }) {
31
- return !e || n ? c.Resolving : t ? r ? c.Resolving : i ? c.Unavailable : c.Settled : c.Unavailable;
32
- }
33
- function f({ items: c }) {
34
- let { initResponse: f } = n(), p = r(), m = !!f, h = e(f?.scopes, [t.CounterpartReadOrg]), g = e(f?.scopes, [t.UserReadOrg]), _ = s(() => c.map(({ payable: e }) => e?.counterpart_id).filter((e) => !!e), [c]), v = s(() => c.map(({ request: e }) => e.created_by).filter((e) => !!e), [c]), y = a({
35
- counterpartIds: _,
36
- enabled: h && !p
37
- }), b = o({
38
- ids: v,
39
- enabled: g && !p
40
- }), x = m && !h && !p, S = m && !g && !p, C = s(() => x ? l : u(y.data?.data, i), [y.data, x]), w = s(() => S ? l : u(b.data?.data, (e) => `${e.first_name ?? ""} ${e.last_name ?? ""}`.trim()), [b.data, S]), T = d({
41
- isInitResolved: m,
42
- canRead: h,
43
- isPaused: p
44
- }, y), E = d({
45
- isInitResolved: m,
46
- canRead: g,
47
- isPaused: p
48
- }, b);
49
- return s(() => ({
50
- vendors: {
51
- names: C,
52
- state: T
53
- },
54
- users: {
55
- names: w,
56
- state: E
57
- }
58
- }), [
59
- C,
60
- T,
61
- w,
62
- E
63
- ]);
64
- }
65
- export { c as NameLookupState, f as useApprovalRequestNames };