@tesouro/embedded-components-react 0.4.28 → 0.4.29

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 (92) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/lib/BillPayWidget.js +1 -1
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +2 -2
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index16.js +15 -82
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index17.js +87 -25
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index18.js +36 -0
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +12 -12
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +5 -70
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +64 -37
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +38 -110
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +104 -73
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +87 -7
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +7 -21
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +17 -22
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +23 -63
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +66 -2
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +2 -77
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +78 -3
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +4 -5
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +5 -4
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +3 -32
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +30 -39
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +37 -166
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +164 -39
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +48 -1
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +1 -50
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +45 -11
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +13 -8
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +8 -14
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +7 -59
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +64 -8
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +8 -24
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +18 -136
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +139 -16
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +24 -4
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +4 -41
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +39 -88
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +79 -85
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +96 -3
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +3 -49
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +47 -119
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +135 -33
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +33 -186
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +186 -75
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +75 -21
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +22 -232
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +223 -210
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +14 -25
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +202 -103
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +121 -13
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +12 -47
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +47 -31
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +27 -198
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +198 -30
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +30 -234
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +240 -19
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +19 -425
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +433 -4
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +25 -24
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +4 -38
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +35 -218
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +224 -3
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +3 -4
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +2 -44
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +46 -1
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +1 -8
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +6 -10
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +10 -110
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +112 -3
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +21 -57
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +3 -127
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +124 -8
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +8 -7
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -46
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +43 -18
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +20 -28
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +27 -82
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +83 -47
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +47 -250
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +239 -101
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +58 -5
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +107 -202
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +209 -3
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +4 -8
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +6 -113
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +115 -1
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +0 -24
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +25 -0
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +5 -4
  90. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  91. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  92. package/package.json +1 -1
