@tesouro/embedded-components-react 0.4.0 → 0.4.1

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 (61) 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 +8 -8
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +8 -14
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +7 -57
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +56 -16
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +18 -126
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +126 -14
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +22 -4
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +4 -41
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +40 -4
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +5 -73
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +72 -48
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +47 -91
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +91 -33
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +33 -167
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +167 -75
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +75 -21
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +23 -210
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +199 -203
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +198 -89
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +105 -13
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +12 -47
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +47 -31
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +27 -198
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +198 -30
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +30 -234
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +240 -18
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +18 -341
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +343 -4
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +4 -33
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +31 -83
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +78 -163
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +170 -3
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +3 -4
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +2 -44
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +46 -1
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +1 -8
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +6 -9
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +9 -92
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +94 -3
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +3 -128
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +125 -8
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -7
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +8 -46
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +43 -18
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +20 -28
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +27 -82
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +83 -47
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +47 -250
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +239 -101
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +107 -202
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +209 -3
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +4 -8
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +6 -113
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +115 -1
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +0 -24
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +25 -0
  59. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  60. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  61. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import { RefreshingRootWidgetProvider as _ } from "./libs/tesouro-embedded-compo
14
14
  import { useDisclosuresAcceptanceSurface as v, useOwnWidgetConfig as y, useRefetchWidget as b, useWidgetConfig as x, useWidgetError as S, useWidgetLoading as C } from "./libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/hooks.js";
15
15
  import { BankAccountsWidget as w } from "./libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index8.js";
16
16
  import { CounterpartsWidget as T } from "./libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index8.js";
17
- import { BillPayWidget as E } from "./libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js";
17
+ import { BillPayWidget as E } from "./libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js";
18
18
  import { CardDetailsWidget as D } from "./libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index13.js";
19
19
  import { CreditCardsWidget as O } from "./libs/tesouro-embedded-components-react/cards-widget/feature/dist/index10.js";
20
20
  import { DebitCardsWidget as k } from "./libs/tesouro-embedded-components-react/cards-widget/feature/dist/index11.js";
@@ -1,3 +1,3 @@
1
- import { BillPayWidget as e } from "../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js";
1
+ import { BillPayWidget as e } from "../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js";
2
2
  import "../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js";
3
3
  export { e as BillPayWidget };
@@ -9,23 +9,23 @@ import "./index10.js";
9
9
  import "./index11.js";
10
10
  import "./index23.js";
11
11
  import "./index24.js";
12
- import "./index40.js";
13
- import "./index49.js";
14
- import "./index51.js";
15
- import "./index53.js";
12
+ import "./index41.js";
13
+ import "./index50.js";
14
+ import "./index52.js";
16
15
  import "./index54.js";
17
16
  import "./index55.js";
18
17
  import "./index56.js";
19
18
  import "./index57.js";
20
19
  import "./index58.js";
21
- import "./index62.js";
20
+ import "./index59.js";
22
21
  import "./index63.js";
23
22
  import "./index64.js";
24
23
  import "./index65.js";
25
24
  import "./index66.js";
26
- import "./index69.js";
27
- import "./index75.js";
25
+ import "./index67.js";
26
+ import "./index70.js";
28
27
  import "./index76.js";
29
28
  import "./index77.js";
30
- import { BillPayWidget as e } from "./index81.js";
29
+ import "./index78.js";
30
+ import { BillPayWidget as e } from "./index82.js";
31
31
  export { e as BillPayWidget };
@@ -1,17 +1,11 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { usePayableHistoryQuery as e } from "../../data-access/dist/index8.js";
6
- import "../../data-access/dist/index.js";
7
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js
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
- };
2
+ function e(e) {
3
+ let t = [];
4
+ for (let n of e.steps) n.chips.some((e) => e.approved) || t.push({
5
+ id: n.id,
6
+ names: n.chips.map((e) => e.label)
7
+ });
8
+ return t;
15
9
  }
16
10
  //#endregion
