@tesouro/embedded-components-react 0.5.65 → 0.5.68

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.
@@ -9,126 +9,127 @@ import { hasSuspectedPayableDuplicate as ee } from "../../data-access/dist/index
9
9
  import { usePayablesQuery as r, usePayablesTotalCountQuery as i } from "../../data-access/dist/index17.js";
10
10
  import "../../data-access/dist/index.js";
11
11
  import { derivePayableStatus as te } from "./index7.js";
12
- import { resolveVendorName as a } from "./index8.js";
13
- import { isEditablePayableStatus as ne } from "./index19.js";
14
- import { BillQueue as o, DEFAULT_BILL_QUEUE as s, billQueueColumns as c, billQueueHasScheduledPayment as l, billQueueOffersAddPanel as u, billQueueStatuses as d, billSortColumnId as f, billSortField as p } from "./index73.js";
15
- import { useBillsFilters as m } from "./index81.js";
16
- import { useCallback as h, useEffect as g, useMemo as _, useState as v } from "react";
12
+ import { resolveVendorName as ne } from "./index8.js";
13
+ import { isEditablePayableStatus as re } from "./index19.js";
14
+ import { BillQueue as a, DEFAULT_BILL_QUEUE as o, billQueueColumns as s, billQueueHasScheduledPayment as c, billQueueOffersAddPanel as l, billQueueStatuses as u, billSortColumnId as d, billSortField as f } from "./index73.js";
15
+ import { useBillsFilters as p } from "./index81.js";
16
+ import { useCallback as m, useEffect as h, useMemo as g, useState as _ } from "react";
17
17
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js
18
- var y = 10, b = [{
18
+ var v = 10, y = [{
19
19
  id: "addedOnLabel",
20
20
  desc: !0
21
21
  }];
22
- function x({ enabled: x = !0, canReadVendors: S = !0, isVendorFilterPaused: C = !1, filterLabels: w, onOpenBill: T, duplicateRowNote: E, attachmentLabel: D }) {
23
- let [O, k] = v(s), [A, j] = v(b), [M, N] = v(y), [P, F] = v(), [I, L] = v(""), [R, z] = v(""), B = h(() => F(void 0), []);
24
- g(() => {
22
+ function b({ enabled: b = !0, canReadVendors: x = !0, isVendorFilterPaused: S = !1, filterLabels: C, onOpenBill: w, duplicateRowNote: T, attachmentLabel: E }) {
23
+ let [D, O] = _(o), [k, A] = _(y), [j, ie] = _(v), [M, N] = _(), [P, F] = _(""), [I, L] = _(""), R = m(() => N(void 0), []);
24
+ h(() => {
25
25
  let e = setTimeout(() => {
26
- z(I), B();
26
+ L(P), R();
27
27
  }, 300);
28
28
  return () => clearTimeout(e);
29
- }, [I, B]);
30
- let V = m({
31
- offersStatusFilter: O === o.All,
32
- offersVendorFilter: S,
33
- isVendorFilterPaused: C,
34
- labels: w,
35
- onFiltersChange: B
36
- }), H = A[0], U = p(H?.id), W = U ? H?.desc ? "desc" : "asc" : void 0, G = _(() => ({
37
- ...V.query,
38
- limit: M,
39
- pagination_token: P,
40
- status__in: d(O) ?? V.query.status__in,
41
- has_scheduled_payment: l(O),
42
- counterpart_name__icontains: R || void 0,
43
- sort: U,
44
- order: W
29
+ }, [P, R]);
30
+ let z = p({
31
+ offersStatusFilter: D === a.All,
32
+ offersVendorFilter: x,
33
+ isVendorFilterPaused: S,
34
+ labels: C,
35
+ onFiltersChange: R
36
+ }), B = k[0], V = f(B?.id), H = V ? B?.desc ? "desc" : "asc" : void 0, U = g(() => ({
37
+ ...z.query,
38
+ limit: j,
39
+ pagination_token: M,
40
+ status__in: u(D) ?? z.query.status__in,
41
+ has_scheduled_payment: c(D),
42
+ counterpart_name__icontains: I || void 0,
43
+ sort: V,
44
+ order: H
45
45
  }), [
46
- V.query,
46
+ z.query,
47
+ j,
47
48
  M,
48
- P,
49
- O,
50
- R,
51
- U,
52
- W
53
- ]), { organizationId: K } = e(), q = JSON.stringify([K, G]), J = r({
54
- ...G,
55
- enabled: x
56
- }), [Y, X] = v(q);
57
- g(() => {
58
- J.isFetching || X(q);
59
- }, [J.isFetching, q]);
60
- let Z = J.data?.data.length === 0, Q = i({ enabled: x && Z }), re = !Z || (Q.data?.count ?? 1) > 0, ie = _(() => (J.data?.data ?? []).map((e) => {
49
+ D,
50
+ I,
51
+ V,
52
+ H
53
+ ]), { organizationId: W } = e(), G = JSON.stringify([W, U]), K = r({
54
+ ...U,
55
+ enabled: b,
56
+ pollWhileOcrProcessing: !0
57
+ }), [q, J] = _(G);
58
+ h(() => {
59
+ K.isFetching || J(G);
60
+ }, [K.isFetching, G]);
61
+ let Y = K.data?.data.length, X = Y === 0, Z = i({ enabled: b && X }), ae = !X || (Z.data?.count ?? 1) > 0, Q = g(() => (K.data?.data ?? []).filter((e) => e.ocr_status !== "processing").map((e) => {
61
62
  let r = te({
62
63
  apiStatus: e.status,
63
64
  dueDate: e.due_date,
64
65
  scheduledPaymentDate: e.scheduled_payment_date
65
- }), i = e.amount_due ?? e.total_amount, s = e.status === "partially_paid" || e.status === "paid", c = (t) => t == null ? "" : n(t / 100, { currencyCode: e.currency ?? "USD" });
66
+ }), i = e.amount_due ?? e.total_amount, o = e.status === "partially_paid" || e.status === "paid", s = (t) => t == null ? "" : n(t / 100, { currencyCode: e.currency ?? "USD" });
66
67
  return {
67
68
  rowKey: e.id,
68
- vendorLabel: a(e),
69
+ vendorLabel: ne(e),
69
70
  issueDateLabel: t(e.issued_at),
70
71
  dueDateLabel: t(e.due_date),
71
72
  dueDateTone: r.isOverdue ? "danger" : "default",
72
73
  scheduledDateLabel: t(e.scheduled_payment_date),
73
- scheduledDateIsGap: O === o.Scheduled,
74
+ scheduledDateIsGap: D === a.Scheduled,
74
75
  paidDateLabel: t(e.paid_at?.slice(0, 10)),
75
- amountDueLabel: c(i),
76
- amountPaidLabel: s ? c(e.amount_paid) : "",
77
- amountPaidIsGap: O === o.Paid,
78
- amountScheduledLabel: c(e.amount_to_pay ?? i),
79
- totalAmountLabel: c(e.total_amount),
80
- attachment: e.file_id ? { label: D } : void 0,
76
+ amountDueLabel: s(i),
77
+ amountPaidLabel: o ? s(e.amount_paid) : "",
78
+ amountPaidIsGap: D === a.Paid,
79
+ amountScheduledLabel: s(e.amount_to_pay ?? i),
80
+ totalAmountLabel: s(e.total_amount),
81
+ attachment: e.file_id ? { label: E } : void 0,
81
82
  status: r.status,
82
83
  statusTone: r.tone,
83
84
  addedOnLabel: t(e.created_at?.slice(0, 10)),
84
85
  ...ee(e) ? {
85
86
  rowTone: "warning",
86
- rowNote: E
87
+ rowNote: T
87
88
  } : {},
88
- onOpen: () => T(e.id, ne(e.status))
89
+ onOpen: () => w(e.id, re(e.status))
89
90
  };
90
91
  }), [
91
- J.data?.data,
92
- E,
93
- D,
92
+ K.data?.data,
94
93
  T,
95
- O
96
- ]), ae = h((e) => {
94
+ E,
95
+ w,
96
+ D
97
+ ]), oe = m((e) => {
97
98
  let t = e;
98
- k(t), j((e) => {
99
+ O(t), A((e) => {
99
100
  let n = e[0]?.id;
100
- return n ? c(t).some((e) => f(e) === n) ? e : b : e;
101
- }), B();
102
- }, [B]), oe = h((e) => {
103
- j((t) => typeof e == "function" ? e(t) : e), B();
104
- }, [B]), $ = h((e) => {
105
- N(e), B();
106
- }, [B]), se = h(() => F(J.data?.next_pagination_token ?? void 0), [J.data?.next_pagination_token]), ce = h(() => F(J.data?.prev_pagination_token ?? void 0), [J.data?.prev_pagination_token]), le = h(() => {
107
- J.refetch();
108
- }, [J.refetch]);
101
+ return n ? s(t).some((e) => d(e) === n) ? e : y : e;
102
+ }), R();
103
+ }, [R]), se = m((e) => {
104
+ A((t) => typeof e == "function" ? e(t) : e), R();
105
+ }, [R]), ce = m((e) => {
106
+ ie(e), R();
107
+ }, [R]), le = m(() => N(K.data?.next_pagination_token ?? void 0), [K.data?.next_pagination_token]), $ = m(() => N(K.data?.prev_pagination_token ?? void 0), [K.data?.prev_pagination_token]), ue = m(() => {
108
+ K.refetch();
109
+ }, [K.refetch]);
109
110
  return {
110
- rows: ie,
111
- isLoading: J.isLoading || q !== Y || Z && Q.isLoading,
112
- isError: J.isError,
113
- onRetry: le,
114
- selectedFilterTabId: O,
115
- onFilterTabChange: ae,
116
- searchValue: I,
117
- onSearchChange: L,
118
- hasAnyBills: re,
119
- isSearchActive: R.length > 0 || V.isFilterActive,
120
- filterBarProps: V.filterBarProps,
121
- visibleColumns: c(O),
122
- showAddPanelWhenEmpty: u(O),
123
- sorting: A,
124
- onSortingChange: oe,
125
- pageSize: M,
126
- onPageSizeChange: $,
127
- hasNextPage: !!J.data?.next_pagination_token,
128
- hasPrevPage: !!J.data?.prev_pagination_token,
129
- onNextPage: se,
130
- onPrevPage: ce
111
+ rows: Q,
112
+ isLoading: K.isLoading || G !== q || X && Z.isLoading || (Y ?? 0) > 0 && Q.length === 0,
113
+ isError: K.isError,
114
+ onRetry: ue,
115
+ selectedFilterTabId: D,
116
+ onFilterTabChange: oe,
117
+ searchValue: P,
118
+ onSearchChange: F,
119
+ hasAnyBills: ae,
120
+ isSearchActive: I.length > 0 || z.isFilterActive,
121
+ filterBarProps: z.filterBarProps,
122
+ visibleColumns: s(D),
123
+ showAddPanelWhenEmpty: l(D),
124
+ sorting: k,
125
+ onSortingChange: se,
126
+ pageSize: j,
127
+ onPageSizeChange: ce,
128
+ hasNextPage: !!K.data?.next_pagination_token,
129
+ hasPrevPage: !!K.data?.prev_pagination_token,
130
+ onNextPage: le,
131
+ onPrevPage: $
131
132
  };
132
133
  }
133
134
  //#endregion
134
- export { x as useBillsTable };
135
+ export { b as useBillsTable };
@@ -1,6 +1,6 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js
2
2
  var e = {
3
- legalNameRequired: "Legal name is required",
3
+ legalNameRequired: "Business name is required",
4
4
  firstNameRequired: "First name is required",
5
5
  lastNameRequired: "Last name is required",
6
6
  emailRequired: "Email is required",
@@ -18,7 +18,7 @@ var e = {
18
18
  genericError: "Something went wrong. Please try again.",
19
19
  deleteTitle: "Delete “{name}”?",
20
20
  deleteBankAccountTitle: "Delete bank account “{account}”?",
21
- deleteCounterpartMessage: "This counterpart and its contacts, bank accounts, and VAT IDs will be permanently removed. You can't undo this action.",
21
+ deleteCounterpartMessage: "This record and its contacts, bank accounts, and tax ID will be permanently removed. You can't undo this action.",
22
22
  deleteBankAccountMessage: "This removes these payment instructions from the vendor. The vendor will not be deleted. You can't undo this action."
23
23
  };
24
24
  //#endregion
@@ -7,48 +7,71 @@ import { useCreateCounterpartMutation as t, useUpdateCounterpartMutation as n }
7
7
  import { useCreateCounterpartBankAccountMutation as r, useUpdateCounterpartBankAccountMutation as i } from "../../../data-access/dist/index5.js";
8
8
  import { useCreateCounterpartAddressMutation as a, useUpdateCounterpartAddressMutation as o } from "../../../data-access/dist/index7.js";
9
9
  import "../../../data-access/dist/index.js";
10
- import { addressFormToCreatePayload as s, addressFormToUpdatePayload as c, addressResponseToFormValues as l, counterpartFormBankAccountToCreatePayload as u, counterpartFormBankAccountToUpdatePayload as d, counterpartFormToCreatePayload as f, counterpartFormToUpdatePayload as p, counterpartToFormValues as m, emptyCounterpartFormValues as h, getAchInstructions as g, hasCounterpartFormAddressValues as _, hasCounterpartFormBankAccountValues as v, hasCounterpartFormErrors as ee, resolveCounterpartBankAccountWrite as y, validateCounterpartForm as b } from "./helpers.js";
11
- import { useCallback as x, useState as S } from "react";
10
+ import { addressFormToCreatePayload as s, addressFormToUpdatePayload as c, addressResponseToFormValues as l, counterpartFormBankAccountToCreatePayload as u, counterpartFormBankAccountToUpdatePayload as ee, counterpartFormToCreatePayload as te, counterpartFormToUpdatePayload as d, counterpartToFormValues as f, emptyCounterpartFormValues as p, getAchInstructions as m, hasCounterpartFormAddressValues as h, hasCounterpartFormBankAccountValues as g, hasCounterpartFormErrors as _, resolveCounterpartBankAccountWrite as v, validateCounterpartForm as y } from "./helpers.js";
11
+ import { useCallback as b, useState as x } from "react";
12
12
  //#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js
13
- function C(e, t) {
14
- if (!t) return _(e);
13
+ function S(e, t) {
14
+ if (!t) return h(e);
15
15
  let n = l(t);
16
16
  return e.address.line1.trim() !== n.line1.trim() || e.address.line2.trim() !== n.line2.trim() || e.address.city.trim() !== n.city.trim() || e.address.state.trim() !== n.state.trim() || e.address.postalCode.trim() !== n.postalCode.trim();
17
17
  }
18
- function w(e) {
18
+ function C(e) {
19
19
  return {
20
20
  accountHolderName: e.account_holder_name ?? "",
21
21
  routingNumber: e.routing_number ?? "",
22
22
  accountNumber: e.account_number ?? ""
23
23
  };
24
24
  }
25
- function T(e, t) {
26
- if (!t) return v(e);
27
- let n = w(t);
25
+ function w(e, t) {
26
+ if (!t) return g(e);
27
+ let n = C(t);
28
28
  return e.bankAccount.accountHolderName.trim() !== n.accountHolderName.trim() || e.bankAccount.routingNumber.trim() !== n.routingNumber.trim() || e.bankAccount.accountNumber.trim() !== n.accountNumber.trim();
29
29
  }
30
+ function T(e, t) {
31
+ let n = { ...e };
32
+ if ([
33
+ "legalName",
34
+ "firstName",
35
+ "lastName",
36
+ "email"
37
+ ].forEach((e) => {
38
+ n[e] && !t[e] && delete n[e];
39
+ }), e.address) {
40
+ let r = { ...e.address };
41
+ Object.keys(r).forEach((e) => {
42
+ r[e] && !t.address?.[e] && delete r[e];
43
+ }), n.address = Object.keys(r).length ? r : void 0;
44
+ }
45
+ if (e.bankAccount) {
46
+ let r = { ...e.bankAccount };
47
+ Object.keys(r).forEach((e) => {
48
+ r[e] && !t.bankAccount?.[e] && delete r[e];
49
+ }), n.bankAccount = Object.keys(r).length ? r : void 0;
50
+ }
51
+ return n;
52
+ }
30
53
  function E({ view: l, setView: E, selectedId: D, setSelectedId: O, messages: k, counterpartType: A, counterpart: j, primaryAddress: M, bankAccounts: N, isBankAccountsLoading: P, isBankAccountsError: F, includeBankAccount: I = !0 }) {
31
- let L = A === "vendor" && I, R = t(), z = a(), B = r(), V = n(), H = o(), U = i(), [W, G] = S(() => h()), [K, q] = S({}), [J, Y] = S({
54
+ let L = A === "vendor" && I, R = t(), z = a(), B = r(), V = n(), H = o(), U = i(), [W, G] = x(() => p()), [K, q] = x({}), [J, Y] = x({
32
55
  address: !1,
33
56
  bankAccount: !1
34
- }), [X, Z] = S(), [Q, $] = S(), te = R.isPending || z.isPending || B.isPending || U.isPending || V.isPending || H.isPending, ne = x(() => {
57
+ }), [X, Z] = x(), [Q, $] = x(), ne = R.isPending || z.isPending || B.isPending || U.isPending || V.isPending || H.isPending, re = b(() => {
35
58
  O(void 0), $(void 0), Z(void 0), Y({
36
59
  address: A === "vendor",
37
60
  bankAccount: !1
38
- }), G(h("organization", A)), q({}), E("create");
61
+ }), G(p("organization", A)), q({}), E("create");
39
62
  }, [
40
63
  A,
41
64
  O,
42
65
  E
43
- ]), re = x(() => {
66
+ ]), ie = b(() => {
44
67
  if (!j || L && (P || F)) return;
45
- let e = L ? g(N) : void 0, t = m(j, M);
68
+ let e = L ? m(N) : void 0, t = f(j, M);
46
69
  $(void 0), Z(e?.id), Y({
47
- address: _(t),
70
+ address: h(t),
48
71
  bankAccount: !1
49
72
  }), G({
50
73
  ...t,
51
- ...e ? { bankAccount: w(e) } : {}
74
+ ...e ? { bankAccount: C(e) } : {}
52
75
  }), q({}), E("edit");
53
76
  }, [
54
77
  N,
@@ -58,27 +81,38 @@ function E({ view: l, setView: E, selectedId: D, setSelectedId: O, messages: k,
58
81
  M,
59
82
  E,
60
83
  L
61
- ]), ie = x(() => {
84
+ ]), ae = b(() => {
62
85
  E("none");
63
- }, [E]);
86
+ }, [E]), oe = b(() => {
87
+ Y((e) => ({
88
+ ...e,
89
+ address: !0
90
+ }));
91
+ }, []);
64
92
  return {
65
93
  values: W,
66
94
  errors: K,
67
- setValues: G,
68
- isSubmitting: te,
95
+ setValues: b((e) => {
96
+ G((t) => {
97
+ let n = typeof e == "function" ? e(t) : e;
98
+ return q((e) => _(e) ? T(e, y(n, l === "edit" ? "edit" : "create", k, A, l === "edit" && L && !!X)) : e), n;
99
+ });
100
+ }, [
101
+ X,
102
+ A,
103
+ k,
104
+ l,
105
+ L
106
+ ]),
107
+ isSubmitting: ne,
69
108
  sectionsToExpand: J,
70
- expandAddress: x(() => {
71
- Y((e) => ({
72
- ...e,
73
- address: !0
74
- }));
75
- }, []),
76
- openCreate: ne,
77
- openEdit: re,
78
- close: ie,
79
- submit: x(async () => {
80
- let t = l === "edit" ? "edit" : "create", n = b(W, t, k, A, t === "edit" && L && !!X);
81
- if (ee(n)) return q(n), Y((e) => ({
109
+ expandAddress: oe,
110
+ openCreate: re,
111
+ openEdit: ie,
112
+ close: ae,
113
+ submit: b(async () => {
114
+ let t = l === "edit" ? "edit" : "create", n = y(W, t, k, A, t === "edit" && L && !!X);
115
+ if (_(n)) return q(n), Y((e) => ({
82
116
  address: e.address || !!n.address,
83
117
  bankAccount: e.bankAccount || !!n.bankAccount
84
118
  })), { ok: !1 };
@@ -91,23 +125,23 @@ function E({ view: l, setView: E, selectedId: D, setSelectedId: O, messages: k,
91
125
  if (l === "edit" && D) {
92
126
  $(void 0), await V.mutateAsync({
93
127
  path: { counterpart_id: D },
94
- body: p(W, A)
128
+ body: d(W, A)
95
129
  });
96
- let e = M ? C(W, M) ? H.mutateAsync({
130
+ let e = M ? S(W, M) ? H.mutateAsync({
97
131
  path: {
98
132
  counterpart_id: D,
99
133
  address_id: M.id
100
134
  },
101
135
  body: c(W.address)
102
- }) : void 0 : _(W) ? z.mutateAsync({
136
+ }) : void 0 : h(W) ? z.mutateAsync({
103
137
  path: { counterpart_id: D },
104
138
  body: s(W.address)
105
- }) : void 0, t = L && T(W, g(N)) ? y(N, X) : void 0, n = t?.kind === "update" ? U.mutateAsync({
139
+ }) : void 0, t = L && w(W, m(N)) ? v(N, X) : void 0, n = t?.kind === "update" ? U.mutateAsync({
106
140
  path: {
107
141
  counterpart_id: D,
108
142
  bank_account_id: t.bankAccountId
109
143
  },
110
- body: d(W.bankAccount, { includeAchDefaults: t.includeAchDefaults })
144
+ body: ee(W.bankAccount, { includeAchDefaults: t.includeAchDefaults })
111
145
  }) : t?.kind === "create" ? B.mutateAsync({
112
146
  path: { counterpart_id: D },
113
147
  body: u(W.bankAccount, { isDefaultForCurrency: t.isDefaultForCurrency })
@@ -119,7 +153,7 @@ function E({ view: l, setView: E, selectedId: D, setSelectedId: O, messages: k,
119
153
  counterpartId: D
120
154
  };
121
155
  }
122
- return r ||= (await R.mutateAsync({ body: f(W, A) }))?.id, r && L && v(W) && ($(r), await B.mutateAsync({
156
+ return r ||= (await R.mutateAsync({ body: te(W, A) }))?.id, r && L && g(W) && ($(r), await B.mutateAsync({
123
157
  path: { counterpart_id: r },
124
158
  body: u(W.bankAccount)
125
159
  })), $(void 0), E("none"), r && O(r), {
@@ -57,7 +57,7 @@ var n = {
57
57
  paymentRemindersLabel: "Payment reminders",
58
58
  paymentRemindersDescription: "Send automatic reminders for unpaid customer invoices.",
59
59
  paymentMethodsHeading: "Accepted payment methods",
60
- paymentMethodsDescription: "Optional ACH bank transfer details for this vendor.",
60
+ paymentMethodsDescription: "ACH bank transfer details for this vendor.",
61
61
  accountHolderNameLabel: "Account holder name",
62
62
  routingNumberLabel: "Routing number",
63
63
  accountNumberLabel: "Account number",
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.5.65", n = "35433d9cf705a72a3f408bcd151b358ad3b88449", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.5.68", n = "9254e7ccf1a0171056396b0f52a95a5e35e14260", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.5.65",
3
+ "version": "0.5.68",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {