@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
@@ -1,50 +1,253 @@
1
- import { BillStatusFilter as e } from "./index78.js";
2
- import { BillsDatePreset as t } from "./index79.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
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/index72.js";
9
+ import "../../ui/dist/index.js";
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 "./index77.js";
13
+ import { BillsDatePreset as o, resolveDatePreset as s } from "./index78.js";
14
+ import { BILLS_FILTER_LABELS_EN as c } from "./index79.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";
3
17
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js
4
- var n = {
5
- presets: {
6
- [t.Today]: "Today",
7
- [t.ThisWeek]: "This week",
8
- [t.ThisMonth]: "This month",
9
- [t.ThisQuarter]: "This quarter",
10
- [t.ThisYear]: "This year",
11
- [t.Yesterday]: "Yesterday",
12
- [t.LastWeek]: "Last week",
13
- [t.LastMonth]: "Last month",
14
- [t.Last30Days]: "Last 30 days",
15
- [t.Last90Days]: "Last 90 days",
16
- [t.LastQuarter]: "Last quarter",
17
- [t.LastYear]: "Last year"
18
- },
19
- presetGroupCurrent: "Current",
20
- presetGroupPast: "Past",
21
- statuses: {
22
- [e.Draft]: "Draft",
23
- [e.ReadyToSubmit]: "Ready to submit",
24
- [e.PendingApproval]: "Pending review",
25
- [e.ReadyToPay]: "Ready to pay",
26
- [e.Paid]: "Paid",
27
- [e.Canceled]: "Cancelled",
28
- [e.Rejected]: "Rejected"
29
- },
30
- dateFieldNames: {
31
- issueDate: "Issue date",
32
- dueDate: "Due date",
33
- addedOn: "Added on"
34
- },
35
- dateChip: (e, t) => `${e}: ${t}`,
36
- statusChip: (e) => `Status: ${e}`,
37
- vendorChip: (e) => `Vendor: ${e}`,
38
- amountChip: (e) => `Total amount: ${e}`,
39
- attachmentChipHas: "Has attachment",
40
- attachmentChipNone: "No attachment",
41
- moreSelected: (e, t) => `${e} + ${t} more`,
42
- amountAtLeast: (e) => `${e} or more`,
43
- amountAtMost: (e) => `${e} or less`,
44
- amountBetween: (e, t) => `${e} - ${t}`,
45
- dateRange: (e, t) => `${e} - ${t}`,
46
- dateFrom: (e) => `From ${e}`,
47
- dateTo: (e) => `Until ${e}`
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"
48
41
  };
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(() => ({
58
+ ...c,
59
+ ...D,
60
+ presets: {
61
+ ...c.presets,
62
+ ...D?.presets
63
+ },
64
+ statuses: {
65
+ ...c.statuses,
66
+ ...D?.statuses
67
+ },
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
+ ...e,
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));
118
+ }
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;
152
+ }, [
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
+ let n = { ...t };
185
+ for (let t of z) e.includes(t.value) && (n[t.value] = t.label);
186
+ return n;
187
+ }), L({ vendorIds: e });
188
+ }, [L, z]);
189
+ return {
190
+ filterBarProps: {
191
+ fields: [...d(() => [
192
+ ...w ? [n.Vendor] : [],
193
+ n.IssueDate,
194
+ n.DueDate,
195
+ ...o ? [n.Status] : [],
196
+ n.TotalAmount,
197
+ n.AddedOn,
198
+ n.Attachment
199
+ ], [o, w])],
200
+ activeFilterCount: U.length,
201
+ chips: U,
202
+ onRemoveChip: W,
203
+ onClearAll: G,
204
+ dateField: k.dateField,
205
+ onDateFieldChange: (e) => {
206
+ let t = !!(k.dateFrom || k.dateTo);
207
+ A((t) => ({
208
+ ...t,
209
+ dateField: e
210
+ })), t && E?.();
211
+ },
212
+ datePresets: V,
213
+ selectedDatePreset: k.datePreset,
214
+ dateFrom: k.dateFrom,
215
+ dateTo: k.dateTo,
216
+ onDateRangeChange: ({ from: e, to: t }) => L({
217
+ datePreset: void 0,
218
+ dateFrom: e,
219
+ dateTo: t
220
+ }),
221
+ onDatePresetChange: (e) => {
222
+ 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);
223
+ L({
224
+ datePreset: e,
225
+ dateFrom: i,
226
+ dateTo: a
227
+ });
228
+ },
229
+ statusOptions: B,
230
+ selectedStatuses: k.statuses,
231
+ onStatusChange: (e) => L({ statuses: e }),
232
+ amountMode: k.amountMode,
233
+ onAmountModeChange: (e) => L({ amountMode: e }),
234
+ amountMin: k.amountMin,
235
+ amountMax: k.amountMax,
236
+ onAmountMinChange: (e) => L({ amountMin: e }),
237
+ onAmountMaxChange: (e) => L({ amountMax: e }),
238
+ vendorOptions: z,
239
+ selectedVendors: k.vendorIds,
240
+ onVendorChange: K,
241
+ vendorSearchValue: N,
242
+ onVendorSearchChange: P,
243
+ isVendorLoading: R.isLoading || T,
244
+ isVendorError: R.isError,
245
+ hasAttachment: k.hasFile,
246
+ onHasAttachmentChange: (e) => L({ hasFile: e })
247
+ },
248
+ query: H,
249
+ isFilterActive: U.length > 0
250
+ };
251
+ }
49
252
  //#endregion