17
- export { n as usePayableApprovalRoundStart };
11
+ export { e as buildPendingApproverGroupsFromCardView };
@@ -2,66 +2,16 @@
2
2
  "use client";
3
3
  "use client";
4
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 { 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";
11
- import "../../../shared/feature/dist/index.js";
12
- import { usePayableApprovalRequestsQuery as a } from "../../data-access/dist/index7.js";
5
+ import { usePayableHistoryQuery as e } from "../../data-access/dist/index8.js";
13
6
  import "../../data-access/dist/index.js";
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 "./index25.js";
17
- import { currentApprovalRound as c } from "./index26.js";
18
- import { buildPendingApproverGroups as l } from "./index27.js";
19
- import { usePayableApprovalRoundStart as u } from "./index28.js";
20
- import { useMemo as d } from "react";
21
7
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js
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]);
8
+ var t = "submitted_for_approval";
9
+ function n({ payableId: n, enabled: r = !0 }) {
10
+ let i = e(n, { enabled: r });
38
11
  return {
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)
12
+ roundStartedAt: (i.data?.data ?? []).reduce((e, n) => n.event_type === t ? n.timestamp : e, void 0),
13
+ isLoading: i.isLoading
64
14
  };
65
15
  }
66
16
  //#endregion
67
- export { f as useApprovalPolicyCardView };
17
+ export { n as usePayableApprovalRoundStart };
@@ -3,27 +3,67 @@
3
3
  "use client";
4
4
  "use client";
5
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";
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";
8
9
  import "../../../shared/data-access/dist/index.js";
9
- import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useWidgetConfig as i } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
11
  import "../../../shared/feature/dist/index.js";
11
- import { usePayableApprovalRequestsQuery as i } from "../../data-access/dist/index7.js";
12
+ import { usePayableApprovalRequestsQuery as a } from "../../data-access/dist/index7.js";
12
13
  import "../../data-access/dist/index.js";
13
- import { currentApprovalRound as a } from "./index26.js";
14
- import { usePayableApprovalRoundStart as o } from "./index28.js";
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 "./index25.js";
17
+ import { currentApprovalRound as c } from "./index26.js";
18
+ import { buildPendingApproverGroups as l } from "./index27.js";
19
+ import { buildPendingApproverGroupsFromCardView as u } from "./index28.js";
20
+ import { usePayableApprovalRoundStart as d } from "./index29.js";
21
+ import { useMemo as f } from "react";
15
22
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.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");
23
+ function p({ payableId: p, approvalPolicyId: m, enabled: h = !0, copy: g }) {
24
+ let _ = h && !!m, { initResponse: v } = i(), y = e(v?.scopes, [t.ApprovalPolicyReadOrg]), b = e(v?.scopes, [t.ApprovalRequestReadOrg]), x = e(v?.scopes, [t.RoleReadOrg]), S = e(v?.scopes, [t.UserReadOrg]), C = o({ enabled: _ && y }), w = n({ enabled: _ && x }), T = r({ enabled: _ && S }), E = a(p, { enabled: _ && b }), { roundStartedAt: D } = d({
25
+ payableId: p,
26
+ enabled: _ && b
27
+ }), O = f(() => {
28
+ let e = /* @__PURE__ */ new Map();
29
+ for (let t of w.data?.data ?? []) e.set(t.id, {
30
+ label: t.name,
31
+ kind: "role"
32
+ });
33
+ for (let t of T.data?.data ?? []) e.set(t.id, {
34
+ label: t.name,
35
+ kind: "user"
36
+ });
37
+ return e;
38
+ }, [w.data, T.data]), k = f(() => c(E.data?.data, D), [E.data, D]), A = f(() => new Set(k.flatMap((e) => e.approved_by ?? [])), [k]), j = f(() => new Set(k.filter((e) => (e.approved_by ?? []).length > 0).flatMap((e) => e.role_ids ?? [])), [k]), M = f(() => m ? C.data?.data.find((e) => e.id === m) : void 0, [C.data, m]), N = f(() => _ && M ? s({
39
+ policy: M,
40
+ lookup: O,
41
+ approvedUserIds: A,
42
+ approvedRoleIds: j,
43
+ copy: g
44
+ }) : void 0, [
45
+ _,
46
+ M,
47
+ O,
48
+ A,
49
+ j,
50
+ g
51
+ ]);
21
52
  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
53
+ view: N,
54
+ pendingApprovers: f(() => _ ? N ? u(N) : l({
55
+ requestsNewestFirst: E.data?.data,
56
+ roundStartedAt: D,
57
+ lookup: O
58
+ }) : [], [
59
+ _,
60
+ N,
61
+ E.data,
62
+ D,
63
+ O
64
+ ]),
65
+ isLoading: _ && (C.isResolving || w.isResolving || T.isResolving || E.isLoading)
26
66
  };
