@tesouro/embedded-components-react 0.5.303 → 0.5.305

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 (52) hide show
  1. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index.js +9 -9
  2. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index12.js +7 -7
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +10 -9
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +8 -7
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +7 -8
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +8 -28
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +24 -157
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +20 -13
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +13 -34
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +153 -89
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +17 -83
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +23 -3
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +42 -55
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +93 -107
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +77 -185
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +3 -80
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +55 -72
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +111 -113
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +184 -463
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index3.js +14 -4
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +78 -11
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +61 -74
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +115 -80
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +449 -216
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +116 -42
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +11 -249
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +85 -23
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +80 -648
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +240 -4
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +44 -40
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +38 -15
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +242 -240
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +25 -3
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +538 -3
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +3 -66
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +42 -1
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js +239 -0
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index46.js +3 -0
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js +5 -0
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js +67 -0
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index49.js +1 -0
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index5.js +227 -38
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index6.js +82 -224
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index7.js +45 -82
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index8.js +4 -47
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index9.js +1 -1
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index.js +2 -2
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index29.js +1 -1
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +2 -2
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/BillsTab.js +6 -6
  51. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  52. package/package.json +1 -1
@@ -0,0 +1,239 @@
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 { useAllLedgerAccountsQuery as ee } from "../../../../shared/data-access/dist/lib/reference-data/useLedgerAccountsQuery.js";
8
+ import "../../../../shared/data-access/dist/index.js";
9
+ import { useWidgetConfig as te } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useOrganizationUserNames as n } from "../../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
11
+ import "../../../../shared/feature/dist/index.js";
12
+ import { mergeDecisionDialogCopy as r, mergePaymentHistoryMethodLabels as i } from "../../../util/dist/lib/billDetailLabels.js";
13
+ import { hasSuspectedPayableDuplicate as a } from "../../../util/dist/lib/payableDuplicates.js";
14
+ import { mapPayableToBillDetails as o } from "./index24.js";
15
+ import { BillDecisionDialog as s } from "../../../ui/dist/index4.js";
16
+ import "../../../ui/dist/index.js";
17
+ import { BillDetailsSheet as c } from "../../ui/dist/index34.js";
18
+ import { BillDuplicateNotice as l } from "../../ui/dist/index37.js";
19
+ import "../../ui/dist/index.js";
20
+ import { useAllPayableLineItemsQuery as u } from "../../data-access/dist/index4.js";
21
+ import { usePayableQuery as d } from "../../data-access/dist/index21.js";
22
+ import "../../data-access/dist/index.js";
23
+ import { buildPaymentHistory as f } from "./index2.js";
24
+ import { canOverrideApprovalPolicy as p, canReadCounterpartBankAccounts as m } from "./index6.js";
25
+ import { useApprovalPolicyCardView as h } from "./index12.js";
26
+ import { resolveApprovalNotices as g } from "./index14.js";
27
+ import { useBillRejectionNotice as ne } from "./index17.js";
28
+ import { useCurrentApprovalRequestId as re } from "./index18.js";
29
+ import { usePayableAuditHistory as ie } from "./index19.js";
30
+ import { usePayableDetailActions as ae } from "./index20.js";
31
+ import { useScheduledDateLabel as oe } from "./index21.js";
32
+ import { useScheduledPayment as se } from "./index22.js";
33
+ import { usePayableAchInstructions as ce } from "../../../../shared/counterpart-management/feature/dist/lib/usePayableAchInstructions.js";
34
+ import "../../../../shared/counterpart-management/feature/dist/index.js";
35
+ import { BILL_DETAILS_LABELS_EN as _ } from "./index44.js";
36
+ import { useMemo as v, useRef as le, useState as ue } from "react";
37
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
38
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js
39
+ function S({ open: S, onOpenChange: C, payableId: w, onClose: T, onExpand: E, onEdit: D, testId: O, labels: k, renderPaymentFlows: A }) {
40
+ let j = v(() => ({
41
+ ..._,
42
+ ...k,
43
+ sheet: {
44
+ ..._.sheet,
45
+ ...k?.sheet,
46
+ statusBadge: {
47
+ ..._.sheet.statusBadge,
48
+ ...k?.sheet?.statusBadge
49
+ },
50
+ approvalPolicy: {
51
+ ..._.sheet.approvalPolicy,
52
+ ...k?.sheet?.approvalPolicy
53
+ },
54
+ dueDate: {
55
+ ..._.sheet.dueDate,
56
+ ...k?.sheet?.dueDate
57
+ },
58
+ auditHistory: {
59
+ ..._.sheet.auditHistory,
60
+ ...k?.sheet?.auditHistory
61
+ }
62
+ },
63
+ decisionDialog: r(_.decisionDialog, k?.decisionDialog),
64
+ approvalPolicyCopy: {
65
+ ..._.approvalPolicyCopy,
66
+ ...k?.approvalPolicyCopy
67
+ },
68
+ history: {
69
+ ..._.history,
70
+ ...k?.history
71
+ },
72
+ scheduledRelativeDay: {
73
+ ..._.scheduledRelativeDay,
74
+ ...k?.scheduledRelativeDay
75
+ },
76
+ actionSuccess: {
77
+ ..._.actionSuccess,
78
+ ...k?.actionSuccess
79
+ },
80
+ paymentHistoryMethodLabels: i(k?.paymentHistoryMethodLabels)
81
+ }), [k]), M = d(w), N = u(w), P = ee(), { initResponse: F } = te(), I = M.data, L = le(null), [R, z] = ue(!1), B = re({
82
+ payableId: w,
83
+ status: I?.status
84
+ }), V = I?.status === "rejected", H = e(F?.scopes, [t.ApprovalRequestReadOrg]), de = V && H, U = e(F?.scopes, [t.UserReadOrg]), { userNames: W, isError: fe, isResolving: pe } = n({ enabled: U }), G = ne({
85
+ payableId: w,
86
+ payableStatus: I?.status,
87
+ payableUpdatedAt: I?.updated_at,
88
+ enabled: de,
89
+ userNames: W,
90
+ labels: j
91
+ }), K = h({
92
+ payableId: w,
93
+ approvalPolicyId: I?.approval_policy_id,
94
+ copy: j.approvalPolicyCopy
95
+ }), me = p({
96
+ status: I?.status,
97
+ scopes: F?.scopes,
98
+ arePendingApproversUnknown: K.isLoading,
99
+ hasApprovalPolicy: !!I?.approval_policy_id,
100
+ hasWaitingRequest: B.hasWaitingRequest
101
+ }), q = g({
102
+ isCapabilityUnknown: B.isLoading || K.isLoading,
103
+ canApproveNow: !!B.id,
104
+ canOverridePolicy: me,
105
+ status: I?.status,
106
+ hasApprovalPolicy: !!I?.approval_policy_id,
107
+ pendingApproverNames: K.pendingApprovers.flatMap((e) => e.names),
108
+ labels: j
109
+ }), J = se({
110
+ payableId: w,
111
+ scheduledPaymentDate: I?.scheduled_payment_date
112
+ }), Y = m(F?.scopes), X = ce({
113
+ counterpartId: I?.counterpart_id,
114
+ currency: I?.currency,
115
+ currentBankAccountId: I?.counterpart_bank_account_id,
116
+ enabled: Y
117
+ }), { actions: he, decisionDialog: ge } = ae({
118
+ payableId: I ? w : void 0,
119
+ status: I?.status,
120
+ currentApprovalRequestId: B.id,
121
+ hasScheduledPayment: J.hasScheduledPayment,
122
+ scheduledPaymentIntentId: J.scheduledPaymentIntentId,
123
+ isScheduledPaymentUnknown: J.isResolving,
124
+ isPayabilityUnknown: X.isLoading,
125
+ hasApprovalPolicy: !!I?.approval_policy_id,
126
+ hasWaitingRequest: B.hasWaitingRequest,
127
+ pendingApprovers: K.pendingApprovers,
128
+ arePendingApproversUnknown: K.isLoading,
129
+ labels: {
130
+ edit: j.sheet.editButton,
131
+ payBill: j.sheet.payButton,
132
+ markAsPaid: j.sheet.markAsPaidButton,
133
+ reject: j.sheet.rejectButton,
134
+ approve: j.sheet.approveButton,
135
+ cancel: j.sheet.cancelButton,
136
+ cancelScheduledPayment: j.sheet.cancelScheduledPaymentButton,
137
+ reopen: j.sheet.reopenButton,
138
+ forceApprove: j.sheet.forceApproveButton,
139
+ forceReject: j.sheet.forceRejectButton,
140
+ policyOverridesHeading: j.sheet.policyOverridesGroup,
141
+ decisionDialog: j.decisionDialog,
142
+ actionError: j.actionError,
143
+ actionSuccess: j.actionSuccess
144
+ },
145
+ isMarkAsPaidPending: R,
146
+ onMarkAsPaidSelect: () => L.current?.openMarkAsPaid(),
147
+ onPayBillSelect: () => L.current?.openPayBill(),
148
+ onEditSelect: D,
149
+ onActionSucceeded: (e) => {
150
+ e === "reopen" && D?.();
151
+ }
152
+ }), Z = oe({
153
+ hasScheduledPayment: J.hasScheduledPayment,
154
+ scheduledDate: J.scheduledDate,
155
+ labels: j.scheduledRelativeDay
156
+ }), _e = Z ? j.scheduledSummary(Z.label) : void 0, Q = a(I) ? /* @__PURE__ */ b(l, { onOpenFullScreen: E }) : void 0, { historyQuery: $, rows: ve, namesError: ye } = ie({
157
+ payableId: w,
158
+ userNames: W,
159
+ isRosterError: U && fe,
160
+ labels: j.history
161
+ }), be = v(() => f({
162
+ records: J.paymentRecords,
163
+ events: $.data?.data ?? [],
164
+ currencyCode: I?.currency,
165
+ labels: j
166
+ }), [
167
+ J.paymentRecords,
168
+ $.data,
169
+ I?.currency,
170
+ j
171
+ ]), xe = v(() => I ? o({
172
+ payable: I,
173
+ lineItems: N.lineItems,
174
+ ledgerAccounts: P.data?.data ?? [],
175
+ labels: j,
176
+ hasScheduledPayment: J.hasScheduledPayment,
177
+ rejection: G,
178
+ achInstructions: X.achInstructions,
179
+ achInstructionsReadable: Y && !X.isLoading && !X.isError
180
+ }) : void 0, [
181
+ I,
182
+ N.lineItems,
183
+ P.data,
184
+ j,
185
+ J.hasScheduledPayment,
186
+ G,
187
+ X.achInstructions,
188
+ X.isError,
189
+ X.isLoading,
190
+ Y
191
+ ]), Se = M.isLoading || N.isResolving || P.isResolving || X.isLoading, Ce = M.isError || N.isError || P.isError;
192
+ return /* @__PURE__ */ x(y, { children: [
193
+ /* @__PURE__ */ b(c, {
194
+ open: S,
195
+ onOpenChange: C,
196
+ details: xe,
197
+ actions: he,
198
+ approvalPolicy: K.view,
199
+ showApprovalOverrideNotice: q.showApprovalOverrideNotice,
200
+ awaitingApprovalNotice: q.awaitingApprovalNotice,
201
+ scheduledSummary: _e,
202
+ scheduledSummaryDate: Z?.absoluteLabel,
203
+ auditHistory: ve,
204
+ auditHistoryError: $.isError,
205
+ auditHistoryLoading: $.isLoading || pe,
206
+ auditHistoryNamesError: ye,
207
+ paymentHistory: be,
208
+ paymentHistoryError: J.isError || $.isError,
209
+ paymentHistoryLoading: J.isResolving || $.isLoading,
210
+ isLoading: Se,
211
+ isError: Ce,
212
+ notice: Q,
213
+ onClose: T,
214
+ onExpand: E,
215
+ testId: O,
216
+ labels: j.sheet
217
+ }),
218
+ /* @__PURE__ */ b(s, {
219
+ ...ge,
220
+ labels: { cancelButton: j.decisionDialog.cancelButton },
221
+ testId: O ? `${O}-decision-dialog` : void 0,
222
+ confirmTestId: O ? `${O}-decision-confirm` : void 0,
223
+ reasonTestId: O ? `${O}-decision-reason` : void 0,
224
+ reasonFieldId: O ? `${O}-decision-reason-field` : void 0
225
+ }),
226
+ A?.({
227
+ ref: L,
228
+ payable: I,
229
+ payableId: w,
230
+ isPayBillEnabled: !0,
231
+ hasScheduledPayment: J.hasScheduledPayment,
232
+ onMissingAchInstructions: E,
233
+ onMarkAsPaidPendingChange: z,
234
+ testId: O
235
+ })
236
+ ] });
237
+ }
238
+ //#endregion
239
+ export { S as BillDetailsContainer, S as default };
@@ -0,0 +1,3 @@
1
+ import "./index24.js";
2
+ import "./index44.js";
3
+ import "./index45.js";
@@ -0,0 +1,5 @@
1
+ import { BILL_PAY_WIDGET_NAME as e } from "../../../util/dist/lib/widgetName.js";
2
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js
3
+ var t = `${e}.bill_detail`, n = { Mounted: `${t}.mounted` };
4
+ //#endregion
5
+ export { n as BillDetailWidgetAnalyticsEvent, t as WIDGET_NAME };
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useAnalyticsTrack as e } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
6
+ import { WidgetProvider as t } from "../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
7
+ import "../../../../shared/feature/dist/index.js";
8
+ import { BillDialog as n } from "./index42.js";
9
+ import "./index43.js";
10
+ import { BillDetailsContainer as r } from "./index45.js";
11
+ import "./index46.js";
12
+ import { BillDetailWidgetAnalyticsEvent as i, WIDGET_NAME as a } from "./index47.js";
13
+ import { useEffect as o } from "react";
14
+ import { jsx as s } from "react/jsx-runtime";
15
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js
16
+ function c() {
17
+ let t = e();
18
+ o(() => {
19
+ t(i.Mounted);
20
+ }, [t]);
21
+ }
22
+ function l(e) {
23
+ return c(), /* @__PURE__ */ s(n, { ...e });
24
+ }
25
+ function u(e) {
26
+ return c(), /* @__PURE__ */ s(r, { ...e });
27
+ }
28
+ function d({ baseUrl: e, widgetToken: n, organizationId: r, configClient: i, gatewayRouting: o, linkComponent: c, implementation: u, uiFramework: d, errorFallback: f, onError: p, analytics: m, disclosuresAcceptance: h, providerLabels: g, ..._ }) {
29
+ return /* @__PURE__ */ s(t, {
30
+ widgetName: a,
31
+ baseUrl: e,
32
+ widgetToken: n,
33
+ organizationId: r,
34
+ configClient: i,
35
+ gatewayRouting: o,
36
+ linkComponent: c,
37
+ implementation: u,
38
+ uiFramework: d,
39
+ errorFallback: f,
40
+ onError: p,
41
+ analytics: m,
42
+ disclosuresAcceptance: h,
43
+ providerLabels: g,
44
+ children: /* @__PURE__ */ s(l, { ..._ })
45
+ });
46
+ }
47
+ function f({ baseUrl: e, widgetToken: n, organizationId: r, configClient: i, gatewayRouting: o, linkComponent: c, implementation: l, uiFramework: d, errorFallback: f, onError: p, analytics: m, disclosuresAcceptance: h, providerLabels: g, ..._ }) {
48
+ return /* @__PURE__ */ s(t, {
49
+ widgetName: a,
50
+ baseUrl: e,
51
+ widgetToken: n,
52
+ organizationId: r,
53
+ configClient: i,
54
+ gatewayRouting: o,
55
+ linkComponent: c,
56
+ implementation: l,
57
+ uiFramework: d,
58
+ errorFallback: f,
59
+ onError: p,
60
+ analytics: m,
61
+ disclosuresAcceptance: h,
62
+ providerLabels: g,
63
+ children: /* @__PURE__ */ s(u, { ..._ })
64
+ });
65
+ }
66
+ //#endregion
67
+ export { f as BillDetailsWidget, d as BillDialogWidget };
@@ -1,40 +1,229 @@
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 { formatCalendarDate as t } from "../../../../shared/util/dist/lib/formatCalendarDate.js";
7
+ import { formatMoneyExact as n } from "../../../../shared/util/dist/lib/formatMoneyExact.js";
8
+ import "../../../../shared/ui/dist/index.js";
9
+ import { derivePayableStatus as r } from "../../../util/dist/lib/derivePayableStatus.js";
10
+ import { DuplicateVerdict as i } from "../../../util/dist/lib/duplicateVerdict.js";
11
+ import { suspectedPayableDuplicates as a } from "../../../util/dist/lib/payableDuplicates.js";
12
+ import { duplicateVerdictMatches as o, groupSuspectedDuplicates as s, resolveDuplicateOriginalId as c } from "../../../util/dist/lib/groupDuplicates.js";
13
+ import { isEditablePayableStatus as l } from "../../../util/dist/lib/isEditablePayableStatus.js";
14
+ import { payableRemoval as u } from "../../../util/dist/lib/payableRemoval.js";
15
+ import { resolveVendorName as d } from "../../../util/dist/lib/resolveVendor.js";
16
+ import { useApplyDuplicateVerdictsMutation as f } from "../../../data-access/dist/lib/useApplyDuplicateVerdictsMutation.js";
17
+ import "../../../data-access/dist/index.js";
18
+ import { usePayablesByIdsQueries as p } from "../../data-access/dist/index22.js";
19
+ import "../../data-access/dist/index.js";
20
+ import { duplicateRemovalPrompt as m } from "./index3.js";
21
+ import { DUPLICATE_BILLS_LABELS_EN as h } from "./index4.js";
22
+ import { useCallback as g, useMemo as _, useState as v } from "react";
23
+ import { BanIcon as y, FileCheckIcon as b, Trash2Icon as x } from "lucide-react";
1
24
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index5.js
2
- var e = {
3
- selectRow: ({ vendorLabel: e, invoiceNumberLabel: t, addedOnLabel: n }) => `Select bill — ${e}, invoice ${t}, added ${n}`,
4
- openRow: ({ vendorLabel: e, invoiceNumberLabel: t, addedOnLabel: n }) => `View bill — ${e}, invoice ${t}, added ${n}`,
5
- reviewGroup: ({ vendorLabel: e, count: t }) => `${e} — ${t} possible duplicate bills`,
6
- selectGroup: ({ vendorLabel: e }) => `Select every bill from ${e}`,
7
- deleteBillButton: "Remove this bill",
8
- deleteConfirmTitle: "Remove duplicate bill?",
9
- deleteConfirmDescription: "You can't undo this action.",
10
- deleteConfirmButton: "Remove duplicate bill",
11
- deleteConfirmBackButton: "Cancel",
12
- cancelBillButton: "Cancel this bill",
13
- confirmBillButton: "Confirm duplicate",
14
- cancelConfirmTitle: "Cancel duplicate bill?",
15
- cancelConfirmDescription: "You can't undo this action.",
16
- cancelConfirmButton: "Cancel this bill",
17
- cancelConfirmBackButton: "Back",
18
- confirmDuplicateTitle: "Confirm duplicate?",
19
- confirmDuplicateDescription: "This bill is already cancelled. This records it as a duplicate.",
20
- notDuplicateAction: "Not a duplicate",
21
- notDuplicateConfirmTitle: "Mark as not a duplicate?",
22
- notDuplicateConfirmDescription: "You can't undo this action.",
23
- notDuplicateConfirmButton: "Not a duplicate",
24
- notDuplicateConfirmBackButton: "Back",
25
- deleteAction: "Remove bill",
26
- cancelAction: "Cancel bill",
27
- confirmAction: "Confirm duplicate",
28
- currentBillBadge: "This bill",
29
- originalBillBadge: "Original bill",
30
- showMoreRows: (e) => `Show ${e} more`,
31
- deletedToast: "Duplicate removed",
32
- cancelledToast: "Duplicate cancelled",
33
- confirmedToast: "Duplicate confirmed",
34
- dismissedToast: "Marked as “not a duplicate”.",
35
- removedToast: "Duplicate removed",
36
- verdictFailedToast: "Couldn't update this duplicate. Try again.",
37
- allResolvedToast: "All possible duplicates resolved"
38
- };
25
+ var S = 5;
26
+ function C(e, t) {
27
+ return t ? s(e).map(({ members: e }) => e).find((e) => e.some((e) => e.id === t)) ?? [] : [];
28
+ }
29
+ function w({ payable: s, canManage: w = !0, onRemoved: T, onOpenPayable: E, labels: D }) {
30
+ let O = _(() => ({
31
+ ...h,
32
+ ...D
33
+ }), [D]), k = a(s), [A] = k, j = s?.id, M = _(() => [...new Set(k.map((e) => e.matched_payable_id))], [k]), N = p(M, { enabled: !!(A && j) }), P = f(), [F, I] = v(!1), [L, R] = v(), [z, B] = v(), V = u(s?.status), H = g(async (t, n, r, i, a) => {
34
+ let s = o(t, n, a);
35
+ if (s.length && t?.id) try {
36
+ await P.mutateAsync({
37
+ verdict: n,
38
+ targets: s.map((e) => ({
39
+ payableId: t.id,
40
+ duplicateId: e.id,
41
+ matchedPayableId: e.matched_payable_id,
42
+ removeBy: u(t.status)
43
+ }))
44
+ }), e.success(r), i?.();
45
+ } catch {
46
+ e.error(O.verdictFailedToast);
47
+ }
48
+ }, [P, O]), U = g((e, t, n) => H(s, e, t, n), [H, s]), W = V === "delete" ? {
49
+ button: O.deleteBillButton,
50
+ title: O.deleteConfirmTitle,
51
+ description: O.deleteConfirmDescription,
52
+ confirmButton: O.deleteConfirmButton,
53
+ backButton: O.deleteConfirmBackButton,
54
+ toast: O.deletedToast
55
+ } : V === "confirm" ? {
56
+ button: O.confirmBillButton,
57
+ title: O.confirmDuplicateTitle,
58
+ description: O.confirmDuplicateDescription,
59
+ confirmButton: O.confirmBillButton,
60
+ backButton: O.cancelConfirmBackButton,
61
+ toast: O.confirmedToast
62
+ } : {
63
+ button: O.cancelBillButton,
64
+ title: O.cancelConfirmTitle,
65
+ description: O.cancelConfirmDescription,
66
+ confirmButton: O.cancelConfirmButton,
67
+ backButton: O.cancelConfirmBackButton,
68
+ toast: O.cancelledToast
69
+ }, G = g(async () => {
70
+ await U(i.Remove, W.toast, T), I(!1);
71
+ }, [
72
+ U,
73
+ T,
74
+ W.toast
75
+ ]), K = _(() => ({
76
+ delete: {
77
+ action: O.deleteAction,
78
+ title: O.deleteConfirmTitle,
79
+ description: O.deleteConfirmDescription,
80
+ confirmButton: O.deleteConfirmButton,
81
+ backButton: O.deleteConfirmBackButton,
82
+ toast: O.deletedToast
83
+ },
84
+ cancel: {
85
+ action: O.cancelAction,
86
+ title: O.cancelConfirmTitle,
87
+ description: O.cancelConfirmDescription,
88
+ confirmButton: O.cancelConfirmButton,
89
+ backButton: O.cancelConfirmBackButton,
90
+ toast: O.cancelledToast
91
+ },
92
+ confirm: {
93
+ action: O.confirmAction,
94
+ title: O.confirmDuplicateTitle,
95
+ description: O.confirmDuplicateDescription,
96
+ confirmButton: O.confirmBillButton,
97
+ backButton: O.cancelConfirmBackButton,
98
+ toast: O.confirmedToast
99
+ }
100
+ }), [O]), q = K[L?.removeBy ?? "cancel"], J = g(async () => {
101
+ L && (await H(L.payable, i.Remove, K[L.removeBy].toast, L.payable.id === j ? T : void 0), R(void 0));
102
+ }, [
103
+ H,
104
+ T,
105
+ j,
106
+ L,
107
+ K
108
+ ]), Y = g(async () => {
109
+ z && (await H(z.payable, i.Keep, O.dismissedToast, void 0, z.originalPayableId), B(void 0));
110
+ }, [
111
+ H,
112
+ O.dismissedToast,
113
+ z
114
+ ]), X = w && !!(A && j), Z = X && !!V, Q = _(() => {
115
+ let e = new Map(N.flatMap((e) => e.data ? [[e.data.id, e.data]] : []));
116
+ s?.id && e.set(s.id, s);
117
+ let i = C([...e.values()], j);
118
+ if (i.length < 2) return [];
119
+ let o = c(i), f = (e) => {
120
+ let t = e.total_amount ?? e.amount_due;
121
+ return t == null ? "" : n(t / 100, { currencyCode: e.currency ?? "USD" });
122
+ };
123
+ return i.map((e) => {
124
+ let n = e.status ? r({
125
+ apiStatus: e.status,
126
+ dueDate: e.due_date,
127
+ scheduledPaymentDate: e.scheduled_payment_date
128
+ }) : void 0, i = e.id === o, s = e.id === j, c = w && a(e).length > 0, p = d(e), m = u(e.status);
129
+ return {
130
+ id: e.id,
131
+ roleLabel: p,
132
+ badges: [...i ? [O.originalBillBadge] : [], ...s ? [O.currentBillBadge] : []],
133
+ invoiceNumberLabel: e.document_id ?? "",
134
+ roleTone: i ? void 0 : "warning",
135
+ amountLabel: f(e),
136
+ addedOnLabel: t(e.created_at?.slice(0, 10)),
137
+ dueDateLabel: t(e.due_date),
138
+ status: n?.status,
139
+ statusTone: n?.tone,
140
+ onOpen: !s && E ? () => E(e.id, l(e.status ?? void 0)) : void 0,
141
+ menu: c ? {
142
+ triggerLabel: O.openRow({
143
+ vendorLabel: p,
144
+ invoiceNumberLabel: "",
145
+ addedOnLabel: t(e.created_at?.slice(0, 10))
146
+ }),
147
+ items: [{
148
+ id: "not-duplicate",
149
+ label: O.notDuplicateAction,
150
+ icon: b,
151
+ disabled: P.isPending,
152
+ onSelect: () => B({
153
+ payable: e,
154
+ originalPayableId: i ? void 0 : o
155
+ })
156
+ }, ...m ? [{
157
+ id: "cancel-duplicate",
158
+ label: K[m].action,
159
+ icon: m === "delete" ? x : y,
160
+ disabled: P.isPending,
161
+ onSelect: () => R({
162
+ payable: e,
163
+ removeBy: m
164
+ })
165
+ }] : []]
166
+ } : void 0
167
+ };
168
+ });
169
+ }, [
170
+ P.isPending,
171
+ w,
172
+ N,
173
+ O,
174
+ E,
175
+ s,
176
+ j,
177
+ K
178
+ ]);
179
+ return {
180
+ isPossibleDuplicate: !!A,
181
+ onNotADuplicate: X ? () => B({ payable: s }) : void 0,
182
+ onRemoveBill: Z ? () => I(!0) : void 0,
183
+ removeBillLabel: Z ? W.button : void 0,
184
+ removeConfirmation: {
185
+ open: F,
186
+ copy: {
187
+ title: W.title,
188
+ description: W.description,
189
+ confirmButton: W.confirmButton,
190
+ presentation: { tone: "destructive" }
191
+ },
192
+ onConfirm: () => void G(),
193
+ onCancel: () => I(!1),
194
+ isPending: P.isPending,
195
+ cancelButtonLabel: W.backButton
196
+ },
197
+ cancelRowConfirmation: {
198
+ open: !!L,
199
+ copy: m(q, L?.removeBy ?? "cancel"),
200
+ onConfirm: () => void J(),
201
+ onCancel: () => R(void 0),
202
+ isPending: P.isPending,
203
+ cancelButtonLabel: q.backButton
204
+ },
205
+ keepRowConfirmation: {
206
+ open: !!z,
207
+ copy: {
208
+ title: O.notDuplicateConfirmTitle,
209
+ description: O.notDuplicateConfirmDescription,
210
+ confirmButton: O.notDuplicateConfirmButton,
211
+ presentation: {
212
+ alignment: "center",
213
+ icon: b,
214
+ actionWidth: "equal"
215
+ }
216
+ },
217
+ onConfirm: () => void Y(),
218
+ onCancel: () => B(void 0),
219
+ isPending: P.isPending,
220
+ cancelButtonLabel: O.notDuplicateConfirmBackButton
221
+ },
222
+ isBusy: P.isPending,
223
+ rows: Q,
224
+ collapsedRowCount: S,
225
+ showMoreLabel: Q.length > S ? O.showMoreRows(Q.length - S) : void 0
226
+ };
227
+ }
39
228
  //#endregion
40
- export { e as DUPLICATE_BILLS_LABELS_EN };
229
+ export { w as usePayableDuplicateReview };