50
- export { n as BILLS_FILTER_LABELS_EN };
253
+ export { h as BillsFilterChipKey, w as useBillsFilters };
@@ -2,252 +2,114 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
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";
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 { hasSuspectedPayableDuplicate as n } from "../../data-access/dist/index7.js";
8
+ import { usePayablesQuery as r, usePayablesTotalCountQuery as i } from "../../data-access/dist/index17.js";
7
9
  import "../../data-access/dist/index.js";
8
- import { BillsFilterField as n } from "../../ui/dist/index72.js";
9
- import "../../ui/dist/index.js";
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 "./index78.js";
13
- import { BillsDatePreset as o, resolveDatePreset as s } from "./index79.js";
14
- import { BILLS_FILTER_LABELS_EN as c } from "./index80.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";
10
+ import { derivePayableStatus as a } from "./index7.js";
11
+ import { resolveVendorName as o } from "./index8.js";
12
+ import { isEditablePayableStatus as s } from "./index37.js";
13
+ import { BillQueue as c, DEFAULT_BILL_QUEUE as l, billQueueColumns as u, billQueueHasScheduledPayment as d, billQueueOffersAddPanel as f, billQueueStatuses as p, billSortColumnId as m, billSortField as h } from "./index72.js";
14
+ import { useBillsFilters as g } from "./index80.js";
15
+ import { useCallback as _, useEffect as v, useMemo as y, useState as b } from "react";
17
16
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js
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"
41
- };
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(() => ({
58
- ...c,
59
- ...D,
60
- presets: {
61
- ...c.presets,
62
- ...D?.presets
63
- },
64
- statuses: {
65
- ...c.statuses,
66
- ...D?.statuses
67
- },
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
- ...e,
86
- statuses: []
87
- }));
88
- }, [o, E]), u(() => {
89
- let e = setTimeout(() => I(N.trim()), _);
17
+ var x = 10, S = [{
18
+ id: "addedOnLabel",
19
+ desc: !0
20
+ }];
21
+ function C({ enabled: C = !0, canReadVendors: w = !0, isVendorFilterPaused: T = !1, filterLabels: E, onOpenBill: D, duplicateBadgeLabel: O, attachmentLabel: k }) {
22
+ let [A, j] = b(l), [M, N] = b(S), [P, F] = b(x), [I, L] = b(), [R, z] = b(""), [B, V] = b(""), H = _(() => L(void 0), []);
23
+ v(() => {
24
+ let e = setTimeout(() => {
25
+ V(R), H();
26
+ }, 300);
90
27
  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));
118
- }
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) : "";
28
+ }, [R, H]);
29
+ let U = g({
30
+ offersStatusFilter: A === c.All,
31
+ offersVendorFilter: w,
32
+ isVendorFilterPaused: T,
33
+ labels: E,
34
+ onFiltersChange: H
35
+ }), W = M[0], G = h(W?.id), K = r({
36
+ ...U.query,
37
+ limit: P,
38
+ pagination_token: I,
39
+ status__in: p(A) ?? U.query.status__in,
40
+ has_scheduled_payment: d(A),
41
+ counterpart_name__icontains: B || void 0,
42
+ sort: G,
43
+ order: G ? W?.desc ? "desc" : "asc" : void 0,
44
+ enabled: C
45
+ }), q = K.data?.data.length === 0, J = i({ enabled: C && q }), Y = !q || (J.data?.count ?? 1) > 0, X = y(() => (K.data?.data ?? []).map((r) => {
46
+ let i = a({
47
+ apiStatus: r.status,
48
+ dueDate: r.due_date,
49
+ scheduledPaymentDate: r.scheduled_payment_date
50
+ }), c = r.amount_due ?? r.total_amount, l = (e) => e == null ? "" : t(e / 100, { currencyCode: r.currency ?? "USD" });
51
+ return {
52
+ vendorLabel: o(r),
53
+ issueDateLabel: e(r.issued_at),
54
+ dueDateLabel: e(r.due_date),
55
+ dueDateTone: i.isOverdue ? "danger" : "default",
56
+ scheduledDateLabel: e(r.scheduled_payment_date),
57
+ paidDateLabel: e(r.paid_at?.slice(0, 10)),
58
+ amountDueLabel: l(c),
59
+ amountPaidLabel: l(r.amount_paid),
60
+ amountScheduledLabel: l(r.amount_to_pay ?? c),
61
+ totalAmountLabel: l(r.total_amount),
62
+ attachment: r.file_id ? { label: k } : void 0,
63
+ status: i.status,
64
+ statusTone: i.tone,
65
+ addedOnLabel: e(r.created_at?.slice(0, 10)),
66
+ duplicateBadge: n(r) ? {
67
+ label: O,
68
+ tone: "warning"
69
+ } : void 0,
70
+ onOpen: () => D(r.id, s(r.status))
124
71
  };
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;
152
- }, [
72
+ }), [
73
+ K.data?.data,
153
74
  O,
154
75
  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
- let n = { ...t };
185
- for (let t of z) e.includes(t.value) && (n[t.value] = t.label);
186
- return n;
187
- }), L({ vendorIds: e });
188
- }, [L, z]);
76
+ D
77
+ ]), Z = _((e) => {
78
+ let t = e;
79
+ j(t), N((e) => {
80
+ let n = e[0]?.id;
81
+ return n ? u(t).some((e) => m(e) === n) ? e : S : e;
82
+ }), H();
83
+ }, [H]), Q = _((e) => {
84
+ N((t) => typeof e == "function" ? e(t) : e), H();
85
+ }, [H]), $ = _((e) => {
86
+ F(e), H();
87
+ }, [H]), ee = _(() => L(K.data?.next_pagination_token ?? void 0), [K.data?.next_pagination_token]), te = _(() => L(K.data?.prev_pagination_token ?? void 0), [K.data?.prev_pagination_token]), ne = _(() => {
88
+ K.refetch();
89
+ }, [K.refetch]);
189
90
  return {
190
- filterBarProps: {
191
- fields: [...d(() => [
192
- ...w ? [n.Vendor] : [],
193
- n.IssueDate,
194
- n.DueDate,
195
- ...o ? [n.Status] : [],
196
- n.TotalAmount,
197
- n.AddedOn,
198
- n.Attachment
199
- ], [o, w])],
200
- activeFilterCount: U.length,
201
- chips: U,
202
- onRemoveChip: W,
203
- onClearAll: G,
204
- dateField: k.dateField,
205
- onDateFieldChange: (e) => {
206
- let t = !!(k.dateFrom || k.dateTo);
207
- A((t) => ({
208
- ...t,
209
- dateField: e
210
- })), t && E?.();
211
- },
212
- datePresets: V,
213
- selectedDatePreset: k.datePreset,
214
- dateFrom: k.dateFrom,
215
- dateTo: k.dateTo,
216
- onDateRangeChange: ({ from: e, to: t }) => L({
217
- datePreset: void 0,
218
- dateFrom: e,
219
- dateTo: t
220
- }),
221
- onDatePresetChange: (e) => {
222
- 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);
223
- L({
224
- datePreset: e,
225
- dateFrom: i,
226
- dateTo: a
227
- });
228
- },
229
- statusOptions: B,
230
- selectedStatuses: k.statuses,
231
- onStatusChange: (e) => L({ statuses: e }),
232
- amountMode: k.amountMode,
233
- onAmountModeChange: (e) => L({ amountMode: e }),
234
- amountMin: k.amountMin,
235
- amountMax: k.amountMax,
236
- onAmountMinChange: (e) => L({ amountMin: e }),
237
- onAmountMaxChange: (e) => L({ amountMax: e }),
238
- vendorOptions: z,
239
- selectedVendors: k.vendorIds,
240
- onVendorChange: K,
241
- vendorSearchValue: N,
242
- onVendorSearchChange: P,
243
- isVendorLoading: R.isLoading || T,
244
- isVendorError: R.isError,
245
- hasAttachment: k.hasFile,
246
- onHasAttachmentChange: (e) => L({ hasFile: e })
247
- },
248
- query: H,
249
- isFilterActive: U.length > 0
91
+ rows: X,
92
+ isLoading: K.isFetching || q && J.isLoading,
93
+ isError: K.isError,
94
+ onRetry: ne,
95
+ selectedFilterTabId: A,
96
+ onFilterTabChange: Z,
97
+ searchValue: R,
98
+ onSearchChange: z,
99
+ hasAnyBills: Y,
100
+ isSearchActive: B.length > 0 || U.isFilterActive,
101
+ filterBarProps: U.filterBarProps,
102
+ visibleColumns: u(A),
103
+ showAddPanelWhenEmpty: f(A),
104
+ sorting: M,
105
+ onSortingChange: Q,
106
+ pageSize: P,
107
+ onPageSizeChange: $,
108
+ hasNextPage: !!K.data?.next_pagination_token,
109
+ hasPrevPage: !!K.data?.prev_pagination_token,
110
+ onNextPage: ee,
111
+ onPrevPage: te
250
112
  };
251
113
  }
252
114
  //#endregion
253
- export { h as BillsFilterChipKey, w as useBillsFilters };
115
+ export { C as useBillsTable };