27
67
  }
28
68
  //#endregion
29
- export { s as useCurrentApprovalRequestId };
69
+ export { p as useApprovalPolicyCardView };
@@ -2,136 +2,28 @@
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 { 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";
8
10
  import "../../../shared/feature/dist/index.js";
9
- import { useApprovePayableApprovalRequestMutation as n, useRejectPayableApprovalRequestMutation as r } from "../../data-access/dist/index7.js";
10
- import { useCancelPayableMutation as i, useCancelScheduledPaymentMutation as a, useForceApprovePayableMutation as o, useForceRejectPayableMutation as s, useReopenPayableMutation as c } from "../../data-access/dist/index12.js";
11
+ import { usePayableApprovalRequestsQuery as i } from "../../data-access/dist/index7.js";
11
12
  import "../../data-access/dist/index.js";
12
- import { getBillDetailActions as l } from "./index16.js";
13
- import { useState as u } from "react";
14
- import { HandIcon as d } from "lucide-react";
13
+ import { currentApprovalRound as a } from "./index26.js";
14
+ import { usePayableApprovalRoundStart as o } from "./index29.js";
15
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js
16
- function f({ payableId: d, status: f, currentApprovalRequestId: m, isPolicyApprover: _, hasWaitingRequest: v, arePendingApproversUnknown: y, hasScheduledPayment: b, scheduledPaymentIntentId: x, isScheduledPaymentUnknown: S, labels: C, isMarkAsPaidPending: w, pendingApprovers: T, onPayBillSelect: E, onMarkAsPaidSelect: D, onActionSucceeded: O }) {
17
- let { initResponse: k } = t(), A = r(), j = n(), M = i(), N = a(), P = c(), F = o(), I = s(), L = w || A.isPending || j.isPending || M.isPending || N.isPending || P.isPending || F.isPending || I.isPending, [R, z] = u(), B = R && (R.id !== "cancelScheduledPayment" || R.scheduledPaymentIntentId === x) ? R : void 0, V = d && f ? l({
18
- status: f,
19
- scopes: k?.scopes,
20
- canDecideApprovalRequest: !!m,
21
- isPolicyApprover: _,
22
- hasWaitingRequest: v,
23
- arePendingApproversUnknown: y,
24
- hasScheduledPayment: b || S,
25
- scheduledPaymentIntentId: x,
26
- labels: C
27
- }) : [], H = (t) => ({
28
- onError: () => e.error(C.actionError),
29
- onSuccess: () => {
30
- e.success(C.actionSuccess[t]), O?.();
31
- }
32
- }), U = {
33
- reject: {
34
- isPending: A.isPending,
35
- run: (e) => m && A.mutate({
36
- path: { approval_request_id: m },
37
- body: e ? { reject_reason: e } : void 0
38
- }, H("reject"))
39
- },
40
- approve: {
41
- isPending: j.isPending,
42
- run: () => m && j.mutate({ path: { approval_request_id: m } }, H("approve"))
43
- },
44
- cancel: {
45
- isPending: M.isPending,
46
- run: () => d && M.mutate({ path: { payable_id: d } }, H("cancel"))
47
- },
48
- cancelScheduledPayment: {
49
- isPending: N.isPending,
50
- run: () => {
51
- let e = B?.scheduledPaymentIntentId;
52
- !d || !e || N.mutate({
53
- path: { payment_intent_id: e },
54
- payableId: d
55
- }, H("cancelScheduledPayment"));
56
- }
57
- },
58
- reopen: {
59
- isPending: P.isPending,
60
- run: () => d && P.mutate({ path: { payable_id: d } }, H("reopen"))
61
- },
62
- forceApprove: {
63
- isPending: F.isPending,
64
- run: () => d && F.mutate({ path: { payable_id: d } }, H("forceApprove"))
65
- },
66
- forceReject: {
67
- isPending: I.isPending,
68
- run: () => d && I.mutate({ path: { payable_id: d } }, H("forceReject"))
69
- }
70
- }, W = V.map((e) => ({
71
- ...e,
72
- disabled: L,
73
- loading: e.id === "markAsPaid" ? w : U[e.id]?.isPending ?? !1,
74
- onSelect: () => {
75
- if (!(L || !d)) {
76
- if (e.id === "payBill") {
77
- E();
78
- return;
79
- }
80
- if (e.id === "markAsPaid") {
81
- D();
82
- return;
83
- }
84
- if (h(e.id)) {
85
- z({
86
- id: e.id,
87
- scheduledPaymentIntentId: x
88
- });
89
- return;
90
- }
91
- U[e.id]?.run();
92
- }
93
- }
94
- }));
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");
95
21
  return {
96
- isActionPending: L,
97
- actions: {
98
- row: W.filter((e) => e.surface === "row"),
99
- menu: W.filter((e) => e.surface === "menu")
100
- },
101
- decisionDialog: {
102
- open: !!B,
103
- copy: B ? {
104
- ...C.decisionDialog[B.id],
105
- presentation: g(B.id) ? p : void 0,
106
- pendingApprovers: g(B.id) ? T ?? [] : void 0
107
- } : void 0,
108
- isPending: B ? U[B.id]?.isPending ?? !1 : !1,
109
- onCancel: () => {
110
- L || z(void 0);
111
- },
112
- onConfirm: (e) => {
113
- !B || L || (U[B.id]?.run(e), z(void 0));
114
- }
115
- }
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
116
26
  };
117
27
  }
118
- var p = {
119
- alignment: "center",
120
- icon: d,
121
- tone: "destructive",
122
- actionWidth: "equal"
123
- }, m = [
124
- "reject",
125
- "cancel",
126
- "cancelScheduledPayment",
127
- "forceApprove",
128
- "forceReject"
129
- ];
130
- function h(e) {
131
- return m.includes(e);
132
- }
133
- function g(e) {
134
- return e === "forceApprove" || e === "forceReject";
135
- }
136
28
  //#endregion
137
- export { f as usePayableDetailActions };
29
+ export { s as useCurrentApprovalRequestId };
@@ -2,24 +2,136 @@
2
2
  "use client";
3
3
  "use client";
4
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 { formatCalendarDate as n } from "../../../shared/util/dist/lib/formatCalendarDate.js";
9
- import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
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";
10
8
  import "../../../shared/feature/dist/index.js";
11
- import { isLiveScheduledPaymentRecord as i } from "../../data-access/dist/index3.js";
12
- import { usePayablePaymentRecordsQuery as a } from "../../data-access/dist/index10.js";
9
+ import { useApprovePayableApprovalRequestMutation as n, useRejectPayableApprovalRequestMutation as r } from "../../data-access/dist/index7.js";
10
+ import { useCancelPayableMutation as i, useCancelScheduledPaymentMutation as a, useForceApprovePayableMutation as o, useForceRejectPayableMutation as s, useReopenPayableMutation as c } from "../../data-access/dist/index12.js";
13
11
  import "../../data-access/dist/index.js";
12
+ import { getBillDetailActions as l } from "./index16.js";
13
+ import { useState as u } from "react";
14
+ import { HandIcon as d } from "lucide-react";
14
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js
15
- function o({ payableId: o, scheduledPaymentDate: s, enabled: c = !0 }) {
16
- let { initResponse: l } = r(), u = e(l?.scopes, [t.PaymentRecordReadOrg]), d = a(c ? o : void 0, { enabled: c && u }), f = d.paymentRecords.find(i), p = !!f || !!s, m = f?.planned_payment_date ?? (p ? s : void 0);
16
+ function f({ payableId: d, status: f, currentApprovalRequestId: m, isPolicyApprover: _, hasWaitingRequest: v, arePendingApproversUnknown: y, hasScheduledPayment: b, scheduledPaymentIntentId: x, isScheduledPaymentUnknown: S, labels: C, isMarkAsPaidPending: w, pendingApprovers: T, onPayBillSelect: E, onMarkAsPaidSelect: D, onActionSucceeded: O }) {
17
+ let { initResponse: k } = t(), A = r(), j = n(), M = i(), N = a(), P = c(), F = o(), I = s(), L = w || A.isPending || j.isPending || M.isPending || N.isPending || P.isPending || F.isPending || I.isPending, [R, z] = u(), B = R && (R.id !== "cancelScheduledPayment" || R.scheduledPaymentIntentId === x) ? R : void 0, V = d && f ? l({
18
+ status: f,
19
+ scopes: k?.scopes,
20
+ canDecideApprovalRequest: !!m,
21
+ isPolicyApprover: _,
22
+ hasWaitingRequest: v,
23
+ arePendingApproversUnknown: y,
24
+ hasScheduledPayment: b || S,
25
+ scheduledPaymentIntentId: x,
26
+ labels: C
27
+ }) : [], H = (t) => ({
28
+ onError: () => e.error(C.actionError),
29
+ onSuccess: () => {
30
+ e.success(C.actionSuccess[t]), O?.();
31
+ }
32
+ }), U = {
33
+ reject: {
34
+ isPending: A.isPending,
35
+ run: (e) => m && A.mutate({
36
+ path: { approval_request_id: m },
37
+ body: e ? { reject_reason: e } : void 0
38
+ }, H("reject"))
39
+ },
40
+ approve: {
41
+ isPending: j.isPending,
42
+ run: () => m && j.mutate({ path: { approval_request_id: m } }, H("approve"))
43
+ },
44
+ cancel: {
45
+ isPending: M.isPending,
46
+ run: () => d && M.mutate({ path: { payable_id: d } }, H("cancel"))
47
+ },
48
+ cancelScheduledPayment: {
49
+ isPending: N.isPending,
50
+ run: () => {
51
+ let e = B?.scheduledPaymentIntentId;
52
+ !d || !e || N.mutate({
53
+ path: { payment_intent_id: e },
54
+ payableId: d
55
+ }, H("cancelScheduledPayment"));
56
+ }
57
+ },
58
+ reopen: {
59
+ isPending: P.isPending,
60
+ run: () => d && P.mutate({ path: { payable_id: d } }, H("reopen"))
61
+ },
62
+ forceApprove: {
63
+ isPending: F.isPending,
64
+ run: () => d && F.mutate({ path: { payable_id: d } }, H("forceApprove"))
65
+ },
66
+ forceReject: {
67
+ isPending: I.isPending,
68
+ run: () => d && I.mutate({ path: { payable_id: d } }, H("forceReject"))
69
+ }
70
+ }, W = V.map((e) => ({
71
+ ...e,
72
+ disabled: L,
73
+ loading: e.id === "markAsPaid" ? w : U[e.id]?.isPending ?? !1,
74
+ onSelect: () => {
75
+ if (!(L || !d)) {
76
+ if (e.id === "payBill") {
77
+ E();
78
+ return;
79
+ }
80
+ if (e.id === "markAsPaid") {
81
+ D();
82
+ return;
83
+ }
84
+ if (h(e.id)) {
85
+ z({
86
+ id: e.id,
87
+ scheduledPaymentIntentId: x
88
+ });
89
+ return;
90
+ }
91
+ U[e.id]?.run();
92
+ }
93
+ }
94
+ }));
17
95
  return {
18
- hasScheduledPayment: p,
19
- isResolving: d.isResolving,
20
- scheduledDateLabel: m ? n(m) : void 0,
21
- scheduledPaymentIntentId: f?.payment_intent_id ?? void 0
96
+ isActionPending: L,
97
+ actions: {
98
+ row: W.filter((e) => e.surface === "row"),
99
+ menu: W.filter((e) => e.surface === "menu")
100
+ },
101
+ decisionDialog: {
102
+ open: !!B,
103
+ copy: B ? {
104
+ ...C.decisionDialog[B.id],
105
+ presentation: g(B.id) ? p : void 0,
106
+ pendingApprovers: g(B.id) ? T ?? [] : void 0
107
+ } : void 0,
108
+ isPending: B ? U[B.id]?.isPending ?? !1 : !1,
109
+ onCancel: () => {
110
+ L || z(void 0);
111
+ },
112
+ onConfirm: (e) => {
113
+ !B || L || (U[B.id]?.run(e), z(void 0));
114
+ }
115
+ }
22
116
  };
23
117
  }
118
+ var p = {
119
+ alignment: "center",
120
+ icon: d,
121
+ tone: "destructive",
122
+ actionWidth: "equal"
123
+ }, m = [
124
+ "reject",
125
+ "cancel",
126
+ "cancelScheduledPayment",
127
+ "forceApprove",
128
+ "forceReject"
129
+ ];
130
+ function h(e) {
131
+ return m.includes(e);
132
+ }
133
+ function g(e) {
134
+ return e === "forceApprove" || e === "forceReject";
135
+ }
24
136
  //#endregion
25
- export { o as useScheduledPayment };
137
+ export { f as usePayableDetailActions };
@@ -1,7 +1,25 @@
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 { formatCalendarDate as n } from "../../../shared/util/dist/lib/formatCalendarDate.js";
9
+ import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import "../../../shared/feature/dist/index.js";
11
+ import { isLiveScheduledPaymentRecord as i } from "../../data-access/dist/index3.js";
12
+ import { usePayablePaymentRecordsQuery as a } from "../../data-access/dist/index10.js";
13
+ import "../../data-access/dist/index.js";
1
14
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js
2
- var e = /* @__PURE__ */ new Set(["draft", "new"]);
3
- function t(t) {
4
- return !!(t && e.has(t));
15
+ function o({ payableId: o, scheduledPaymentDate: s, enabled: c = !0 }) {
16
+ let { initResponse: l } = r(), u = e(l?.scopes, [t.PaymentRecordReadOrg]), d = a(c ? o : void 0, { enabled: c && u }), f = d.paymentRecords.find(i), p = !!f || !!s, m = f?.planned_payment_date ?? (p ? s : void 0);
17
+ return {
18
+ hasScheduledPayment: p,
19
+ isResolving: d.isResolving,
20
+ scheduledDateLabel: m ? n(m) : void 0,
21
+ scheduledPaymentIntentId: f?.payment_intent_id ?? void 0
22
+ };
5
23
  }
6
24
  //#endregion
7
- export { t as isEditablePayableStatus };
25
+ export { o as useScheduledPayment };
@@ -1,44 +1,7 @@
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";
8
- 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/index12.js";
13
- import "../../data-access/dist/index.js";
14
- import { useState as a } from "react";
15
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.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
- };
2
+ var e = /* @__PURE__ */ new Set(["draft", "new"]);
3
+ function t(t) {
4
+ return !!(t && e.has(t));
42
5
  }
43
6
  //#endregion
44
- export { o as useDraftDelete };
7
+ export { t as isEditablePayableStatus };