@tesouro/embedded-components-react 0.5.113 → 0.5.115

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 (33) hide show
  1. package/dist/index.css +3 -0
  2. package/dist/index.js +1 -1
  3. package/dist/lib/BillPayWidget.js +1 -1
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +3 -3
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index17.js +57 -36
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index5.js +15 -11
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index6.js +10 -10
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +5 -5
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +3 -124
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +124 -8
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +8 -7
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +8 -47
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +44 -18
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +20 -28
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +19 -83
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +28 -47
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +76 -252
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +48 -136
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +246 -218
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +138 -4
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +212 -5
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +3 -112
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +7 -1
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +104 -18
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +1 -0
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index89.js +27 -0
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +231 -228
  28. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +24 -24
  29. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +143 -154
  30. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +79 -87
  31. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  32. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  33. package/package.json +1 -1
@@ -2,233 +2,261 @@
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 { 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, useWidgetInitStaleForToken as ee } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
- import "../../../shared/feature/dist/index.js";
12
- import { useDuplicateBillsCount as te } from "./index10.js";
13
- import { AddBillDialog as ne } from "../../ui/dist/index10.js";
14
- import { BillsScreen as i } from "../../ui/dist/index82.js";
5
+ import { formatMoneyExact as e } from "../../../shared/util/dist/lib/formatMoneyExact.js";
6
+ import { useCounterpartsQuery as t } from "../../../shared/counterpart-management/data-access/dist/index3.js";
7
+ import "../../data-access/dist/index.js";
8
+ import { BillsFilterField as n } from "../../ui/dist/index78.js";
15
9
  import "../../ui/dist/index.js";