@@ -1,2 +1,66 @@
1
- import "./index15.js";
2
- import "./index17.js";
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 { formatCalendarDate as t } from "../../../shared/util/dist/lib/formatCalendarDate.js";
8
+ import { formatMoneyExact as n } from "../../../shared/util/dist/lib/formatMoneyExact.js";
9
+ import { extractApiErrorMessage as r } from "../../../shared/util/dist/lib/apiErrors.js";
10
+ import { useMarkPayableAsPaidMutation as i } from "../../data-access/dist/index13.js";
11
+ import "../../data-access/dist/index.js";
12
+ import { dateToCalendarKey as a, getDefaultPaymentDate as o, isTodayInEastern as s } from "./index17.js";
13
+ import { mergeMarkAsPaidFlowLabels as c } from "./index16.js";
14
+ import { useEffect as l, useState as u } from "react";
15
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js
16
+ function d({ payableId: d, amountDueMinorUnits: f, amountToPayMinorUnits: p, currencyCode: m, dueDate: h, hasScheduledPayment: g, testId: _, labels: v }) {
17
+ let y = c(v), b = i(), [x, S] = u(!1), [C, w] = u(void 0), [T, E] = u(""), D = x && !g, O = n(f / 100, { currencyCode: m }), k = n((p ?? f) / 100, { currencyCode: m }), A = C ? t(a(C)) : void 0, j = h ? y.dueDateSuffix(t(h)) : void 0, M = () => {
18
+ S(!1), w(void 0), E("");
19
+ };
20
+ return l(() => {
21
+ g && (S(!1), w(void 0), E(""));
22
+ }, [g]), {
23
+ open: () => {
24
+ w(o()), E(""), S(!0);
25
+ },
26
+ isPending: b.isPending,
27
+ dialogProps: {
28
+ open: D,
29
+ amountDue: O,
30
+ dueDateSuffix: j,
31
+ paymentAmount: k,
32
+ selectedDate: C,
33
+ selectedDateLabel: A,
34
+ isToday: C ? s(C) : !1,
35
+ comment: T,
36
+ isSubmitting: b.isPending,
37
+ onDateChange: w,
38
+ onCommentChange: E,
39
+ onConfirm: () => {
40
+ !d || !C || b.isPending || g || b.mutate({
41
+ path: { payable_id: d },
42
+ body: {
43
+ paid_at: `${a(C)}T12:00:00.000Z`,
44
+ is_external: !0,
45
+ ...T.trim() ? { comment: T.trim() } : {}
46
+ }
47
+ }, {
48
+ onSuccess: () => {
49
+ e.success(y.paidToast), M();
50
+ },
51
+ onError: (t) => {
52
+ e.error(r(t) ?? y.submitError);
53
+ }
54
+ });
55
+ },
56
+ onCancel: () => {
57
+ b.isPending || M();
58
+ },
59
+ testId: _ ? `${_}-mark-as-paid-dialog` : void 0,
60
+ confirmTestId: _ ? `${_}-mark-as-paid-confirm` : void 0,
61
+ labels: y.dialog
62
+ }
63
+ };
64
+ }
65
+ //#endregion
66
+ export { d as useMarkAsPaidFlow };
@@ -1,77 +1,2 @@
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";
5
- //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js
6
- function s(n) {
7
- return e(n, [t.CounterpartReadOrg]);
8
- }
9
- function c({ status: n, scopes: r, hasWaitingRequest: i, arePendingApproversUnknown: a }) {
10
- let o = e(r, [t.PayableApproveOrg]);
11
- return !!(n === "approve_in_progress" && i && o && !a);
12
- }
13
- function l({ status: l, scopes: u, canDecideApprovalRequest: d, hasScheduledPayment: f, scheduledPaymentIntentId: p, hasWaitingRequest: m, arePendingApproversUnknown: h, isPayabilityUnknown: g, labels: _ }) {
14
- let v = e(u, [t.PayablePayOrg]), y = e(u, [t.BankAccountReadOrg]), b = s(u), x = e(u, [t.PaymentRailAch]), S = e(u, [t.PayableWriteOrg]), C = v, w = [];
15
- l === "approve_in_progress" && d && (w.push({
16
- id: "approve",
17
- label: _.approve,
18
- variant: "default",
19
- surface: "row"
20
- }), w.push({
21
- id: "reject",
22
- label: _.reject,
23
- variant: "ghost",
24
- surface: "row"
25
- })), c({
26
- status: l,
27
- scopes: u,
28
- hasWaitingRequest: m,
29
- arePendingApproversUnknown: h
30
- }) && (w.push({
31
- id: "forceApprove",
32
- label: _.forceApprove,
33
- variant: "ghost",
34
- surface: "menu",
35
- icon: o,
36
- sectionHeading: _.policyOverridesHeading
37
- }), w.push({
38
- id: "forceReject",
39
- label: _.forceReject,
40
- variant: "ghost",
41
- surface: "menu",
42
- icon: a,
43
- sectionHeading: _.policyOverridesHeading
44
- }));
45
- let T = l === "waiting_to_be_paid" && v && !f, E = l === "waiting_to_be_paid" && v && y && b && x && !f && !g;
46
- return T && w.push({
47
- id: "markAsPaid",
48
- label: _.markAsPaid,
49
- variant: "outline",
50
- surface: "row"
51
- }), E && w.push({
52
- id: "payBill",
53
- label: _.payBill,
54
- variant: "default",
55
- surface: "row"
56
- }), l === "new" && S && w.push({
57
- id: "cancel",
58
- label: _.cancel,
59
- variant: "ghost",
60
- surface: "menu",
61
- icon: n
62
- }), (l === "rejected" || l === "waiting_to_be_paid" && !f) && S && w.push({
63
- id: "reopen",
64
- label: _.reopen,
65
- variant: "ghost",
66
- surface: "menu",
67
- icon: i
68
- }), l === "waiting_to_be_paid" && f && p && C && w.push({
69
- id: "cancelScheduledPayment",
70
- label: _.cancelScheduledPayment,
71
- variant: "ghost",
72
- surface: "menu",
73
- icon: r
74
- }), w;
75
- }
76
- //#endregion
77
- export { c as canOverrideApprovalPolicy, s as canReadCounterpartBankAccounts, l as getBillDetailActions };
1
+ import "./index16.js";
2
+ import "./index18.js";
@@ -1,6 +1,81 @@
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
5
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js
2
- function e(e) {
3
- return e?.amount_due ?? e?.total_amount ?? void 0;
6
+ function s(n) {
7
+ return e(n, [t.CounterpartReadOrg]);
8
+ }
9
+ function c({ status: n, scopes: r, arePendingApproversUnknown: i, hasApprovalPolicy: a = !0, hasWaitingRequest: o }) {
10
+ let s = e(r, [t.PayableApproveOrg]);
11
+ return !!(n === "approve_in_progress" && s && !i && (!a || o));
12
+ }
13
+ function l({ status: l, scopes: u, canDecideApprovalRequest: d, hasScheduledPayment: f, scheduledPaymentIntentId: p, arePendingApproversUnknown: m, hasApprovalPolicy: h, hasWaitingRequest: g, isPayabilityUnknown: _, labels: v }) {
14
+ let y = e(u, [t.PayablePayOrg]), b = e(u, [t.BankAccountReadOrg]), x = s(u), S = e(u, [t.PaymentRailAch]), C = e(u, [t.PayableWriteOrg]), w = y, T = [];
15
+ if (l === "approve_in_progress" && d && (T.push({
16
+ id: "approve",
17
+ label: v.approve,
18
+ variant: "default",
19
+ surface: "row"
20
+ }), T.push({
21
+ id: "reject",
22
+ label: v.reject,
23
+ variant: "ghost",
24
+ surface: "row"
25
+ })), c({
26
+ status: l,
27
+ scopes: u,
28
+ arePendingApproversUnknown: m,
29
+ hasApprovalPolicy: h,
30
+ hasWaitingRequest: g
31
+ })) {
32
+ let e = h === !1 ? void 0 : v.policyOverridesHeading;
33
+ T.push({
34
+ id: "forceApprove",
35
+ label: v.forceApprove,
36
+ variant: "ghost",
37
+ surface: "menu",
38
+ icon: o,
39
+ sectionHeading: e
40
+ }), T.push({
41
+ id: "forceReject",
42
+ label: v.forceReject,
43
+ variant: "ghost",
44
+ surface: "menu",
45
+ icon: a,
46
+ sectionHeading: e
47
+ });
48
+ }
49
+ let E = l === "waiting_to_be_paid" && y && !f, D = l === "waiting_to_be_paid" && y && b && x && S && !f && !_;
50
+ return E && T.push({
51
+ id: "markAsPaid",
52
+ label: v.markAsPaid,
53
+ variant: "outline",
54
+ surface: "row"
55
+ }), D && T.push({
56
+ id: "payBill",
57
+ label: v.payBill,
58
+ variant: "default",
59
+ surface: "row"
60
+ }), l === "new" && C && T.push({
61
+ id: "cancel",
62
+ label: v.cancel,
63
+ variant: "ghost",
64
+ surface: "menu",
65
+ icon: n
66
+ }), (l === "rejected" || l === "waiting_to_be_paid" && !f) && C && T.push({
67
+ id: "reopen",
68
+ label: v.reopen,
69
+ variant: "ghost",
70
+ surface: "menu",
71
+ icon: i
72
+ }), l === "waiting_to_be_paid" && f && p && w && T.push({
73
+ id: "cancelScheduledPayment",
74
+ label: v.cancelScheduledPayment,
75
+ variant: "ghost",
76
+ surface: "menu",
77
+ icon: r
78
+ }), T;
4
79
  }
5
80
  //#endregion
6
- export { e as resolveAmountDueMinorUnits };
81
+ export { c as canOverrideApprovalPolicy, s as canReadCounterpartBankAccounts, l as getBillDetailActions };
@@ -1,7 +1,6 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js
2
- var e = {
3
- scheduleDialog: "pay-bill-schedule-dialog",
4
- reviewDialog: "pay-bill-review-dialog"
5
- };
2
+ function e(e) {
3
+ return e?.amount_due ?? e?.total_amount ?? void 0;
4
+ }
6
5
  //#endregion
7
- export { e as payBillFlowTestIds };
6
+ export { e as resolveAmountDueMinorUnits };
@@ -1,6 +1,7 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js
2
- function e(e) {
3
- return e ? `••••${e.slice(-4)}` : void 0;
4
- }
2
+ var e = {
3
+ scheduleDialog: "pay-bill-schedule-dialog",
4
+ reviewDialog: "pay-bill-review-dialog"
5
+ };
5
6
  //#endregion
6
- export { e as maskAccountNumber };
7
+ export { e as payBillFlowTestIds };
@@ -1,35 +1,6 @@
1
- import { coerceAmountValueToMinorUnits as e } from "../../../shared/util/dist/lib/coerceAmountValueToMinorUnits.js";
2
- import { formatMoneyExact as t } from "../../../shared/util/dist/lib/formatMoneyExact.js";
3
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js
4
- var n = {
5
- unnamedSourceAccount: "Bank account",
6
- availableBalancePrefix: (e) => `Available balance: ${e}`,
7
- futureInsufficientFunds: "Not enough funds right now. Add funds before the payment date.",
8
- todayInsufficientFunds: "Not enough funds to pay today. Choose a different account or a later date."
9
- };
10
- function r(e) {
11
- return e.slice(-4);
12
- }
13
- function i(i, a = n) {
14
- return i.filter((e) => e.status === "ACTIVE").map((n) => {
15
- let i = e(n.balance.value), o = n.balance.currencyCode;
16
- return {
17
- id: n.id,
18
- primaryLabel: `${n.nickname || a.unnamedSourceAccount} - ${r(n.accountNumber)}`,
19
- secondaryLabel: a.availableBalancePrefix(t(i / 100, { currencyCode: o })),
20
- balanceMinorUnits: i
21
- };
22
- });
23
- }
24
- function a({ selectedAccount: e, amountDueMinorUnits: t, isToday: r, labels: i = n }) {
25
- let a = e?.balanceMinorUnits;
26
- return a === void 0 ? { state: "warning" } : a >= t ? { state: "sufficient" } : r ? {
27
- state: "error",
28
- message: i.todayInsufficientFunds
29
- } : {
30
- state: "warning",
31
- message: i.futureInsufficientFunds
32
- };
2
+ function e(e) {
3
+ return e ? `••••${e.slice(-4)}` : void 0;
33
4
  }
34
5
  //#endregion
35
- export { n as SOURCE_ACCOUNT_LABELS_EN, a as deriveSourceAccountFunds, i as mapSourceAccountOptions };
6
+ export { e as maskAccountNumber };
@@ -1,44 +1,35 @@
1
- import { REVIEW_TRANSACTION_DIALOG_LABELS_EN as e } from "../../ui/dist/index92.js";
2
- import { SCHEDULE_PAYMENT_DIALOG_LABELS_EN as t } from "../../ui/dist/index98.js";
3
- import "../../ui/dist/index.js";
4
- import { SOURCE_ACCOUNT_LABELS_EN as n } from "./index23.js";
1
+ import { coerceAmountValueToMinorUnits as e } from "../../../shared/util/dist/lib/coerceAmountValueToMinorUnits.js";
2
+ import { formatMoneyExact as t } from "../../../shared/util/dist/lib/formatMoneyExact.js";
5
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js
6
- var r = {
7
- amountDue: "Amount due",
8
- paymentAmount: "Payment amount",
9
- dueDateSuffix: (e) => `by ${e}`,
10
- paymentDate: "Payment date",
11
- sourceAccount: "Pay from",
12
- accountHolder: "Account holder name",
13
- routingNumber: "Routing number",
14
- accountNumber: "Account number",
15
- achMethod: "Pay by ACH bank transfer",
16
- scheduledToast: "Payment scheduled",
17
- submitError: "Couldn't schedule this payment. Try again.",
18
- selectAccountError: "Select a source account.",
19
- selectDateError: "Select a payment date.",
20
- staleDateError: "That date has passed. Choose a new payment date.",
21
- missingPaymentInstructionsError: "This vendor does not have ACH payment instructions on file.",
22
- checkingPaymentInstructionsError: "Still checking this vendor's payment instructions. Try again in a moment.",
23
- paymentInstructionsUnavailableError: "Couldn't check this vendor's payment instructions. Try again.",
24
- missingVendorName: "Not provided",
25
- ...n,
26
- scheduleDialog: t,
27
- reviewDialog: e
4
+ var n = {
5
+ unnamedSourceAccount: "Bank account",
6
+ availableBalancePrefix: (e) => `Available balance: ${e}`,
7
+ futureInsufficientFunds: "Not enough funds right now. Add funds before the payment date.",
8
+ todayInsufficientFunds: "Not enough funds to pay today. Choose a different account or a later date."
28
9
  };
29
- function i(e) {
30
- return {
31
- ...r,
32
- ...e,
33
- scheduleDialog: {
34
- ...r.scheduleDialog,
35
- ...e?.scheduleDialog
36
- },
37
- reviewDialog: {
38
- ...r.reviewDialog,
39
- ...e?.reviewDialog
40
- }
10
+ function r(e) {
11
+ return e.slice(-4);
12
+ }
13
+ function i(i, a = n) {
14
+ return i.filter((e) => e.status === "ACTIVE").map((n) => {
15
+ let i = e(n.balance.value), o = n.balance.currencyCode;
16
+ return {
17
+ id: n.id,
18
+ primaryLabel: `${n.nickname || a.unnamedSourceAccount} - ${r(n.accountNumber)}`,
19
+ secondaryLabel: a.availableBalancePrefix(t(i / 100, { currencyCode: o })),
20
+ balanceMinorUnits: i
21
+ };
22
+ });
23
+ }
24
+ function a({ selectedAccount: e, amountDueMinorUnits: t, isToday: r, labels: i = n }) {
25
+ let a = e?.balanceMinorUnits;
26
+ return a === void 0 ? { state: "warning" } : a >= t ? { state: "sufficient" } : r ? {
27
+ state: "error",
28
+ message: i.todayInsufficientFunds
29
+ } : {
30
+ state: "warning",
31
+ message: i.futureInsufficientFunds
41
32
  };
42
33
  }
43
34
  //#endregion
44
- export { r as PAY_BILL_FLOW_LABELS_EN, i as mergePayBillFlowLabels };
35
+ export { n as SOURCE_ACCOUNT_LABELS_EN, a as deriveSourceAccountFunds, i as mapSourceAccountOptions };
@@ -1,173 +1,44 @@
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 { useAllBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
7
- import "../../../shared/data-access/dist/index.js";
8
- import "../../../shared/ui/dist/index.js";
9
- import { useAnalyticsCaptureException as n } from "../../../shared/feature/dist/lib/analytics/hooks.js";
10
- import { formatCalendarDate as r } from "../../../shared/util/dist/lib/formatCalendarDate.js";
11
- import { formatMoneyExact as i } from "../../../shared/util/dist/lib/formatMoneyExact.js";
12
- import { extractApiErrorMessage as a } from "../../../shared/util/dist/lib/apiErrors.js";
13
- import "../../../shared/feature/dist/index.js";
14
- import { useSchedulePaymentMutation as o } from "../../data-access/dist/index12.js";
15
- import "../../data-access/dist/index.js";
16
- import { dateToCalendarKey as s, getDefaultPaymentDate as c, isPastEasternDate as l, isTodayInEastern as u } from "./index16.js";
17
- import { maskAccountNumber as d } from "./index22.js";
18
- import { deriveSourceAccountFunds as f, mapSourceAccountOptions as p } from "./index23.js";
19
- import { mergePayBillFlowLabels as m } from "./index24.js";
20
- import { useMemo as h, useState as g } from "react";
1
+ import { REVIEW_TRANSACTION_DIALOG_LABELS_EN as e } from "../../ui/dist/index92.js";
2
+ import { SCHEDULE_PAYMENT_DIALOG_LABELS_EN as t } from "../../ui/dist/index98.js";
3
+ import "../../ui/dist/index.js";
4
+ import { SOURCE_ACCOUNT_LABELS_EN as n } from "./index24.js";
21
5
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js
22
- function _(e) {
23
- return !!(e?.account_holder_name && e.routing_number && e.account_number);
24
- }
25
- function v({ selectedDate: e, selectedAccount: t, amountDueMinorUnits: n, labels: r }) {
26
- if (!e) return {
27
- ok: !1,
28
- error: r.selectDateError
29
- };
30
- if (l(e)) return {
31
- ok: !1,
32
- error: r.staleDateError
33
- };
34
- if (!t) return {
35
- ok: !1,
36
- error: r.selectAccountError
37
- };
38
- let i = f({
39
- selectedAccount: t,
40
- amountDueMinorUnits: n,
41
- isToday: u(e),
42
- labels: r
43
- });
44
- return i.state === "error" ? {
45
- ok: !1,
46
- error: i.message ?? r.todayInsufficientFunds
47
- } : {
48
- ok: !0,
49
- date: e,
50
- account: t
51
- };
52
- }
53
- function y({ payableId: l, amountDueMinorUnits: y, currencyCode: b = "USD", dueDate: x, vendorName: S, vendorEmail: C, vendorBankAccount: w, isVendorBankAccountLoading: T, isVendorBankAccountError: E, onMissingAchInstructions: D, poweredByBankName: O, labels: k }) {
54
- let A = h(() => m(k), [k]), j = S ?? A.missingVendorName, [M, N] = g(!1), [P, F] = g(!1), [I, L] = g(() => c()), [R, z] = g(), B = t({ enabled: M || P }), V = o(), H = n(), U = h(() => p(B.data?.data ?? [], A), [B.data?.data, A]), W = U.find((e) => e.id === R), G = I ? u(I) : !1, K = { before: c() }, q = f({
55
- selectedAccount: W,
56
- amountDueMinorUnits: y,
57
- isToday: G,
58
- labels: A
59
- }), J = i(y / 100, { currencyCode: b }), Y = I ? r(s(I)) : void 0, X = x ? A.dueDateSuffix(r(x)) : void 0, Z = () => v({
60
- selectedDate: I,
61
- selectedAccount: W,
62
- amountDueMinorUnits: y,
63
- labels: A
64
- }), Q = () => {
65
- if (T) {
66
- e.error(A.checkingPaymentInstructionsError);
67
- return;
68
- }
69
- if (E) {
70
- e.error(A.paymentInstructionsUnavailableError);
71
- return;
72
- }
73
- if (!_(w)) {
74
- D ? D() : e.error(A.missingPaymentInstructionsError);
75
- return;
76
- }
77
- N(!0);
78
- }, $ = () => {
79
- F(!1), N(!1);
80
- };
6
+ var r = {
7
+ amountDue: "Amount due",
8
+ paymentAmount: "Payment amount",
9
+ dueDateSuffix: (e) => `by ${e}`,
10
+ paymentDate: "Payment date",
11
+ sourceAccount: "Pay from",
12
+ accountHolder: "Account holder name",
13
+ routingNumber: "Routing number",
14
+ accountNumber: "Account number",
15
+ achMethod: "Pay by ACH bank transfer",
16
+ scheduledToast: "Payment scheduled",
17
+ submitError: "Couldn't schedule this payment. Try again.",
18
+ selectAccountError: "Select a source account.",
19
+ selectDateError: "Select a payment date.",
20
+ staleDateError: "That date has passed. Choose a new payment date.",
21
+ missingPaymentInstructionsError: "This vendor does not have ACH payment instructions on file.",
22
+ checkingPaymentInstructionsError: "Still checking this vendor's payment instructions. Try again in a moment.",
23
+ paymentInstructionsUnavailableError: "Couldn't check this vendor's payment instructions. Try again.",
24
+ missingVendorName: "Not provided",
25
+ ...n,
26
+ scheduleDialog: t,
27
+ reviewDialog: e
28
+ };
29
+ function i(e) {
81
30
  return {
82
- open: Q,
83
- dialogProps: {
84
- open: M,
85
- onOpenChange: N,
86
- amountDueLabel: A.amountDue,
87
- amountDue: J,
88
- dueDateSuffix: X,
89
- paymentAmountLabel: A.paymentAmount,
90
- paymentAmount: J,
91
- selectedDate: I,
92
- selectedDateLabel: Y,
93
- calendarDisabled: K,
94
- isToday: G,
95
- selectedAccountId: R,
96
- accounts: U,
97
- poweredByBankName: O,
98
- funds: q,
99
- isAccountsLoading: B.isLoading,
100
- isAccountsError: B.isError,
101
- isSubmitting: V.isPending,
102
- onDateChange: L,
103
- onAccountChange: z,
104
- onReview: () => {
105
- let t = Z();
106
- if (!t.ok) {
107
- e.error(t.error);
108
- return;
109
- }
110
- N(!1), F(!0);
111
- },
112
- onCancel: $,
113
- labels: A.scheduleDialog
31
+ ...r,
32
+ ...e,
33
+ scheduleDialog: {
34
+ ...r.scheduleDialog,
35
+ ...e?.scheduleDialog
114
36
  },
115
- reviewProps: {
116
- open: P,
117
- onOpenChange: F,
118
- amountLabel: A.paymentAmount,
119
- amount: J,
120
- rows: [{
121
- label: A.sourceAccount,
122
- value: W?.primaryLabel ?? ""
123
- }, {
124
- label: A.paymentDate,
125
- value: Y ?? ""
126
- }],
127
- payTo: {
128
- name: j,
129
- email: C,
130
- methodLabel: A.achMethod,
131
- fields: _(w) ? [
132
- {
133
- label: A.routingNumber,
134
- value: w.routing_number
135
- },
136
- {
137
- label: A.accountNumber,
138
- value: w.account_number,
139
- maskedValue: d(w.account_number)
140
- },
141
- {
142
- label: A.accountHolder,
143
- value: w.account_holder_name
144
- }
145
- ] : []
146
- },
147
- isSubmitting: V.isPending,
148
- onBack: () => {
149
- F(!1), N(!0);
150
- },
151
- onCancel: $,
152
- onSubmit: async () => {
153
- let t = Z();
154
- if (!t.ok) {
155
- F(!1), e.error(t.error), N(!0);
156
- return;
157
- }
158
- try {
159
- await V.mutateAsync({
160
- payableId: l,
161
- paymentDate: s(t.date),
162
- sourceBankAccountId: t.account.id
163
- }), $(), e.success(A.scheduledToast);
164
- } catch (t) {
165
- H(t, { payable_id: l }), e.error(a(t) ?? A.submitError);
166
- }
167
- },
168
- labels: A.reviewDialog
37
+ reviewDialog: {
38
+ ...r.reviewDialog,
39
+ ...e?.reviewDialog
169
40
  }
170
41
  };
171
42
  }
172
43
  //#endregion
173
- export { y as usePayBillFlow };
44
+ export { r as PAY_BILL_FLOW_LABELS_EN, i as mergePayBillFlowLabels };