@tesouro/embedded-components-react 0.3.22 → 0.3.24

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 (94) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/lib/BillPayWidget.js +1 -1
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index10.js +10 -10
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +15 -15
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +31 -32
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +42 -1
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +158 -43
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +33 -4
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +1 -16
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +45 -12
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +4 -64
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +13 -26
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +14 -62
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +56 -123
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +18 -3
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +15 -10
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +61 -40
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +130 -50
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +20 -4
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +38 -69
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +48 -46
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +5 -93
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +71 -34
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +48 -139
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +91 -66
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js +22 -5
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +34 -22
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +146 -210
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +72 -209
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +21 -103
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +209 -12
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +211 -44
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +104 -30
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +12 -165
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +47 -35
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +29 -99
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index4.js +64 -5
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +181 -12
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +34 -243
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +104 -4
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +12 -27
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +267 -81
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +4 -145
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +33 -3
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +82 -2
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +155 -37
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +2 -0
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +2 -6
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +2 -6
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +43 -9
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +1 -94
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +8 -3
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +7 -5
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +85 -13
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +3 -59
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +9 -3
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +19 -120
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +56 -8
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +3 -32
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +3 -46
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +116 -15
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +8 -28
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +43 -83
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +19 -47
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +27 -249
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +82 -109
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +47 -206
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +253 -4
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +111 -6
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +6 -39
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +197 -102
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -0
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +6 -23
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +114 -0
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +1 -0
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +25 -0
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +5 -24
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +3 -162
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +9 -6
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +10 -11
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index83.js +123 -8
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index84.js +2 -170
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index85.js +18 -2
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index86.js +7 -11
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index87.js +163 -82
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index88.js +1 -1
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index89.js +14 -0
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index90.js +108 -0
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index91.js +2 -0
  90. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +2 -2
  91. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +27 -27
  92. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  93. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
  94. package/package.json +1 -1
@@ -1,29 +1,16 @@
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 { useCurrentUserQuery as t } from "../../../shared/data-access/dist/lib/useCurrentUserQuery.js";
7
- import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
8
- import "../../../shared/data-access/dist/index.js";
9
- import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
- import "../../../shared/feature/dist/index.js";
11
- import { usePayableApprovalRequestsQuery as i } from "../../data-access/dist/index5.js";
12
- import "../../data-access/dist/index.js";
13
- import { currentApprovalRound as a } from "./index13.js";
14
- import { usePayableApprovalRoundStart as o } from "./index15.js";
1
+ import { currentApprovalRound as e } from "./index16.js";
15
2
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js
16
- function s({ payableId: s, status: c }) {
17
- let { initResponse: l } = r(), u = e(l?.scopes, [n.ApprovalRequestReadOrg]), d = c === "approve_in_progress" && u, f = i(s, { enabled: d }), p = t({ enabled: d }), { roundStartedAt: m } = o({
18
- payableId: s,
19
- enabled: d
20
- }), h = p.data?.id, g = d ? a(f.data?.data, m) : [], _ = (e) => e.caller_is_policy_approver ?? !!(h && e.user_ids.includes(h)), v = g.some(_), y = g.filter((e) => e.status === "waiting");
21
- return {
22
- id: y.filter(_).find((e) => !(h && (e.approved_by ?? []).includes(h)))?.id,
23
- isPolicyApprover: v,
24
- hasWaitingRequest: y.length > 0,
25
- isLoading: f.isLoading || p.isLoading
26
- };
3
+ function t({ requestsNewestFirst: t, roundStartedAt: n, lookup: r }) {
4
+ let i = e(t, n), a = [];
5
+ for (let e of i) {
6
+ if (e.status !== "waiting") continue;
7
+ let t = [...e.role_ids ?? [], ...e.user_ids ?? []].map((e) => r.get(e)?.label).filter((e) => !!e);
8
+ t.length && a.push({
9
+ id: e.id,
10
+ names: t
11
+ });
12
+ }
13
+ return a;
27
14
  }
28
15
  //#endregion
29
- export { s as useCurrentApprovalRequestId };
16
+ export { t as buildPendingApproverGroups };
@@ -1,65 +1,17 @@
1
- import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
2
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
3
- import "../../../shared/data-access/dist/index.js";
4
- import { BanIcon as n, CalendarXIcon as r, RotateCcwIcon as i, ThumbsDownIcon as a, ThumbsUpIcon as o } from "lucide-react";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { usePayableHistoryQuery as e } from "../../data-access/dist/index6.js";
6
+ import "../../data-access/dist/index.js";
5
7
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js
6
- function s({ status: s, scopes: c, canDecideApprovalRequest: l, hasScheduledPayment: u, scheduledPaymentRecordId: d, isPolicyApprover: f, hasWaitingRequest: p, arePendingApproversUnknown: m, labels: h }) {
7
- let g = e(c, [t.PayablePayOrg]), _ = e(c, [t.BankAccountReadOrg]), v = e(c, [t.PaymentRailAch]), y = e(c, [t.PayableWriteOrg]), b = e(c, [t.PaymentRecordWriteOrg]), x = e(c, [t.PayableApproveOrg]), S = [];
8
- s === "approve_in_progress" && l && (S.push({
9
- id: "approve",
10
- label: h.approve,
11
- variant: "default",
12
- surface: "row"
13
- }), S.push({
14
- id: "reject",
15
- label: h.reject,
16
- variant: "ghost",
17
- surface: "row"
18
- })), s === "approve_in_progress" && p && x && !f && !m && (S.push({
19
- id: "forceApprove",
20
- label: h.forceApprove,
21
- variant: "ghost",
22
- surface: "menu",
23
- icon: o,
24
- sectionHeading: h.policyOverridesHeading
25
- }), S.push({
26
- id: "forceReject",
27
- label: h.forceReject,
28
- variant: "ghost",
29
- surface: "menu",
30
- icon: a,
31
- sectionHeading: h.policyOverridesHeading
32
- }));
33
- let C = (s === "waiting_to_be_paid" || s === "partially_paid") && g && !u, w = s === "waiting_to_be_paid" && g && _ && v && !u;
34
- return C && S.push({
35
- id: "markAsPaid",
36
- label: h.markAsPaid,
37
- variant: "outline",
38
- surface: "row"
39
- }), w && S.push({
40
- id: "payBill",
41
- label: h.payBill,
42
- variant: "default",
43
- surface: "row"
44
- }), s === "new" && y && S.push({
45
- id: "cancel",
46
- label: h.cancel,
47
- variant: "ghost",
48
- surface: "menu",
49
- icon: n
50
- }), (s === "rejected" || s === "waiting_to_be_paid" && !u) && y && S.push({
51
- id: "reopen",
52
- label: h.reopen,
53
- variant: "ghost",
54
- surface: "menu",
55
- icon: i
56
- }), s === "waiting_to_be_paid" && u && d && b && S.push({
57
- id: "cancelScheduledPayment",
58
- label: h.cancelScheduledPayment,
59
- variant: "ghost",
60
- surface: "menu",
61
- icon: r
62
- }), S;
8
+ var t = "submitted_for_approval";
9
+ function n({ payableId: n, enabled: r = !0 }) {
10
+ let i = e(n, { enabled: r });
11
+ return {
12
+ roundStartedAt: (i.data?.data ?? []).reduce((e, n) => n.event_type === t ? n.timestamp : e, void 0),
13
+ isLoading: i.isLoading
14
+ };
63
15
  }
64
16
  //#endregion
65
- export { s as getBillDetailActions };
17
+ export { n as usePayableApprovalRoundStart };
@@ -2,133 +2,66 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import "../../../shared/ui/dist/index.js";
7
- import { useWidgetConfig as t } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
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 { useAllOrganizationRolesQuery as n } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
8
+ import { useAllOrganizationUsersQuery as r } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
9
+ import "../../../shared/data-access/dist/index.js";
10
+ import { useWidgetConfig as i } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
8
11
  import "../../../shared/feature/dist/index.js";
9
- import { useApprovePayableApprovalRequestMutation as n, useRejectPayableApprovalRequestMutation as r } from "../../data-access/dist/index5.js";
10
- import { useCancelPayableMutation as i, useCancelPaymentRecordMutation as a, useForceApprovePayableMutation as o, useForceRejectPayableMutation as s, useMarkPayableAsPaidMutation as c, useReopenPayableMutation as l } from "../../data-access/dist/index10.js";
12
+ import { usePayableApprovalRequestsQuery as a } from "../../data-access/dist/index5.js";
11
13
  import "../../data-access/dist/index.js";
12
- import { getBillDetailActions as u } from "./index18.js";
13
- import { useState as d } from "react";
14
- import { HandIcon as f } from "lucide-react";
14
+ import { useGetApprovalPoliciesQuery as o } from "../../../shared/approval-policy/data-access/dist/lib/approvalPoliciesApi.js";
15
+ import "../../../shared/approval-policy/data-access/dist/index.js";
16
+ import { buildApprovalPolicyCardView as s } from "./index15.js";
17
+ import { currentApprovalRound as c } from "./index16.js";
18
+ import { buildPendingApproverGroups as l } from "./index17.js";
19
+ import { usePayableApprovalRoundStart as u } from "./index18.js";
20
+ import { useMemo as d } from "react";
15
21
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js
16
- function p({ payableId: f, status: p, currentApprovalRequestId: h, isPolicyApprover: v, hasWaitingRequest: y, arePendingApproversUnknown: b, hasScheduledPayment: x, scheduledPaymentRecordId: S, isScheduledPaymentUnknown: C, labels: w, pendingApprovers: T, onPayBillSelect: E }) {
17
- let { initResponse: D } = t(), O = c(), k = r(), A = n(), j = i(), M = a(), N = l(), P = o(), F = s(), I = O.isPending || k.isPending || A.isPending || j.isPending || M.isPending || N.isPending || P.isPending || F.isPending, [L, R] = d(), z = L && (L.id !== "cancelScheduledPayment" || L.scheduledPaymentRecordId === S) ? L : void 0, B = f && p ? u({
18
- status: p,
19
- scopes: D?.scopes,
20
- canDecideApprovalRequest: !!h,
21
- isPolicyApprover: v,
22
- hasWaitingRequest: y,
23
- arePendingApproversUnknown: b,
24
- hasScheduledPayment: x || C,
25
- scheduledPaymentRecordId: S,
26
- labels: w
27
- }) : [], V = (t) => ({
28
- onError: () => e.error(w.actionError),
29
- onSuccess: () => e.success(w.actionSuccess[t])
30
- }), H = {
31
- markAsPaid: {
32
- isPending: O.isPending,
33
- run: () => f && O.mutate({ path: { payable_id: f } }, V("markAsPaid"))
34
- },
35
- reject: {
36
- isPending: k.isPending,
37
- run: (e) => h && k.mutate({
38
- path: { approval_request_id: h },
39
- body: e ? { reject_reason: e } : void 0
40
- }, V("reject"))
41
- },
42
- approve: {
43
- isPending: A.isPending,
44
- run: () => h && A.mutate({ path: { approval_request_id: h } }, V("approve"))
45
- },
46
- cancel: {
47
- isPending: j.isPending,
48
- run: () => f && j.mutate({ path: { payable_id: f } }, V("cancel"))
49
- },
50
- cancelScheduledPayment: {
51
- isPending: M.isPending,
52
- run: () => {
53
- let e = z?.scheduledPaymentRecordId;
54
- !f || !e || M.mutate({
55
- path: { payment_record_id: e },
56
- payableId: f
57
- }, V("cancelScheduledPayment"));
58
- }
59
- },
60
- reopen: {
61
- isPending: N.isPending,
62
- run: () => f && N.mutate({ path: { payable_id: f } }, V("reopen"))
63
- },
64
- forceApprove: {
65
- isPending: P.isPending,
66
- run: () => f && P.mutate({ path: { payable_id: f } }, V("forceApprove"))
67
- },
68
- forceReject: {
69
- isPending: F.isPending,
70
- run: () => f && F.mutate({ path: { payable_id: f } }, V("forceReject"))
71
- }
72
- }, U = B.map((e) => ({
73
- ...e,
74
- disabled: I,
75
- loading: H[e.id]?.isPending ?? !1,
76
- onSelect: () => {
77
- if (!(I || !f)) {
78
- if (e.id === "payBill") {
79
- E();
80
- return;
81
- }
82
- if (g(e.id)) {
83
- R({
84
- id: e.id,
85
- scheduledPaymentRecordId: S
86
- });
87
- return;
88
- }
89
- H[e.id]?.run();
90
- }
91
- }
92
- }));
22
+ function f({ payableId: f, approvalPolicyId: p, enabled: m = !0, copy: h }) {
23
+ let g = m && !!p, { initResponse: _ } = i(), v = e(_?.scopes, [t.ApprovalPolicyReadOrg]), y = e(_?.scopes, [t.ApprovalRequestReadOrg]), b = e(_?.scopes, [t.RoleReadOrg]), x = e(_?.scopes, [t.UserReadOrg]), S = o({ enabled: g && v }), C = n({ enabled: g && b }), w = r({ enabled: g && x }), T = a(f, { enabled: g && y }), { roundStartedAt: E } = u({
24
+ payableId: f,
25
+ enabled: g && y
26
+ }), D = d(() => {
27
+ let e = /* @__PURE__ */ new Map();
28
+ for (let t of C.data?.data ?? []) e.set(t.id, {
29
+ label: t.name,
30
+ kind: "role"
31
+ });
32
+ for (let t of w.data?.data ?? []) e.set(t.id, {
33
+ label: t.name,
34
+ kind: "user"
35
+ });
36
+ return e;
37
+ }, [C.data, w.data]), O = d(() => c(T.data?.data, E), [T.data, E]), k = d(() => new Set(O.flatMap((e) => e.approved_by ?? [])), [O]), A = d(() => new Set(O.filter((e) => (e.approved_by ?? []).length > 0).flatMap((e) => e.role_ids ?? [])), [O]), j = d(() => p ? S.data?.data.find((e) => e.id === p) : void 0, [S.data, p]);
93
38
  return {
94
- actions: {
95
- row: U.filter((e) => e.surface === "row"),
96
- menu: U.filter((e) => e.surface === "menu")
97
- },
98
- decisionDialog: {
99
- open: !!z,
100
- copy: z ? {
101
- ...w.decisionDialog[z.id],
102
- presentation: _(z.id) ? m : void 0,
103
- pendingApprovers: _(z.id) ? T ?? [] : void 0
104
- } : void 0,
105
- isPending: z ? H[z.id]?.isPending ?? !1 : !1,
106
- onCancel: () => {
107
- I || R(void 0);
108
- },
109
- onConfirm: (e) => {
110
- !z || I || (H[z.id]?.run(e), R(void 0));
111
- }
112
- }
39
+ view: d(() => g && j ? s({
40
+ policy: j,
41
+ lookup: D,
42
+ approvedUserIds: k,
43
+ approvedRoleIds: A,
44
+ copy: h
45
+ }) : void 0, [
46
+ g,
47
+ j,
48
+ D,
49
+ k,
50
+ A,
51
+ h
52
+ ]),
53
+ pendingApprovers: d(() => g ? l({
54
+ requestsNewestFirst: T.data?.data,
55
+ roundStartedAt: E,
56
+ lookup: D
57
+ }) : [], [
58
+ g,
59
+ T.data,
60
+ E,
61
+ D
62
+ ]),
63
+ isLoading: g && (S.isResolving || C.isResolving || w.isResolving || T.isLoading)
113
64
  };
114
65
  }
115
- var m = {
116
- alignment: "center",
117
- icon: f,
118
- tone: "destructive",
119
- actionWidth: "equal"
120
- }, h = [
121
- "reject",
122
- "cancel",
123
- "cancelScheduledPayment",
124
- "forceApprove",
125
- "forceReject"
126
- ];
127
- function g(e) {
128
- return h.includes(e);
129
- }
130
- function _(e) {
131
- return e === "forceApprove" || e === "forceReject";
132
- }
133
66
  //#endregion
134
- export { p as usePayableDetailActions };
67
+ export { f as useApprovalPolicyCardView };
@@ -1,6 +1,21 @@
1
+ import { MARK_AS_PAID_DIALOG_LABELS_EN as e } from "../../ui/dist/index82.js";
2
+ import "../../ui/dist/index.js";
1
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js
2
- function e(e) {
3
- return e?.amount_due ?? e?.total_amount ?? void 0;
4
+ var t = {
5
+ dueDateSuffix: (e) => `by ${e}`,
6
+ paidToast: "Bill marked as paid",
7
+ submitError: "Couldn't mark this bill as paid. Try again.",
8
+ dialog: e
9
+ };
10
+ function n(e) {
11
+ return {
12
+ ...t,
13
+ ...e,
14
+ dialog: {
15
+ ...t.dialog,
16
+ ...e?.dialog
17
+ }
18
+ };
4
19
  }
5
20
  //#endregion
6
- export { e as resolveAmountDueMinorUnits };
21
+ export { t as MARK_AS_PAID_FLOW_LABELS_EN, n as mergeMarkAsPaidFlowLabels };
@@ -3,22 +3,27 @@
3
3
  "use client";
4
4
  "use client";
5
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";
6
+ import { useCurrentUserQuery as t } from "../../../shared/data-access/dist/lib/useCurrentUserQuery.js";
7
+ import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
7
8
  import "../../../shared/data-access/dist/index.js";
8
- import { formatCalendarDate as n } from "../../../shared/util/dist/lib/formatCalendarDate.js";
9
9
  import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
10
  import "../../../shared/feature/dist/index.js";
11
- import { usePayablePaymentRecordsQuery as i } from "../../data-access/dist/index8.js";
11
+ import { usePayableApprovalRequestsQuery as i } from "../../data-access/dist/index5.js";
12
12
  import "../../data-access/dist/index.js";
13
+ import { currentApprovalRound as a } from "./index16.js";
14
+ import { usePayableApprovalRoundStart as o } from "./index18.js";
13
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js
14
- function a({ payableId: a, scheduledPaymentDate: o, enabled: s = !0 }) {
15
- let { initResponse: c } = r(), l = e(c?.scopes, [t.PaymentRecordReadOrg]), u = i(s ? a : void 0, { enabled: s && l }), d = u.paymentRecords.find((e) => e.status === "created" || e.status === "processing"), f = !!d || !!o, p = d?.planned_payment_date ?? (f ? o : void 0);
16
+ function s({ payableId: s, status: c }) {
17
+ let { initResponse: l } = r(), u = e(l?.scopes, [n.ApprovalRequestReadOrg]), d = c === "approve_in_progress" && u, f = i(s, { enabled: d }), p = t({ enabled: d }), { roundStartedAt: m } = o({
18
+ payableId: s,
19
+ enabled: d
20
+ }), h = p.data?.id, g = d ? a(f.data?.data, m) : [], _ = (e) => e.caller_is_policy_approver ?? !!(h && e.user_ids.includes(h)), v = g.some(_), y = g.filter((e) => e.status === "waiting");
16
21
  return {
17
- hasScheduledPayment: f,
18
- isResolving: u.isResolving,
19
- scheduledDateLabel: p ? n(p) : void 0,
20
- scheduledPaymentRecordId: d?.id
22
+ id: y.filter(_).find((e) => !(h && (e.approved_by ?? []).includes(h)))?.id,
23
+ isPolicyApprover: v,
24
+ hasWaitingRequest: y.length > 0,
25
+ isLoading: f.isLoading || p.isLoading
21
26
  };
22
27
  }
23
28
  //#endregion
24
- export { a as useScheduledPayment };
29
+ export { s as useCurrentApprovalRequestId };
@@ -1,44 +1,65 @@
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 { hasAnyScope as t } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
7
- import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
1
+ import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
2
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
8
3
  import "../../../shared/data-access/dist/index.js";
9
- import "../../../shared/ui/dist/index.js";
10
- import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
- import "../../../shared/feature/dist/index.js";
12
- import { useDeletePayableMutation as i } from "../../data-access/dist/index10.js";
13
- import "../../data-access/dist/index.js";
14
- import { useState as a } from "react";
4
+ import { BanIcon as n, CalendarXIcon as r, RotateCcwIcon as i, ThumbsDownIcon as a, ThumbsUpIcon as o } from "lucide-react";
15
5
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js
16
- function o({ payableId: o, status: s, enabled: c = !0, labels: l, onDeleted: u }) {
17
- let { initResponse: d } = r(), f = i(), [p, m] = a(!1), h = t(d?.scopes, [n.PayableWriteOrg]), g = !!(c && o && s === "draft" && h), _ = g ? [{
18
- id: "deleteDraft",
19
- label: l.menuItem,
20
- destructive: !0,
21
- onSelect: () => m(!0)
22
- }] : [], v = p && g;
23
- return {
24
- menuItems: _,
25
- dialog: {
26
- open: v,
27
- copy: v ? l.dialog : void 0,
28
- isPending: f.isPending,
29
- onCancel: () => {
30
- f.isPending || m(!1);
31
- },
32
- onConfirm: () => {
33
- !g || !o || f.isPending || f.mutate({ path: { payable_id: o } }, {
34
- onError: () => e.error(l.error),
35
- onSuccess: () => {
36
- m(!1), u();
37
- }
38
- });
39
- }
40
- }
41
- };
6
+ function s({ status: s, scopes: c, canDecideApprovalRequest: l, hasScheduledPayment: u, scheduledPaymentRecordId: d, isPolicyApprover: f, hasWaitingRequest: p, arePendingApproversUnknown: m, labels: h }) {
7
+ let g = e(c, [t.PayablePayOrg]), _ = e(c, [t.BankAccountReadOrg]), v = e(c, [t.PaymentRailAch]), y = e(c, [t.PayableWriteOrg]), b = e(c, [t.PaymentRecordWriteOrg]), x = e(c, [t.PayableApproveOrg]), S = [];
8
+ s === "approve_in_progress" && l && (S.push({
9
+ id: "approve",
10
+ label: h.approve,
11
+ variant: "default",
12
+ surface: "row"
13
+ }), S.push({
14
+ id: "reject",
15
+ label: h.reject,
16
+ variant: "ghost",
17
+ surface: "row"
18
+ })), s === "approve_in_progress" && p && x && !f && !m && (S.push({
19
+ id: "forceApprove",
20
+ label: h.forceApprove,
21
+ variant: "ghost",
22
+ surface: "menu",
23
+ icon: o,
24
+ sectionHeading: h.policyOverridesHeading
25
+ }), S.push({
26
+ id: "forceReject",
27
+ label: h.forceReject,
28
+ variant: "ghost",
29
+ surface: "menu",
30
+ icon: a,
31
+ sectionHeading: h.policyOverridesHeading
32
+ }));
33
+ let C = s === "waiting_to_be_paid" && g && !u, w = s === "waiting_to_be_paid" && g && _ && v && !u;
34
+ return C && S.push({
35
+ id: "markAsPaid",
36
+ label: h.markAsPaid,
37
+ variant: "outline",
38
+ surface: "row"
39
+ }), w && S.push({
40
+ id: "payBill",
41
+ label: h.payBill,
42
+ variant: "default",
43
+ surface: "row"
44
+ }), s === "new" && y && S.push({
45
+ id: "cancel",
46
+ label: h.cancel,
47
+ variant: "ghost",
48
+ surface: "menu",
49
+ icon: n
50
+ }), (s === "rejected" || s === "waiting_to_be_paid" && !u) && y && S.push({
51
+ id: "reopen",
52
+ label: h.reopen,
53
+ variant: "ghost",
54
+ surface: "menu",
55
+ icon: i
56
+ }), s === "waiting_to_be_paid" && u && d && b && S.push({
57
+ id: "cancelScheduledPayment",
58
+ label: h.cancelScheduledPayment,
59
+ variant: "ghost",
60
+ surface: "menu",
61
+ icon: r
62
+ }), S;
42
63
  }
43
64
  //#endregion
44
- export { o as useDraftDelete };
65
+ export { s as getBillDetailActions };