16
- import { DuplicateBillsContainer as a } from "./index12.js";
17
- import "./index14.js";
18
- import { BillCreateDialog as o } from "./index60.js";
19
- import "./index61.js";
20
- import { BillDetailsContainer as re } from "./index63.js";
21
- import "./index64.js";
22
- import "./index70.js";
23
- import "./index71.js";
24
- import { BILL_QUEUE_ORDER as s, BillQueue as c } from "./index72.js";
25
- import { BILLS_TAB_LABELS_EN as l } from "./index75.js";
26
- import { useBillsTable as ie } from "./index81.js";
27
- import { copyTextToClipboard as ae } from "./index73.js";
28
- import { resolveDuplicateWarning as u } from "./index74.js";
29
- import { billsTabTestIds as d, billsTableCellTestIds as f } from "./index76.js";
30
- import { useCallback as p, useEffect as m, useMemo as h, useState as g } from "react";
31
- import { jsx as _, jsxs as oe } from "react/jsx-runtime";
32
- import { CalendarClockIcon as v, CheckIcon as y, FilePenIcon as b, ListIcon as x, LoaderCircleIcon as S } from "lucide-react";
10
+ import { getCounterpartName as r } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
11
+ import "../../../shared/counterpart-management/feature/dist/index.js";
12
+ import { BILL_STATUS_FILTER_ORDER as i, billStatusFilterApiValues as a } from "./index79.js";
13
+ import { BillsDatePreset as o, resolveDatePreset as s } from "./index80.js";
14
+ import { BILLS_FILTER_LABELS_EN as c } from "./index81.js";
15
+ import { useCallback as l, useEffect as u, useMemo as d, useState as f } from "react";
16
+ import { format as p, formatISO as m } from "date-fns";
33
17
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js
34
- var C = "bills@business-banking.app", w = {
35
- [c.Drafts]: /* @__PURE__ */ _(b, {
36
- className: "ttw:size-4",
37
- "aria-hidden": !0
38
- }),
39
- [c.Pending]: /* @__PURE__ */ _(S, {
40
- className: "ttw:size-4",
41
- "aria-hidden": !0
42
- }),
43
- [c.Scheduled]: /* @__PURE__ */ _(v, {
44
- className: "ttw:size-4",
45
- "aria-hidden": !0
46
- }),
47
- [c.Paid]: /* @__PURE__ */ _(y, {
48
- className: "ttw:size-4",
49
- "aria-hidden": !0
50
- }),
51
- [c.All]: /* @__PURE__ */ _(x, {
52
- className: "ttw:size-4",
53
- "aria-hidden": !0
54
- })
18
+ var h = {
19
+ Date: "date",
20
+ Status: "status",
21
+ Amount: "amount",
22
+ Vendor: "vendor",
23
+ Attachment: "attachment"
24
+ }, g = 50, _ = 300, v = "MMM d, yyyy", y = 864e5, b = {
25
+ [n.IssueDate]: "issued_at",
26
+ [n.DueDate]: "due_date",
27
+ [n.AddedOn]: "created_at"
28
+ }, x = {
29
+ [o.Today]: "current",
30
+ [o.ThisWeek]: "current",
31
+ [o.ThisMonth]: "current",
32
+ [o.ThisQuarter]: "current",
33
+ [o.ThisYear]: "current",
34
+ [o.Yesterday]: "past",
35
+ [o.LastWeek]: "past",
36
+ [o.LastMonth]: "past",
37
+ [o.Last30Days]: "past",
38
+ [o.Last90Days]: "past",
39
+ [o.LastQuarter]: "past",
40
+ [o.LastYear]: "past"
55
41
  };
56
- function T({ labels: c, onEnqueueFiles: v, openPayableId: y, onOpenPayableHandled: b, vendorIntent: x, onVendorIntentHandled: S, poweredByBankName: T, onSettingsClick: E }) {
57
- let D = h(() => ({
58
- ...l,
42
+ function S() {
43
+ return {
44
+ dateField: n.DueDate,
45
+ statuses: [],
46
+ amountMode: "any",
47
+ amountMin: "",
48
+ amountMax: "",
49
+ vendorIds: []
50
+ };
51
+ }
52
+ function C(e) {
53
+ let t = Number.parseFloat(e);
54
+ return Number.isFinite(t) ? Math.round(t * 100) : void 0;
55
+ }
56
+ function w({ offersStatusFilter: o = !1, offersVendorFilter: w = !0, isVendorFilterPaused: T = !1, onFiltersChange: E, labels: D } = {}) {
57
+ let O = d(() => ({
59
58
  ...c,
60
- queues: {
61
- ...l.queues,
62
- ...c?.queues
63
- },
64
- filters: {
65
- ...l.filters,
66
- ...c?.filters,
67
- presets: {
68
- ...l.filters.presets,
69
- ...c?.filters?.presets
70
- },
71
- statuses: {
72
- ...l.filters.statuses,
73
- ...c?.filters?.statuses
74
- },
75
- dateFieldNames: {
76
- ...l.filters.dateFieldNames,
77
- ...c?.filters?.dateFieldNames
78
- }
59
+ ...D,
60
+ presets: {
61
+ ...c.presets,
62
+ ...D?.presets
79
63
  },
80
- filterBar: {
81
- ...l.filterBar,
82
- ...c?.filterBar
64
+ statuses: {
65
+ ...c.statuses,
66
+ ...D?.statuses
83
67
  },
84
- queueEmptyStates: s.reduce((e, t) => ({
68
+ dateFieldNames: {
69
+ ...c.dateFieldNames,
70
+ ...D?.dateFieldNames
71
+ }
72
+ }), [D]), [k, A] = f(S), [j, M] = f({}), [N, P] = f(""), [F, I] = f(""), L = l((e) => {
73
+ A((t) => ({
74
+ ...t,
75
+ ...e
76
+ })), E?.();
77
+ }, [E]);
78
+ u(() => {
79
+ w || A((e) => e.vendorIds.length === 0 ? e : (E?.(), {
80
+ ...e,
81
+ vendorIds: []
82
+ }));
83
+ }, [w, E]), u(() => {
84
+ o || A((e) => e.statuses.length === 0 ? e : (E?.(), {
85
85
  ...e,
86
- [t]: {
87
- ...l.queueEmptyStates[t],
88
- ...c?.queueEmptyStates?.[t]
89
- }
90
- }), {})
91
- }), [c]), [se, O] = g(!1), [ce, k] = g(), [le, A] = g(), [j, M] = g(!1), [N, P] = g(), [F, I] = g(!1), [L, R] = g(!1), [z, B] = g(!1), { initResponse: V } = r(), H = ee(), U = t(V?.scopes, [n.PayableReadOrg]), ue = t(V?.scopes, [n.PayableWriteOrg]), W = !V || U, G = !V || ue, de = p((e, t) => {
92
- if (t && G) {
93
- k(e), A(void 0), M(!0);
94
- return;
86
+ statuses: []
87
+ }));
88
+ }, [o, E]), u(() => {
89
+ let e = setTimeout(() => I(N.trim()), _);
90
+ return () => clearTimeout(e);
91
+ }, [N]);
92
+ let R = t({
93
+ enabled: w && !T,
94
+ is_vendor: !0,
95
+ sort: "counterpart_name",
96
+ order: "asc",
97
+ limit: g,
98
+ counterpart_name__icontains: F || void 0
99
+ }), z = d(() => (R.data?.data ?? []).map((e) => ({
100
+ value: e.id,
101
+ label: r(e)
102
+ })), [R.data?.data]), B = d(() => i.map((e) => ({
103
+ value: e,
104
+ label: O.statuses[e]
105
+ })), [O.statuses]), V = d(() => Object.entries(x).map(([e, t]) => ({
106
+ value: e,
107
+ label: O.presets[e],
108
+ group: t === "current" ? O.presetGroupCurrent : O.presetGroupPast
109
+ })), [
110
+ O.presetGroupCurrent,
111
+ O.presetGroupPast,
112
+ O.presets
113
+ ]), H = d(() => {
114
+ let e = {}, t = b[k.dateField], n = (e) => Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
115
+ if (k.dateFrom && (e[`${t}__gte`] = t === "created_at" ? new Date(n(k.dateFrom)).toISOString() : m(k.dateFrom, { representation: "date" })), k.dateTo && (t === "created_at" ? e.created_at__lt = new Date(n(k.dateTo) + y).toISOString() : e[`${t}__lte`] = m(k.dateTo, { representation: "date" })), k.statuses.length > 0 && (e.status__in = a(k.statuses)), k.amountMode !== "any") {
116
+ let t = "total_amount__gte", n = "total_amount__lte", r = C(k.amountMin), i = C(k.amountMax);
117
+ k.amountMode === "exact" ? r !== void 0 && (e[t] = r, e[n] = r) : (r !== void 0 && (e[t] = r), i !== void 0 && (e[n] = i));
95
118
  }
96
- P(e), R(!0);
97
- }, [G]), fe = t(V?.scopes, [n.CounterpartReadOrg]), K = ie({
98
- enabled: W,
99
- canReadVendors: fe,
100
- isVendorFilterPaused: H,
101
- filterLabels: D.filters,
102
- onOpenBill: de,
103
- duplicateRowNote: D.duplicateRowNote,
104
- attachmentLabel: D.attachmentIndicator
105
- }), q = te({ enabled: W }), pe = u(q, D), me = h(() => s.map((e) => ({
106
- id: e,
107
- label: D.queues[e],
108
- icon: w[e]
109
- })), [D.queues]), he = (e) => {
110
- B(!1), P(e), R(!0);
111
- }, ge = () => {
112
- I(!1), R(!0);
113
- }, _e = () => {
114
- R(!1), I(!0);
115
- }, J = () => {
116
- I(!1), R(!1), k(N), A(void 0), M(!0);
117
- }, Y = h(() => ({
118
- createButton: D.createButton,
119
- settingsButton: D.settingsButton,
120
- addBill: { heading: D.nonEmptyHeading }
121
- }), [
122
- D.createButton,
123
- D.settingsButton,
124
- D.nonEmptyHeading
125
- ]), ve = h(() => ({
126
- ...K.filterBarProps,
127
- labels: D.filterBar
128
- }), [K.filterBarProps, D.filterBar]), X = p((e) => {
129
- O(!1), k(void 0), A(e), M(!0);
130
- }, []), Z = (e) => {
131
- O(!1), v?.(e);
132
- }, Q = async () => {
133
- await ae(C) ? e.success(D.emailCopiedToast) : e.error(D.emailCopyFailedToast);
134
- };
135
- m(() => {
136
- y && (k(y), A(void 0), M(!0), b?.());
137
- }, [b, y]);
138
- let { showVendorBills: $ } = K;
139
- return m(() => {
140
- x && (x.action === "createBill" ? G && X(x.vendorId) : $({
141
- id: x.vendorId,
142
- name: x.vendorName
143
- }), S?.());
119
+ return k.vendorIds.length > 0 && (e.counterpart_id__in = [...k.vendorIds]), k.hasFile !== void 0 && (e.has_file = k.hasFile), e;
120
+ }, [k]), U = d(() => {
121
+ let t = [], n = (e) => p(e, v), r = (e) => {
122
+ let [t, ...n] = e;
123
+ return t ? n.length === 0 ? t : O.moreSelected(t, n.length) : "";
124
+ };
125
+ if (k.dateFrom || k.dateTo) {
126
+ let e = (k.datePreset ? O.presets[k.datePreset] : void 0) ?? (k.dateFrom && k.dateTo ? O.dateRange(n(k.dateFrom), n(k.dateTo)) : k.dateFrom ? O.dateFrom(n(k.dateFrom)) : O.dateTo(n(k.dateTo)));
127
+ t.push({
128
+ key: h.Date,
129
+ label: O.dateChip(O.dateFieldNames[k.dateField], e)
130
+ });
131
+ }
132
+ if (k.statuses.length > 0 && t.push({
133
+ key: h.Status,
134
+ label: O.statusChip(r(k.statuses.map((e) => O.statuses[e] ?? e)))
135
+ }), k.vendorIds.length > 0 && t.push({
136
+ key: h.Vendor,
137
+ label: O.vendorChip(r(k.vendorIds.map((e) => j[e] ?? e)))
138
+ }), k.amountMode !== "any") {
139
+ let n = (t) => {
140
+ let n = Number.parseFloat(t);
141
+ return Number.isFinite(n) ? e(n, { currencyCode: "USD" }) : "";
142
+ }, r = n(k.amountMin), i = n(k.amountMax), a = k.amountMode === "exact" ? r : r && i ? O.amountBetween(r, i) : r ? O.amountAtLeast(r) : i ? O.amountAtMost(i) : "";
143
+ a && t.push({
144
+ key: h.Amount,
145
+ label: O.amountChip(a)
146
+ });
147
+ }
148
+ return k.hasFile !== void 0 && t.push({
149
+ key: h.Attachment,
150
+ label: k.hasFile ? O.attachmentChipHas : O.attachmentChipNone
151
+ }), t;
144
152
  }, [
145
- G,
146
- S,
147
- X,
148
- $,
149
- x
150
- ]), /* @__PURE__ */ oe("div", {
151
- "data-testid": d.root,
152
- children: [
153
- /* @__PURE__ */ _(i, {
154
- rows: K.rows,
155
- isLoading: K.isLoading || !V,
156
- isError: K.isError,
157
- onRetry: K.onRetry,
158
- sorting: K.sorting,
159
- onSortingChange: K.onSortingChange,
160
- pageSize: K.pageSize,
161
- onPageSizeChange: K.onPageSizeChange,
162
- hasNextPage: K.hasNextPage,
163
- hasPrevPage: K.hasPrevPage,
164
- onNextPage: K.onNextPage,
165
- onPrevPage: K.onPrevPage,
166
- filterTabs: me,
167
- selectedFilterTabId: K.selectedFilterTabId,
168
- onFilterTabChange: K.onFilterTabChange,
169
- searchValue: K.searchValue,
170
- onSearchChange: K.onSearchChange,
171
- filters: ve,
172
- visibleColumns: K.visibleColumns,
173
- cellTestIds: f,
174
- isSearchActive: K.isSearchActive,
175
- showAddPanelWhenEmpty: K.showAddPanelWhenEmpty,
176
- emptyState: D.queueEmptyStates[K.selectedFilterTabId],
177
- onCreateClick: G ? () => O(!0) : void 0,
178
- onSettingsClick: E,
179
- onEnterManually: G ? () => X() : void 0,
180
- onFilesSelected: G ? Z : void 0,
181
- maxFiles: 10,
182
- emailAddress: C,
183
- onCopyEmail: Q,
184
- duplicateWarning: pe,
185
- onReviewDuplicates: q.isError ? void 0 : () => B(!0),
186
- labels: Y
153
+ O,
154
+ k,
155
+ j
156
+ ]), W = l((e) => {
157
+ switch (e) {
158
+ case h.Date:
159
+ L({
160
+ datePreset: void 0,
161
+ dateFrom: void 0,
162
+ dateTo: void 0
163
+ });
164
+ break;
165
+ case h.Status:
166
+ L({ statuses: [] });
167
+ break;
168
+ case h.Vendor:
169
+ L({ vendorIds: [] });
170
+ break;
171
+ case h.Amount:
172
+ L({
173
+ amountMode: "any",
174
+ amountMin: "",
175
+ amountMax: ""
176
+ });
177
+ break;
178
+ case h.Attachment: L({ hasFile: void 0 });
179
+ }
180
+ }, [L]), G = l(() => {
181
+ A(S()), E?.();
182
+ }, [E]), K = l((e) => {
183
+ M((t) => ({
184
+ ...t,
185
+ [e.id]: e.name
186
+ })), A({
187
+ ...S(),
188
+ vendorIds: [e.id]
189
+ }), E?.();
190
+ }, [E]), q = l((e) => {
191
+ M((t) => {
192
+ let n = { ...t };
193
+ for (let t of z) e.includes(t.value) && (n[t.value] = t.label);
194
+ return n;
195
+ }), L({ vendorIds: e });
196
+ }, [L, z]);
197
+ return {
198
+ filterBarProps: {
199
+ fields: [...d(() => [
200
+ ...w ? [n.Vendor] : [],
201
+ n.IssueDate,
202
+ n.DueDate,
203
+ ...o ? [n.Status] : [],
204
+ n.TotalAmount,
205
+ n.AddedOn,
206
+ n.Attachment
207
+ ], [o, w])],
208
+ activeFilterCount: U.length,
209
+ chips: U,
210
+ onRemoveChip: W,
211
+ onClearAll: G,
212
+ dateField: k.dateField,
213
+ onDateFieldChange: (e) => {
214
+ let t = !!(k.dateFrom || k.dateTo);
215
+ A((t) => ({
216
+ ...t,
217
+ dateField: e
218
+ })), t && E?.();
219
+ },
220
+ datePresets: V,
221
+ selectedDatePreset: k.datePreset,
222
+ dateFrom: k.dateFrom,
223
+ dateTo: k.dateTo,
224
+ onDateRangeChange: ({ from: e, to: t }) => L({
225
+ datePreset: void 0,
226
+ dateFrom: e,
227
+ dateTo: t
187
228
  }),
188
- z ? /* @__PURE__ */ _(a, {
189
- open: z,
190
- onOpenChange: B,
191
- enabled: W,
192
- canManageDuplicates: G,
193
- onOpenBill: he
194
- }) : null,
195
- G ? /* @__PURE__ */ _(ne, {
196
- open: se,
197
- onOpenChange: O,
198
- onFilesSelected: Z,
199
- maxFiles: 10,
200
- onEnterManually: () => X(),
201
- emailAddress: C,
202
- onCopyEmail: Q,
203
- labels: { heading: K.hasAnyBills ? D.nonEmptyHeading : D.emptyHeading }
204
- }) : null,
205
- j ? /* @__PURE__ */ _(o, {
206
- open: j,
207
- onOpenChange: M,
208
- payableId: ce,
209
- initialCounterpartId: le
210
- }) : null,
211
- F ? /* @__PURE__ */ _(re, {
212
- open: F,
213
- onOpenChange: I,
214
- payableId: N,
215
- onClose: () => I(!1),
216
- onExpand: ge,
217
- onEdit: J,
218
- testId: d.detailsSheet,
219
- poweredByBankName: T
220
- }) : null,
221
- L ? /* @__PURE__ */ _(o, {
222
- open: L,
223
- onOpenChange: R,
224
- payableId: N,
225
- readOnly: !0,
226
- onCollapse: _e,
227
- onEdit: J,
228
- poweredByBankName: T
229
- }) : null
230
- ]
231
- });
229
+ onDatePresetChange: (e) => {
230
+ let t = /* @__PURE__ */ new Date(), r = k.dateField === n.AddedOn ? new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate()) : t, { from: i, to: a } = s(e, r);
231
+ L({
232
+ datePreset: e,
233
+ dateFrom: i,
234
+ dateTo: a
235
+ });
236
+ },
237
+ statusOptions: B,
238
+ selectedStatuses: k.statuses,
239
+ onStatusChange: (e) => L({ statuses: e }),
240
+ amountMode: k.amountMode,
241
+ onAmountModeChange: (e) => L({ amountMode: e }),
242
+ amountMin: k.amountMin,
243
+ amountMax: k.amountMax,
244
+ onAmountMinChange: (e) => L({ amountMin: e }),
245
+ onAmountMaxChange: (e) => L({ amountMax: e }),
246
+ vendorOptions: z,
247
+ selectedVendors: k.vendorIds,
248
+ onVendorChange: q,
249
+ vendorSearchValue: N,
250
+ onVendorSearchChange: P,
251
+ isVendorLoading: R.isLoading || T,
252
+ isVendorError: R.isError,
253
+ hasAttachment: k.hasFile,
254
+ onHasAttachmentChange: (e) => L({ hasFile: e })
255
+ },
256
+ query: H,
257
+ isFilterActive: U.length > 0,
258
+ filterByVendor: K
259
+ };
232
260
  }
233
261
  //#endregion
234
- export { T as BillsTab, T as default };
262
+ export { h as BillsFilterChipKey, w as useBillsFilters };
@@ -1,4 +1,138 @@
1
- import "./index72.js";
2
- import "./index75.js";
3
- import "./index81.js";
4
- import "./index82.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.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 { hasSuspectedPayableDuplicate as r } from "../../data-access/dist/index7.js";
9
+ import { usePayablesQuery as i, usePayablesTotalCountQuery as a } from "../../data-access/dist/index17.js";
10
+ import "../../data-access/dist/index.js";
11
+ import { derivePayableStatus as o } from "./index7.js";
12
+ import { resolveVendorName as ee } from "./index8.js";
13
+ import { isEditablePayableStatus as s } from "./index19.js";
14
+ import { BillQueue as c, DEFAULT_BILL_QUEUE as l, billQueueColumns as u, billQueueHasScheduledPayment as te, billQueueOffersAddPanel as d, billQueueStatuses as f, billSortColumnId as ne, billSortField as p } from "./index73.js";
15
+ import { useBillsFilters as m } from "./index82.js";
16
+ import { useCallback as h, useEffect as g, useMemo as _, useState as v } from "react";
17
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js
18
+ var y = 10, b = [{
19
+ id: "addedOnLabel",
20
+ desc: !0
21
+ }];
22
+ function x({ enabled: x = !0, canReadVendors: S = !0, isVendorFilterPaused: C = !1, filterLabels: re, onOpenBill: w, duplicateRowNote: T, attachmentLabel: E }) {
23
+ let [D, ie] = v(l), [O, k] = v(b), [A, j] = v(y), [M, N] = v(), [P, F] = v(""), [I, L] = v(""), R = h(() => N(void 0), []);
24
+ g(() => {
25
+ let e = setTimeout(() => {
26
+ L(P), R();
27
+ }, 300);
28
+ return () => clearTimeout(e);
29
+ }, [P, R]);
30
+ let z = m({
31
+ offersStatusFilter: D === c.All,
32
+ offersVendorFilter: S,
33
+ isVendorFilterPaused: C,
34
+ labels: re,
35
+ onFiltersChange: R
36
+ }), { filterByVendor: B } = z, V = O[0], H = p(V?.id), U = H ? V?.desc ? "desc" : "asc" : void 0, W = _(() => ({
37
+ ...z.query,
38
+ limit: A,
39
+ pagination_token: M,
40
+ status__in: f(D) ?? z.query.status__in,
41
+ has_scheduled_payment: te(D),
42
+ counterpart_name__icontains: I || void 0,
43
+ sort: H,
44
+ order: U
45
+ }), [
46
+ z.query,
47
+ A,
48
+ M,
49
+ D,
50
+ I,
51
+ H,
52
+ U
53
+ ]), { organizationId: G } = e(), K = JSON.stringify([G, W]), q = i({
54
+ ...W,
55
+ enabled: x,
56
+ pollWhileOcrProcessing: !0
57
+ }), [J, ae] = v(K);
58
+ g(() => {
59
+ q.isFetching || ae(K);
60
+ }, [q.isFetching, K]);
61
+ let Y = q.data?.data.length, X = Y === 0, Z = a({ enabled: x && X }), oe = !X || (Z.data?.count ?? 1) > 0, Q = _(() => (q.data?.data ?? []).filter((e) => e.ocr_status !== "processing").map((e) => {
62
+ let i = o({
63
+ apiStatus: e.status,
64
+ dueDate: e.due_date,
65
+ scheduledPaymentDate: e.scheduled_payment_date
66
+ }), a = e.amount_due ?? e.total_amount, l = e.status === "partially_paid" || e.status === "paid", u = (t) => t == null ? "" : n(t / 100, { currencyCode: e.currency ?? "USD" });
67
+ return {
68
+ rowKey: e.id,
69
+ vendorLabel: ee(e),
70
+ issueDateLabel: t(e.issued_at),
71
+ dueDateLabel: t(e.due_date),
72
+ dueDateTone: i.isOverdue ? "danger" : "default",
73
+ scheduledDateLabel: t(e.scheduled_payment_date),
74
+ scheduledDateIsGap: D === c.Scheduled,
75
+ paidDateLabel: t(e.paid_at?.slice(0, 10)),
76
+ amountDueLabel: u(a),
77
+ amountPaidLabel: l ? u(e.amount_paid) : "",
78
+ amountPaidIsGap: D === c.Paid,
79
+ amountScheduledLabel: u(e.amount_to_pay ?? a),
80
+ totalAmountLabel: u(e.total_amount),
81
+ attachment: e.file_id ? { label: E } : void 0,
82
+ status: i.status,
83
+ statusTone: i.tone,
84
+ addedOnLabel: t(e.created_at?.slice(0, 10)),
85
+ ...r(e) ? {
86
+ rowTone: "warning",
87
+ rowNote: T
88
+ } : {},
89
+ onOpen: () => w(e.id, s(e.status))
90
+ };
91
+ }), [
92
+ q.data?.data,
93
+ T,
94
+ E,
95
+ w,
96
+ D
97
+ ]), $ = h((e) => {
98
+ let t = e;
99
+ ie(t), k((e) => {
100
+ let n = e[0]?.id;
101
+ return n ? u(t).some((e) => ne(e) === n) ? e : b : e;
102
+ }), R();
103
+ }, [R]), se = h((e) => {
104
+ $(c.All), F(""), B(e);
105
+ }, [B, $]), ce = h((e) => {
106
+ k((t) => typeof e == "function" ? e(t) : e), R();
107
+ }, [R]), le = h((e) => {
108
+ j(e), R();
109
+ }, [R]), ue = h(() => N(q.data?.next_pagination_token ?? void 0), [q.data?.next_pagination_token]), de = h(() => N(q.data?.prev_pagination_token ?? void 0), [q.data?.prev_pagination_token]), fe = h(() => {
110
+ q.refetch();
111
+ }, [q.refetch]);
112
+ return {
113
+ rows: Q,
114
+ isLoading: q.isLoading || K !== J || X && Z.isLoading || (Y ?? 0) > 0 && Q.length === 0,
115
+ isError: q.isError,
116
+ onRetry: fe,
117
+ selectedFilterTabId: D,
118
+ onFilterTabChange: $,
119
+ showVendorBills: se,
120
+ searchValue: P,
121
+ onSearchChange: F,
122
+ hasAnyBills: oe,
123
+ isSearchActive: I.length > 0 || z.isFilterActive,
124
+ filterBarProps: z.filterBarProps,
125
+ visibleColumns: u(D),
126
+ showAddPanelWhenEmpty: d(D),
127
+ sorting: O,
128
+ onSortingChange: ce,
129
+ pageSize: A,
130
+ onPageSizeChange: le,
131
+ hasNextPage: !!q.data?.next_pagination_token,
132
+ hasPrevPage: !!q.data?.prev_pagination_token,
133
+ onNextPage: ue,
134
+ onPrevPage: de
135
+ };
136
+ }
137
+ //#endregion
138
+ export { x as useBillsTable };