@tesouro/embedded-components-react 0.3.22 → 0.3.23

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 (91) 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/feature/dist/index.js +15 -15
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +31 -32
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +42 -1
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +158 -43
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +33 -4
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +1 -16
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +45 -12
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +4 -64
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +13 -26
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +14 -62
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +56 -123
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +18 -3
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +15 -10
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +61 -40
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +130 -50
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +20 -4
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +38 -69
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +48 -46
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +5 -93
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +71 -34
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +48 -139
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +91 -66
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js +22 -5
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +34 -22
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +144 -210
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +63 -209
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +21 -103
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +209 -12
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +211 -44
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +104 -30
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +12 -165
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +47 -35
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +29 -99
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index4.js +64 -5
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +166 -12
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +34 -243
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +104 -4
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +12 -27
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +259 -81
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +4 -145
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +33 -3
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +82 -2
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +155 -37
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +2 -0
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +2 -6
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +2 -6
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +43 -9
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +1 -94
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +8 -3
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +7 -5
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +85 -13
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +3 -59
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +9 -3
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +19 -120
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +56 -8
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +3 -32
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +3 -46
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +116 -15
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +8 -28
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +43 -83
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +19 -47
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +27 -249
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +82 -109
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +47 -206
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +253 -4
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +111 -6
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +6 -39
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +197 -102
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -0
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +6 -23
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +114 -0
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +1 -0
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +25 -0
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +5 -24
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +3 -162
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +9 -6
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +10 -11
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index83.js +123 -8
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index84.js +2 -170
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index85.js +18 -2
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index86.js +7 -11
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index87.js +163 -82
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index88.js +1 -1
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index89.js +14 -0
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index90.js +89 -0
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index91.js +2 -0
  89. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  90. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
  91. package/package.json +1 -1
@@ -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 };
@@ -1,54 +1,134 @@
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 "../../../shared/ui/dist/index.js";
7
+ import { useWidgetConfig as t } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
8
+ 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, useReopenPayableMutation as c } from "../../data-access/dist/index10.js";
11
+ import "../../data-access/dist/index.js";
12
+ import { getBillDetailActions as l } from "./index21.js";
13
+ import { useState as u } from "react";
14
+ import { HandIcon as d } from "lucide-react";
1
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js
2
- var e = /* @__PURE__ */ new Set([
3
- "new",
4
- "approve_in_progress",
5
- "waiting_to_be_paid",
6
- "partially_paid"
7
- ]);
8
- function t(e, t) {
9
- let n = /* @__PURE__ */ new Date(`${e.slice(0, 10)}T00:00:00Z`), r = Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate());
10
- return n.getTime() < r;
11
- }
12
- function n({ apiStatus: n, dueDate: r, scheduledPaymentDate: i, hasScheduledPayment: a = !!i, now: o = /* @__PURE__ */ new Date() }) {
13
- if (e.has(n) && a) return {
14
- status: "scheduled",
15
- tone: "accent"
16
- };
17
- if (e.has(n) && r && t(r, o)) return {
18
- status: "overdue",
19
- tone: "danger"
16
+ function f({ payableId: d, status: f, currentApprovalRequestId: m, isPolicyApprover: _, hasWaitingRequest: v, arePendingApproversUnknown: y, hasScheduledPayment: b, scheduledPaymentRecordId: x, isScheduledPaymentUnknown: S, labels: C, isMarkAsPaidPending: w, pendingApprovers: T, onPayBillSelect: E, onMarkAsPaidSelect: D }) {
17
+ let { initResponse: O } = t(), k = r(), A = n(), j = i(), M = a(), N = c(), P = o(), F = s(), I = w || k.isPending || A.isPending || j.isPending || M.isPending || N.isPending || P.isPending || F.isPending, [L, R] = u(), z = L && (L.id !== "cancelScheduledPayment" || L.scheduledPaymentRecordId === x) ? L : void 0, B = d && f ? l({
18
+ status: f,
19
+ scopes: O?.scopes,
20
+ canDecideApprovalRequest: !!m,
21
+ isPolicyApprover: _,
22
+ hasWaitingRequest: v,
23
+ arePendingApproversUnknown: y,
24
+ hasScheduledPayment: b || S,
25
+ scheduledPaymentRecordId: x,
26
+ labels: C
27
+ }) : [], V = (t) => ({
28
+ onError: () => e.error(C.actionError),
29
+ onSuccess: () => e.success(C.actionSuccess[t])
30
+ }), H = {
31
+ reject: {
32
+ isPending: k.isPending,
33
+ run: (e) => m && k.mutate({
34
+ path: { approval_request_id: m },
35
+ body: e ? { reject_reason: e } : void 0
36
+ }, V("reject"))
37
+ },
38
+ approve: {
39
+ isPending: A.isPending,
40
+ run: () => m && A.mutate({ path: { approval_request_id: m } }, V("approve"))
41
+ },
42
+ cancel: {
43
+ isPending: j.isPending,
44
+ run: () => d && j.mutate({ path: { payable_id: d } }, V("cancel"))
45
+ },
46
+ cancelScheduledPayment: {
47
+ isPending: M.isPending,
48
+ run: () => {
49
+ let e = z?.scheduledPaymentRecordId;
50
+ !d || !e || M.mutate({
51
+ path: { payment_record_id: e },
52
+ payableId: d
53
+ }, V("cancelScheduledPayment"));
54
+ }
55
+ },
56
+ reopen: {
57
+ isPending: N.isPending,
58
+ run: () => d && N.mutate({ path: { payable_id: d } }, V("reopen"))
59
+ },
60
+ forceApprove: {
61
+ isPending: P.isPending,
62
+ run: () => d && P.mutate({ path: { payable_id: d } }, V("forceApprove"))
63
+ },
64
+ forceReject: {
65
+ isPending: F.isPending,
66
+ run: () => d && F.mutate({ path: { payable_id: d } }, V("forceReject"))
67
+ }
68
+ }, U = B.map((e) => ({
69
+ ...e,
70
+ disabled: I,
71
+ loading: e.id === "markAsPaid" ? w : H[e.id]?.isPending ?? !1,
72
+ onSelect: () => {
73
+ if (!(I || !d)) {
74
+ if (e.id === "payBill") {
75
+ E();
76
+ return;
77
+ }
78
+ if (e.id === "markAsPaid") {
79
+ D();
80
+ return;
81
+ }
82
+ if (h(e.id)) {
83
+ R({
84
+ id: e.id,
85
+ scheduledPaymentRecordId: x
86
+ });
87
+ return;
88
+ }
89
+ H[e.id]?.run();
90
+ }
91
+ }
92
+ }));
93
+ 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
+ ...C.decisionDialog[z.id],
102
+ presentation: g(z.id) ? p : void 0,
103
+ pendingApprovers: g(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
+ }
20
113
  };
21
- switch (n) {
22
- case "draft": return {
23
- status: "draft",
24
- tone: "neutral"
25
- };
26
- case "new":
27
- case "approve_in_progress": return {
28
- status: "pending_approval",
29
- tone: "warning"
30
- };
31
- case "waiting_to_be_paid": return {
32
- status: "ready_to_pay",
33
- tone: "info"
34
- };
35
- case "partially_paid": return {
36
- status: "partially_paid",
37
- tone: "success"
38
- };
39
- case "paid": return {
40
- status: "paid",
41
- tone: "success"
42
- };
43
- case "canceled": return {
44
- status: "canceled",
45
- tone: "muted"
46
- };
47
- case "rejected": return {
48
- status: "rejected",
49
- tone: "danger"
50
- };
51
- }
114
+ }
115
+ var p = {
116
+ alignment: "center",
117
+ icon: d,
118
+ tone: "destructive",
119
+ actionWidth: "equal"
120
+ }, m = [
121
+ "reject",
122
+ "cancel",
123
+ "cancelScheduledPayment",
124
+ "forceApprove",
125
+ "forceReject"
126
+ ];
127
+ function h(e) {
128
+ return m.includes(e);
129
+ }
130
+ function g(e) {
131
+ return e === "forceApprove" || e === "forceReject";
52
132
  }
53
133
  //#endregion
54
- export { n as derivePayableStatus };
134
+ export { f as usePayableDetailActions };