@tesouro/embedded-components-react 0.9.39 → 0.9.40

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.
@@ -611,6 +611,8 @@ interface ApprovalRequestsScreenLabels {
611
611
  errorTitle: string;
612
612
  errorDescription: string;
613
613
  errorRetry: string;
614
+ accessRestrictedTitle: string;
615
+ accessRestrictedDescription: string;
614
616
  }
615
617
 
616
618
  interface ApprovalRequestsListLabels {
@@ -611,6 +611,8 @@ interface ApprovalRequestsScreenLabels {
611
611
  errorTitle: string;
612
612
  errorDescription: string;
613
613
  errorRetry: string;
614
+ accessRestrictedTitle: string;
615
+ accessRestrictedDescription: string;
614
616
  }
615
617
 
616
618
  interface ApprovalRequestsListLabels {
@@ -7,54 +7,59 @@ import { useEmbedApi as t } from "../../../../../shared/data-access/dist/lib/Emb
7
7
  import "../../../../../shared/data-access/dist/index.js";
8
8
  import { useAnalyticsTrack as n } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
9
9
  import { WidgetProvider as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
10
- import { useRefetchWidget as i, useWidgetConfig as a, useWidgetError as o, useWidgetInitStaleForToken as s } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useRefetchWidget as i, useWidgetConfig as a, useWidgetError as o, useWidgetInitStaleForToken as s, useWidgetLoading as c } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
11
  import "../../../../../shared/feature/dist/index.js";
12
- import { ApprovalRequestsWidgetAnalyticsEvent as c, WIDGET_NAME as l } from "../analytics/events.js";
13
- import { APPROVAL_REQUESTS_LIST_LABELS_EN as u } from "./labels.js";
14
- import { useApprovalRequestsTable as d } from "./useApprovalRequestsTable.js";
15
- import { ApprovalRequestsScreen as f } from "../../../../ui/dist/index3.js";
12
+ import { ApprovalRequestsWidgetAnalyticsEvent as l, WIDGET_NAME as u } from "../analytics/events.js";
13
+ import { APPROVAL_REQUESTS_LIST_LABELS_EN as d } from "./labels.js";
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";
16
17
  import "../../../../ui/dist/index.js";
17
- import { useEffect as p, useMemo as m } from "react";
18
- import { jsx as h } from "react/jsx-runtime";
18
+ import { useEffect as h, useMemo as g } from "react";
19
+ import { jsx as _ } from "react/jsx-runtime";
19
20
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js
20
- function g({ screenLabels: r, listLabels: l }) {
21
- let g = n();
22
- p(() => {
23
- g(c.Mounted);
24
- }, [g]);
25
- let _ = m(() => ({
21
+ function v({ screenLabels: r, listLabels: u }) {
22
+ let v = n();
23
+ h(() => {
24
+ v(l.Mounted);
25
+ }, [v]);
26
+ let y = g(() => ({
27
+ ...d,
26
28
  ...u,
27
- ...l,
28
29
  status: {
29
- ...u.status,
30
- ...l?.status
30
+ ...d.status,
31
+ ...u?.status
31
32
  }
32
- }), [l]), v = d({ labels: _ }), { initResponse: y } = a(), b = o(), x = s(), S = i(), { organizationStatus: C } = t(), w = !!b && (!y || x);
33
- return /* @__PURE__ */ h(f, {
34
- rows: v.rows,
35
- isLoading: v.isLoading || e(C) && v.rows.length === 0,
36
- isError: w || v.isError,
37
- pageSize: v.pageSize,
38
- onPageSizeChange: v.onPageSizeChange,
39
- pageSizeOptions: v.pageSizeOptions,
40
- hasNextPage: v.hasNextPage,
41
- hasPrevPage: v.hasPrevPage,
42
- onNextPage: v.onNextPage,
43
- onPrevPage: v.onPrevPage,
44
- emptyState: v.emptyState,
45
- onRetry: w ? S : v.onRetry,
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
36
+ });
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,
46
51
  labels: r
47
52
  });
48
53
  }
49
- function _({ screenLabels: e, listLabels: t, ...n }) {
50
- return /* @__PURE__ */ h(r, {
54
+ function y({ screenLabels: e, listLabels: t, ...n }) {
55
+ return /* @__PURE__ */ _(r, {
51
56
  ...n,
52
- widgetName: l,
53
- children: /* @__PURE__ */ h(g, {
57
+ widgetName: u,
58
+ children: /* @__PURE__ */ _(v, {
54
59
  screenLabels: e,
55
60
  listLabels: t
56
61
  })
57
62
  });
58
63
  }
59
64
  //#endregion
60
- export { _ as ApprovalRequestsWidget, _ as default };
65
+ export { y as ApprovalRequestsWidget, y as default };
@@ -0,0 +1,9 @@
1
+ import { Scope as e } from "../../../../../shared/data-access/dist/lib/scopes.js";
2
+ import "../../../../../shared/data-access/dist/index.js";
3
+ //#region ../../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
+ //#endregion
9
+ export { t as getApprovalRequestPermissions };
@@ -20,38 +20,39 @@ function c(e, t) {
20
20
  description: t.emptyDescription
21
21
  };
22
22
  }
23
- function l({ labels: l }) {
24
- let [u, d] = s(t[0]), [f, p] = s(), { organizationId: m } = e(), [h, g] = s(m);
25
- m && m !== h && (g(m), p(void 0));
26
- let _ = n({
27
- limit: u,
28
- pagination_token: f
29
- }), v = o(() => _.data?.data ?? [], [_.data]), y = r({ items: v }), b = o(() => i(v, y, l), [
30
- v,
23
+ function l({ labels: l, enabled: u = !0 }) {
24
+ let [d, f] = s(t[0]), [p, m] = s(), { organizationId: h } = e(), [g, _] = s(h);
25
+ h && h !== g && (_(h), m(void 0));
26
+ let v = n({
27
+ limit: d,
28
+ pagination_token: p,
29
+ enabled: u
30
+ }), y = o(() => v.data?.data ?? [], [v.data]), b = r({ items: y }), x = o(() => i(y, b, l), [
31
31
  y,
32
+ b,
32
33
  l
33
- ]), x = _.isPlaceholderData ? void 0 : _.data, S = x?.next_pagination_token ?? void 0, C = x?.prev_pagination_token ?? void 0, w = a((e) => {
34
- d(e), p(void 0);
35
- }, []), T = a(() => {
36
- S && p(S);
37
- }, [S]), E = a(() => {
38
- C && p(C);
39
- }, [C]), { refetch: D } = _, O = a(() => {
40
- D();
41
- }, [D]);
34
+ ]), S = v.isPlaceholderData ? void 0 : v.data, C = S?.next_pagination_token ?? void 0, w = S?.prev_pagination_token ?? void 0, T = a((e) => {
35
+ f(e), m(void 0);
36
+ }, []), E = a(() => {
37
+ C && m(C);
38
+ }, [C]), D = a(() => {
39
+ w && m(w);
40
+ }, [w]), { refetch: O } = v, k = a(() => {
41
+ O();
42
+ }, [O]);
42
43
  return {
43
- rows: b,
44
- isLoading: _.isLoading,
45
- isError: _.isError,
46
- pageSize: u,
44
+ rows: x,
45
+ isLoading: v.isLoading,
46
+ isError: v.isError,
47
+ pageSize: d,
47
48
  pageSizeOptions: t,
48
- onPageSizeChange: w,
49
- hasNextPage: !!S,
50
- hasPrevPage: !!C,
51
- onNextPage: T,
52
- onPrevPage: E,
49
+ onPageSizeChange: T,
50
+ hasNextPage: !!C,
51
+ hasPrevPage: !!w,
52
+ onNextPage: E,
53
+ onPrevPage: D,
53
54
  emptyState: c(!1, l),
54
- onRetry: O
55
+ onRetry: k
55
56
  };
56
57
  }
57
58
  //#endregion
@@ -10,7 +10,9 @@ var e = {
10
10
  loadingValue: "Loading",
11
11
  errorTitle: "Couldn't load approval requests",
12
12
  errorDescription: "Try again.",
13
- errorRetry: "Try again"
13
+ errorRetry: "Try again",
14
+ accessRestrictedTitle: "Access restricted",
15
+ accessRestrictedDescription: "You don't have permission to view approval requests."
14
16
  };
15
17
  //#endregion
16
18
  export { e as APPROVAL_REQUESTS_SCREEN_LABELS_EN };
@@ -15,34 +15,34 @@ function d({ name: e, loadingLabel: t }) {
15
15
  children: t
16
16
  })] }) : /* @__PURE__ */ s(o, { children: e });
17
17
  }
18
- function f({ rows: n, isLoading: o, isError: c, pageSize: f, onPageSizeChange: p, pageSizeOptions: m, hasNextPage: h, hasPrevPage: g, onNextPage: _, onPrevPage: v, emptyState: y, onRetry: b, labels: x }) {
19
- let S = {
18
+ function f({ rows: n, isLoading: o, isError: c, isAccessRestricted: f, pageSize: p, onPageSizeChange: m, pageSizeOptions: h, hasNextPage: g, hasPrevPage: _, onNextPage: v, onPrevPage: y, emptyState: b, onRetry: x, labels: S }) {
19
+ let C = {
20
20
  ...a,
21
- ...x
22
- }, C = [
21
+ ...S
22
+ }, w = [
23
23
  {
24
24
  accessorKey: "invoiceNumber",
25
- header: S.columnInvoiceNumber
25
+ header: C.columnInvoiceNumber
26
26
  },
27
27
  {
28
28
  accessorKey: "vendor",
29
- header: S.columnVendor,
29
+ header: C.columnVendor,
30
30
  cell: ({ row: e }) => /* @__PURE__ */ s(d, {
31
31
  name: e.original.vendor,
32
- loadingLabel: S.loadingValue
32
+ loadingLabel: C.loadingValue
33
33
  })
34
34
  },
35
35
  {
36
36
  accessorKey: "issueDate",
37
- header: S.columnIssueDate
37
+ header: C.columnIssueDate
38
38
  },
39
39
  {
40
40
  accessorKey: "dueDate",
41
- header: S.columnDueDate
41
+ header: C.columnDueDate
42
42
  },
43
43
  {
44
44
  accessorKey: "statusLabel",
45
- header: S.columnStatus,
45
+ header: C.columnStatus,
46
46
  cell: ({ row: t }) => /* @__PURE__ */ s(e, {
47
47
  tone: t.original.statusTone,
48
48
  children: t.original.statusLabel
@@ -52,7 +52,7 @@ function f({ rows: n, isLoading: o, isError: c, pageSize: f, onPageSizeChange: p
52
52
  accessorKey: "amount",
53
53
  header: () => /* @__PURE__ */ s("div", {
54
54
  className: "ttw:text-right",
55
- children: S.columnAmount
55
+ children: C.columnAmount
56
56
  }),
57
57
  cell: ({ row: e }) => /* @__PURE__ */ s("div", {
58
58
  className: "ttw:text-right ttw:tabular-nums",
@@ -61,34 +61,37 @@ function f({ rows: n, isLoading: o, isError: c, pageSize: f, onPageSizeChange: p
61
61
  },
62
62
  {
63
63
  accessorKey: "addedBy",
64
- header: S.columnAddedBy,
64
+ header: C.columnAddedBy,
65
65
  cell: ({ row: e }) => /* @__PURE__ */ s(d, {
66
66
  name: e.original.addedBy,
67
- loadingLabel: S.loadingValue
67
+ loadingLabel: C.loadingValue
68
68
  })
69
69
  }
70
70
  ];
71
- return c ? /* @__PURE__ */ s(i, {
72
- title: S.errorTitle,
73
- description: S.errorDescription,
74
- retryLabel: b ? S.errorRetry : void 0,
75
- onRetry: b
71
+ return f ? /* @__PURE__ */ s(i, {
72
+ title: C.accessRestrictedTitle,
73
+ description: C.accessRestrictedDescription
74
+ }) : c ? /* @__PURE__ */ s(i, {
75
+ title: C.errorTitle,
76
+ description: C.errorDescription,
77
+ retryLabel: x ? C.errorRetry : void 0,
78
+ onRetry: x
76
79
  }) : /* @__PURE__ */ s(t, {
77
- columns: C,
80
+ columns: w,
78
81
  data: n,
79
82
  isLoading: o,
80
83
  sorting: l,
81
84
  onSortingChange: u,
82
- pageSize: f,
83
- onPageSizeChange: p,
84
- pageSizeOptions: m,
85
- hasNextPage: h,
86
- hasPrevPage: g,
87
- onNextPage: _,
88
- onPrevPage: v,
85
+ pageSize: p,
86
+ onPageSizeChange: m,
87
+ pageSizeOptions: h,
88
+ hasNextPage: g,
89
+ hasPrevPage: _,
90
+ onNextPage: v,
91
+ onPrevPage: y,
89
92
  children: /* @__PURE__ */ s(r, {
90
- title: y.title,
91
- description: y.description
93
+ title: b.title,
94
+ description: b.description
92
95
  })
93
96
  });
94
97
  }
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.9.39", n = "9a6cb2d3b516b6821374e3a4483594af885ce0ce", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.9.40", n = "f9977fa659d9b5a376c67729dd2762d7e065f98c", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.9.39",
3
+ "version": "0.9.40",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [