@tesouro/embedded-components-react 0.5.3 → 0.5.4

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 (90) 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 +13 -13
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +70 -5
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +37 -64
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +110 -38
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +73 -104
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +7 -87
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +21 -7
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +22 -17
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +63 -23
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +2 -66
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +81 -2
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +3 -78
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +5 -4
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +4 -5
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +32 -3
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +39 -30
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +166 -37
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +39 -164
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +1 -48
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +50 -1
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +11 -45
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +8 -13
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +14 -8
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +59 -7
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +8 -64
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +24 -8
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +139 -18
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +16 -139
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +4 -24
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +41 -4
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +14 -39
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +8 -16
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +91 -8
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +86 -80
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +3 -97
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +49 -3
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +135 -47
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +33 -135
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +186 -33
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +75 -186
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +21 -75
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +25 -14
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +232 -22
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +210 -223
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +103 -202
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +13 -121
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +47 -12
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +31 -47
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +198 -27
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +31 -198
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +234 -31
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +19 -240
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +24 -25
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +427 -19
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +4 -433
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +38 -4
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +220 -35
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +3 -224
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +4 -3
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +44 -2
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +1 -46
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -1
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +10 -6
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +57 -21
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +110 -10
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -112
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +127 -3
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -124
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +7 -8
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +46 -8
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +18 -43
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +28 -20
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +82 -27
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +47 -83
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +5 -58
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +250 -47
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +101 -239
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +202 -107
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +3 -209
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +8 -4
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +113 -6
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +1 -115
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +24 -0
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +4 -5
  87. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  88. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  89. package/package.json +1 -1
  90. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +0 -25
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, useWidgetInitStaleForToken as C, useWidgetLoading as w } from "./libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/hooks.js";
15
15
  import { BankAccountsWidget as T } from "./libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index8.js";
16
16
  import { CounterpartsWidget as E } from "./libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index8.js";
17
- import { BillPayWidget as D } from "./libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js";
17
+ import { BillPayWidget as D } from "./libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js";
18
18
  import { CardDetailsWidget as O } from "./libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index13.js";
19
19
  import { CreditCardsWidget as k } from "./libs/tesouro-embedded-components-react/cards-widget/feature/dist/index10.js";
20
20
  import { DebitCardsWidget as A } 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/index88.js";
1
+ import { BillPayWidget as e } from "../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js";
2
2
  import "../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js";
3
3
  export { e as BillPayWidget };
@@ -1,32 +1,32 @@
1
+ import "./index5.js";
1
2
  import "./index6.js";
2
3
  import "./index7.js";
3
- import "./index8.js";
4
+ import "./index9.js";
4
5
  import "./index10.js";
5
6
  import "./index11.js";
6
7
  import "./index12.js";
7
8
  import "./index13.js";
8
9
  import "./index14.js";
9
- import "./index15.js";
10
+ import "./index26.js";
10
11
  import "./index27.js";
11
- import "./index28.js";
12
- import "./index40.js";
13
- import "./index42.js";
14
- import "./index48.js";
15
- import "./index57.js";
16
- import "./index59.js";
12
+ import "./index39.js";
13
+ import "./index41.js";
14
+ import "./index47.js";
15
+ import "./index56.js";
16
+ import "./index58.js";
17
+ import "./index60.js";
17
18
  import "./index61.js";
18
19
  import "./index62.js";
19
20
  import "./index63.js";
20
21
  import "./index64.js";
21
- import "./index65.js";
22
+ import "./index68.js";
22
23
  import "./index69.js";
23
24
  import "./index70.js";
24
25
  import "./index71.js";
25
26
  import "./index72.js";
26
- import "./index73.js";
27
- import "./index76.js";
27
+ import "./index75.js";
28
+ import "./index81.js";
28
29
  import "./index82.js";
29
30
  import "./index83.js";
30
- import "./index84.js";
31
- import { BillPayWidget as e } from "./index88.js";
31
+ import { BillPayWidget as e } from "./index87.js";
32
32
  export { e as BillPayWidget };
@@ -1,8 +1,73 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { formatCalendarDate as e } from "../../../shared/util/dist/lib/formatCalendarDate.js";
6
+ import { formatMoneyExact as t } from "../../../shared/util/dist/lib/formatMoneyExact.js";
7
+ import { suspectedPayableDuplicates as n } from "../../data-access/dist/index7.js";
8
+ import { useAllSuspectedDuplicatePayablesQuery as r, usePayablesQuery as i } from "../../data-access/dist/index17.js";
9
+ import "../../data-access/dist/index.js";
10
+ import { groupSuspectedDuplicates as a } from "./index6.js";
11
+ import { derivePayableStatus as o } from "./index7.js";
12
+ import { payableRemoval as s } from "./index9.js";
13
+ import { resolveVendorName as c } from "./index8.js";
14
+ import { useMemo as l } from "react";
1
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js
2
- function e(e) {
3
- if (e === "draft") return "delete";
4
- if (e === "new") return "cancel";
5
- if (e === "canceled") return "confirm";
16
+ function u(e) {
17
+ return e.isError && e.data === void 0;
18
+ }
19
+ function d(e, n) {
20
+ return e == null ? "" : t(e / 100, { currencyCode: n ?? "USD" });
21
+ }
22
+ function f(t) {
23
+ let r = t.status ? o({
24
+ apiStatus: t.status,
25
+ dueDate: t.due_date,
26
+ scheduledPaymentDate: t.scheduled_payment_date
27
+ }) : void 0;
28
+ return {
29
+ id: t.id,
30
+ status: r?.status,
31
+ statusTone: r?.tone,
32
+ matches: n(t).map((e) => ({
33
+ matchId: e.id,
34
+ matchedPayableId: e.matched_payable_id
35
+ })),
36
+ removeBy: s(t.status),
37
+ vendorLabel: c(t),
38
+ invoiceNumberLabel: t.document_id ?? "",
39
+ amountLabel: d(t.total_amount ?? t.amount_due, t.currency),
40
+ dueDateLabel: e(t.due_date),
41
+ addedOnLabel: e(t.created_at?.slice(0, 10))
42
+ };
43
+ }
44
+ function p(e) {
45
+ return a(e).map(({ members: e }) => e).filter((e) => e.length > 1).map((e) => ({
46
+ id: e[0].id,
47
+ vendorLabel: e.map(c).find(Boolean) ?? "",
48
+ bills: e.map(f)
49
+ }));
50
+ }
51
+ function m({ enabled: e = !0 } = {}) {
52
+ let t = r({ enabled: e }), n = t.data?.data;
53
+ return {
54
+ groups: l(() => p(n ?? []), [n]),
55
+ isLoading: t.isLoading,
56
+ isError: u(t)
57
+ };
58
+ }
59
+ function h({ enabled: e = !0 } = {}) {
60
+ let t = i({
61
+ duplicate_match_status: "suspected",
62
+ limit: 100,
63
+ enabled: e
64
+ });
65
+ return {
66
+ count: t.data?.data?.length ?? 0,
67
+ isCapped: !!t.data?.next_pagination_token,
68
+ isError: u(t),
69
+ isLoading: t.isLoading
70
+ };
6
71
  }
7
72
  //#endregion
8
- export { e as payableRemoval };
73
+ export { m as useDuplicateBills, h as useDuplicateBillsCount };
@@ -2,72 +2,45 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { formatCalendarDate as e } from "../../../shared/util/dist/lib/formatCalendarDate.js";
6
- import { formatMoneyExact as t } from "../../../shared/util/dist/lib/formatMoneyExact.js";
7
- import { suspectedPayableDuplicates as n } from "../../data-access/dist/index7.js";
8
- import { useAllSuspectedDuplicatePayablesQuery as r, usePayablesQuery as i } from "../../data-access/dist/index17.js";
9
- import "../../data-access/dist/index.js";
10
- import { groupSuspectedDuplicates as a } from "./index7.js";
11
- import { derivePayableStatus as o } from "./index8.js";
12
- import { payableRemoval as s } from "./index10.js";
13
- import { resolveVendorName as c } from "./index9.js";
14
- import { useMemo as l } from "react";
5
+ import { useCallback as e, useEffect as t, useState as n } from "react";
15
6
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js
16
- function u(e) {
17
- return e.isError && e.data === void 0;
18
- }
19
- function d(e, n) {
20
- return e == null ? "" : t(e / 100, { currencyCode: n ?? "USD" });
21
- }
22
- function f(t) {
23
- let r = t.status ? o({
24
- apiStatus: t.status,
25
- dueDate: t.due_date,
26
- scheduledPaymentDate: t.scheduled_payment_date
27
- }) : void 0;
28
- return {
29
- id: t.id,
30
- status: r?.status,
31
- statusTone: r?.tone,
32
- matches: n(t).map((e) => ({
33
- matchId: e.id,
34
- matchedPayableId: e.matched_payable_id
35
- })),
36
- removeBy: s(t.status),
37
- vendorLabel: c(t),
38
- invoiceNumberLabel: t.document_id ?? "",
39
- amountLabel: d(t.total_amount ?? t.amount_due, t.currency),
40
- dueDateLabel: e(t.due_date),
41
- addedOnLabel: e(t.created_at?.slice(0, 10))
42
- };
43
- }
44
- function p(e) {
45
- return a(e).map(({ members: e }) => e).filter((e) => e.length > 1).map((e) => ({
46
- id: e[0].id,
47
- vendorLabel: e.map(c).find(Boolean) ?? "",
48
- bills: e.map(f)
49
- }));
50
- }
51
- function m({ enabled: e = !0 } = {}) {
52
- let t = r({ enabled: e }), n = t.data?.data;
53
- return {
54
- groups: l(() => p(n ?? []), [n]),
55
- isLoading: t.isLoading,
56
- isError: u(t)
57
- };
58
- }
59
- function h({ enabled: e = !0 } = {}) {
60
- let t = i({
61
- duplicate_match_status: "suspected",
62
- limit: 100,
63
- enabled: e
64
- });
7
+ function r({ reviewIds: r }) {
8
+ let [i, a] = n(/* @__PURE__ */ new Set());
9
+ t(() => {
10
+ let e = new Set(r);
11
+ a((t) => {
12
+ let n = new Set([...t].filter((t) => e.has(t)));
13
+ return n.size === t.size ? t : n;
14
+ });
15
+ }, [r]);
16
+ let o = e((e) => {
17
+ a((t) => {
18
+ let n = new Set(t);
19
+ return n.delete(e) || n.add(e), n;
20
+ });
21
+ }, []), s = e((e) => {
22
+ a((t) => {
23
+ let n = new Set(t), r = e.every((e) => n.has(e));
24
+ return e.forEach((e) => {
25
+ r ? n.delete(e) : n.add(e);
26
+ }), n;
27
+ });
28
+ }, []), c = e((e) => {
29
+ a((t) => {
30
+ let n = new Set(t);
31
+ return e.forEach((e) => n.delete(e)), n;
32
+ });
33
+ }, []);
65
34
  return {
66
- count: t.data?.data?.length ?? 0,
67
- isCapped: !!t.data?.next_pagination_token,
68
- isError: u(t),
69
- isLoading: t.isLoading
35
+ isSelected: e((e) => i.has(e), [i]),
36
+ toggle: o,
37
+ toggleAll: s,
38
+ checkedState: e((e) => {
39
+ let t = e.filter((e) => i.has(e)).length;
40
+ return t === 0 ? !1 : t === e.length || "indeterminate";
41
+ }, [i]),
42
+ deselect: c
70
43
  };
71
44
  }
72
45
  //#endregion
73
- export { m as useDuplicateBills, h as useDuplicateBillsCount };
46
+ export { r as useDuplicateBillsSelection };
@@ -2,45 +2,117 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { useCallback as e, useEffect as t, useState as n } from "react";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import "../../../shared/ui/dist/index.js";
7
+ import { DUPLICATE_BILLS_LABELS_EN as t } from "./index5.js";
8
+ import { DuplicateVerdict as n, useApplyDuplicateVerdictsMutation as r } from "../../data-access/dist/index7.js";
9
+ import "../../data-access/dist/index.js";
10
+ import { useDuplicateBills as i } from "./index10.js";
11
+ import { useDuplicateBillsSelection as a } from "./index11.js";
12
+ import { DuplicateBillsDialog as o } from "../../ui/dist/index84.js";
13
+ import "../../ui/dist/index.js";
14
+ import { useEffect as s, useMemo as c, useState as l } from "react";
15
+ import { jsx as u } from "react/jsx-runtime";
6
16
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js
7
- function r({ reviewIds: r }) {
8
- let [i, a] = n(/* @__PURE__ */ new Set());
9
- t(() => {
10
- let e = new Set(r);
11
- a((t) => {
12
- let n = new Set([...t].filter((t) => e.has(t)));
13
- return n.size === t.size ? t : n;
17
+ var d = "";
18
+ function f({ open: f, onOpenChange: p, enabled: m = !0, canManageDuplicates: h = !0, onOpenBill: g, labels: _, dialogLabels: v }) {
19
+ let y = c(() => ({
20
+ ...t,
21
+ ..._
22
+ }), [_]), b = _?.allResolvedToast ?? t.allResolvedToast, x = i({ enabled: m }), S = c(() => x.groups.flatMap((e) => e.bills.map((e) => e.id)), [x.groups]), C = a({ reviewIds: S }), w = r(), [T, E] = l(), [D, O] = l(!1), [k, A] = l(), j = c(() => {
23
+ let [e] = x.groups;
24
+ if (e) {
25
+ if (!k) return e.id;
26
+ if (k.id !== d) return x.groups.some((e) => e.id === k.id) ? k.id : (x.groups[k.index] ?? x.groups[x.groups.length - 1]).id;
27
+ }
28
+ }, [k, x.groups]);
29
+ s(() => {
30
+ if (!f) {
31
+ O(!1);
32
+ return;
33
+ }
34
+ !D || x.isLoading || x.isError || x.groups.length > 0 || (e.success(b), p(!1));
35
+ }, [
36
+ b,
37
+ D,
38
+ p,
39
+ f,
40
+ x.groups.length,
41
+ x.isError,
42
+ x.isLoading
43
+ ]);
44
+ let M = (e) => e.bills.filter((e) => C.isSelected(e.id)), N = async (t, n, r, i) => {
45
+ let a = M(t);
46
+ if (a.length === 0) throw Error("Duplicate review action taken with no bills selected — keeping and removing both need a subject.");
47
+ let o = a.flatMap((e) => e.matches.map((t) => ({
48
+ payableId: e.id,
49
+ duplicateId: t.matchId,
50
+ matchedPayableId: t.matchedPayableId,
51
+ removeBy: e.removeBy
52
+ })));
53
+ E({
54
+ groupId: t.id,
55
+ action: r
14
56
  });
15
- }, [r]);
16
- let o = e((e) => {
17
- a((t) => {
18
- let n = new Set(t);
19
- return n.delete(e) || n.add(e), n;
20
- });
21
- }, []), s = e((e) => {
22
- a((t) => {
23
- let n = new Set(t), r = e.every((e) => n.has(e));
24
- return e.forEach((e) => {
25
- r ? n.delete(e) : n.add(e);
26
- }), n;
27
- });
28
- }, []), c = e((e) => {
29
- a((t) => {
30
- let n = new Set(t);
31
- return e.forEach((e) => n.delete(e)), n;
32
- });
33
- }, []);
34
- return {
35
- isSelected: e((e) => i.has(e), [i]),
36
- toggle: o,
37
- toggleAll: s,
38
- checkedState: e((e) => {
39
- let t = e.filter((e) => i.has(e)).length;
40
- return t === 0 ? !1 : t === e.length || "indeterminate";
41
- }, [i]),
42
- deselect: c
43
- };
57
+ try {
58
+ await w.mutateAsync({
59
+ verdict: n,
60
+ targets: o
61
+ }), e.success(i), O(!0), C.deselect(a.map((e) => e.id));
62
+ } catch {
63
+ e.error(y.verdictFailedToast);
64
+ } finally {
65
+ E(void 0);
66
+ }
67
+ }, P = x.groups.map((e) => {
68
+ let t = e.bills.map((e) => e.id), r = M(e), i = {
69
+ vendorLabel: e.vendorLabel,
70
+ count: e.bills.length
71
+ };
72
+ return {
73
+ id: e.id,
74
+ titleLabel: e.vendorLabel,
75
+ countLabel: String(e.bills.length),
76
+ accessibleLabel: y.reviewGroup(i),
77
+ selectAllLabel: y.selectGroup(i),
78
+ selectAllChecked: C.checkedState(t),
79
+ onToggleAllRows: () => C.toggleAll(t),
80
+ rows: e.bills.map((e) => ({
81
+ id: e.id,
82
+ status: e.status,
83
+ statusTone: e.statusTone,
84
+ removalOutcome: e.removeBy === "delete" || e.removeBy === "cancel" ? e.removeBy : void 0,
85
+ invoiceNumberLabel: e.invoiceNumberLabel,
86
+ amountLabel: e.amountLabel,
87
+ dueDateLabel: e.dueDateLabel,
88
+ addedOnLabel: e.addedOnLabel,
89
+ selectLabel: y.selectRow(e),
90
+ openLabel: y.openRow(e),
91
+ isSelected: C.isSelected(e.id),
92
+ onToggleSelected: () => C.toggle(e.id),
93
+ onOpen: () => g?.(e.id)
94
+ })),
95
+ onKeepSelected: h ? () => void N(e, n.Keep, "keep", y.dismissedToast) : void 0,
96
+ onRemoveDuplicates: h ? () => void N(e, n.Remove, "remove", y.removedToast) : void 0,
97
+ isActionDisabled: r.length === 0,
98
+ isRemoveUnavailable: r.some((e) => !e.removeBy),
99
+ pendingAction: T?.groupId === e.id ? T.action : void 0
100
+ };
101
+ });
102
+ return /* @__PURE__ */ u(o, {
103
+ open: f,
104
+ onOpenChange: p,
105
+ groups: P,
106
+ isLoading: x.isLoading,
107
+ isError: x.isError,
108
+ expandedGroupId: j,
109
+ onExpandedGroupChange: (e) => A({
110
+ id: e,
111
+ index: x.groups.findIndex((t) => t.id === e)
112
+ }),
113
+ isBusy: !!T,
114
+ labels: v
115
+ });
44
116
  }
45
117
  //#endregion
46
- export { r as useDuplicateBillsSelection };
118
+ export { f as DuplicateBillsContainer, f as default };
@@ -4,115 +4,84 @@
4
4
  "use client";
5
5
  import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
6
  import "../../../shared/ui/dist/index.js";
7
- import { DUPLICATE_BILLS_LABELS_EN as t } from "./index6.js";
8
- import { DuplicateVerdict as n, useApplyDuplicateVerdictsMutation as r } from "../../data-access/dist/index7.js";
7
+ import { DUPLICATE_BILLS_LABELS_EN as t } from "./index5.js";
8
+ import { DuplicateVerdict as n, suspectedPayableDuplicates as r, useApplyDuplicateVerdictsMutation as i } from "../../data-access/dist/index7.js";
9
9
  import "../../data-access/dist/index.js";
10
- import { useDuplicateBills as i } from "./index11.js";
11
- import { useDuplicateBillsSelection as a } from "./index12.js";
12
- import { DuplicateBillsDialog as o } from "../../ui/dist/index84.js";
13
- import "../../ui/dist/index.js";
14
- import { useEffect as s, useMemo as c, useState as l } from "react";
15
- import { jsx as u } from "react/jsx-runtime";
10
+ import { payableRemoval as a } from "./index9.js";
11
+ import { useCallback as o, useMemo as s, useState as c } from "react";
16
12
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js
17
- var d = "";
18
- function f({ open: f, onOpenChange: p, enabled: m = !0, canManageDuplicates: h = !0, onOpenBill: g, labels: _, dialogLabels: v }) {
19
- let y = c(() => ({
13
+ function l({ payable: l, canManage: u = !0, onRemoved: d, labels: f }) {
14
+ let p = s(() => ({
20
15
  ...t,
21
- ..._
22
- }), [_]), b = _?.allResolvedToast ?? t.allResolvedToast, x = i({ enabled: m }), S = c(() => x.groups.flatMap((e) => e.bills.map((e) => e.id)), [x.groups]), C = a({ reviewIds: S }), w = r(), [T, E] = l(), [D, O] = l(!1), [k, A] = l(), j = c(() => {
23
- let [e] = x.groups;
24
- if (e) {
25
- if (!k) return e.id;
26
- if (k.id !== d) return x.groups.some((e) => e.id === k.id) ? k.id : (x.groups[k.index] ?? x.groups[x.groups.length - 1]).id;
27
- }
28
- }, [k, x.groups]);
29
- s(() => {
30
- if (!f) {
31
- O(!1);
32
- return;
16
+ ...f
17
+ }), [f]), m = r(l), [h] = m, g = l?.id, _ = i(), [v, y] = c(!1), b = a(l?.status), x = o(async (t, n, r) => {
18
+ if (!(!m.length || !g)) try {
19
+ await _.mutateAsync({
20
+ verdict: t,
21
+ targets: m.map((e) => ({
22
+ payableId: g,
23
+ duplicateId: e.id,
24
+ matchedPayableId: e.matched_payable_id,
25
+ removeBy: b
26
+ }))
27
+ }), e.success(n), r?.();
28
+ } catch {
29
+ e.error(p.verdictFailedToast);
33
30
  }
34
- !D || x.isLoading || x.isError || x.groups.length > 0 || (e.success(b), p(!1));
35
31
  }, [
36
- b,
37
- D,
32
+ _,
38
33
  p,
39
- f,
40
- x.groups.length,
41
- x.isError,
42
- x.isLoading
43
- ]);
44
- let M = (e) => e.bills.filter((e) => C.isSelected(e.id)), N = async (t, n, r, i) => {
45
- let a = M(t);
46
- if (a.length === 0) throw Error("Duplicate review action taken with no bills selected — keeping and removing both need a subject.");
47
- let o = a.flatMap((e) => e.matches.map((t) => ({
48
- payableId: e.id,
49
- duplicateId: t.matchId,
50
- matchedPayableId: t.matchedPayableId,
51
- removeBy: e.removeBy
52
- })));
53
- E({
54
- groupId: t.id,
55
- action: r
56
- });
57
- try {
58
- await w.mutateAsync({
59
- verdict: n,
60
- targets: o
61
- }), e.success(i), O(!0), C.deselect(a.map((e) => e.id));
62
- } catch {
63
- e.error(y.verdictFailedToast);
64
- } finally {
65
- E(void 0);
66
- }
67
- }, P = x.groups.map((e) => {
68
- let t = e.bills.map((e) => e.id), r = M(e), i = {
69
- vendorLabel: e.vendorLabel,
70
- count: e.bills.length
71
- };
72
- return {
73
- id: e.id,
74
- titleLabel: e.vendorLabel,
75
- countLabel: String(e.bills.length),
76
- accessibleLabel: y.reviewGroup(i),
77
- selectAllLabel: y.selectGroup(i),
78
- selectAllChecked: C.checkedState(t),
79
- onToggleAllRows: () => C.toggleAll(t),
80
- rows: e.bills.map((e) => ({
81
- id: e.id,
82
- status: e.status,
83
- statusTone: e.statusTone,
84
- removalOutcome: e.removeBy === "delete" || e.removeBy === "cancel" ? e.removeBy : void 0,
85
- invoiceNumberLabel: e.invoiceNumberLabel,
86
- amountLabel: e.amountLabel,
87
- dueDateLabel: e.dueDateLabel,
88
- addedOnLabel: e.addedOnLabel,
89
- selectLabel: y.selectRow(e),
90
- openLabel: y.openRow(e),
91
- isSelected: C.isSelected(e.id),
92
- onToggleSelected: () => C.toggle(e.id),
93
- onOpen: () => g?.(e.id)
94
- })),
95
- onKeepSelected: h ? () => void N(e, n.Keep, "keep", y.dismissedToast) : void 0,
96
- onRemoveDuplicates: h ? () => void N(e, n.Remove, "remove", y.removedToast) : void 0,
97
- isActionDisabled: r.length === 0,
98
- isRemoveUnavailable: r.some((e) => !e.removeBy),
99
- pendingAction: T?.groupId === e.id ? T.action : void 0
100
- };
101
- });
102
- return /* @__PURE__ */ u(o, {
103
- open: f,
104
- onOpenChange: p,
105
- groups: P,
106
- isLoading: x.isLoading,
107
- isError: x.isError,
108
- expandedGroupId: j,
109
- onExpandedGroupChange: (e) => A({
110
- id: e,
111
- index: x.groups.findIndex((t) => t.id === e)
112
- }),
113
- isBusy: !!T,
114
- labels: v
115
- });
34
+ m,
35
+ g,
36
+ b
37
+ ]), S = b === "delete" ? {
38
+ button: p.deleteBillButton,
39
+ title: p.deleteConfirmTitle,
40
+ description: p.deleteConfirmDescription,
41
+ confirmButton: p.deleteConfirmButton,
42
+ backButton: p.deleteConfirmBackButton,
43
+ toast: p.deletedToast
44
+ } : b === "confirm" ? {
45
+ button: p.confirmBillButton,
46
+ title: p.cancelConfirmTitle,
47
+ description: p.cancelConfirmDescription,
48
+ confirmButton: p.confirmBillButton,
49
+ backButton: p.cancelConfirmBackButton,
50
+ toast: p.confirmedToast
51
+ } : {
52
+ button: p.cancelBillButton,
53
+ title: p.cancelConfirmTitle,
54
+ description: p.cancelConfirmDescription,
55
+ confirmButton: p.cancelConfirmButton,
56
+ backButton: p.cancelConfirmBackButton,
57
+ toast: p.cancelledToast
58
+ }, C = o(async () => {
59
+ await x(n.Remove, S.toast, d), y(!1);
60
+ }, [
61
+ x,
62
+ d,
63
+ S.toast
64
+ ]), w = u && !!(h && g), T = w && !!b;
65
+ return {
66
+ isPossibleDuplicate: !!h,
67
+ onNotADuplicate: w ? () => void x(n.Keep, p.dismissedToast) : void 0,
68
+ onRemoveBill: T ? b === "delete" ? () => y(!0) : () => void C() : void 0,
69
+ removeBillLabel: T ? S.button : void 0,
70
+ removeConfirmation: {
71
+ open: v,
72
+ copy: {
73
+ title: S.title,
74
+ description: S.description,
75
+ confirmButton: S.confirmButton,
76
+ presentation: { tone: "destructive" }
77
+ },
78
+ onConfirm: () => void C(),
79
+ onCancel: () => y(!1),
80
+ isPending: _.isPending,
81
+ cancelButtonLabel: S.backButton
82
+ },
83
+ isBusy: _.isPending
84
+ };
116
85
  }
117
86
  //#endregion
118
- export { f as DuplicateBillsContainer, f as default };
87
+ export { l as usePayableDuplicateReview };