@tesouro/embedded-components-react 0.11.65 → 0.11.66
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.
- package/README.md +14 -14
- package/dist/index.css +6 -24
- package/dist/index.d.ts +27 -39
- package/dist/lib/CounterpartsWidget.d.ts +26 -39
- package/dist/lib/CounterpartsWidgetPublic.d.ts +26 -39
- package/dist/lib/CustomersWidget.d.ts +26 -39
- package/dist/lib/ReceivablesWidget.d.ts +14 -4
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsContainer.js +8 -12
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsPanel.js +93 -110
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartsWidget.js +52 -52
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsActions.js +72 -107
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsSheetView.js +27 -27
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsTable.js +112 -145
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js +13 -16
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/viewModels.js +3 -122
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/mocks/labels.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index2.js +44 -65
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index3.js +157 -134
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index4.js +18 -14
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index5.js +362 -55
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +16 -9
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useAddressForm.js +2 -66
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useDeleteController.js +48 -46
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index10.js +138 -149
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index11.js +19 -20
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index12.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index13.js +21 -27
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index3.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index8.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index9.js +30 -63
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index6.js +0 -211
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index7.js +0 -509
|
@@ -4,124 +4,89 @@
|
|
|
4
4
|
"use client";
|
|
5
5
|
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
6
|
import "../../../../../shared/ui/dist/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { useBankAccountForm as s } from "../../../../../shared/counterpart-management/feature/dist/lib/subEntityForms.js";
|
|
7
|
+
import { bankAccountToAchFormValues as t, counterpartToFormValues as n } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
8
|
+
import { useCounterpartForm as r } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
9
|
+
import { useDeleteController as i } from "../../../../../shared/counterpart-management/feature/dist/lib/useDeleteController.js";
|
|
10
|
+
import { useBankAccountForm as a } from "../../../../../shared/counterpart-management/feature/dist/lib/subEntityForms.js";
|
|
12
11
|
import "../../../../../shared/counterpart-management/feature/dist/index.js";
|
|
13
|
-
import { useRebaseOnRefresh as
|
|
14
|
-
import { useCallback as
|
|
12
|
+
import { useRebaseOnRefresh as o } from "./useRebaseOnRefresh.js";
|
|
13
|
+
import { useCallback as s, useMemo as c } from "react";
|
|
15
14
|
// ../../libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsActions.js
|
|
16
|
-
|
|
17
|
-
line1: "",
|
|
18
|
-
line2: "",
|
|
19
|
-
city: "",
|
|
20
|
-
state: "",
|
|
21
|
-
postalCode: ""
|
|
22
|
-
};
|
|
23
|
-
function f(e, t) {
|
|
15
|
+
function l(e, t) {
|
|
24
16
|
return e.line1 === t.line1 && e.line2 === t.line2 && e.city === t.city && e.state === t.state && e.postalCode === t.postalCode;
|
|
25
17
|
}
|
|
26
|
-
function p
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
selectedId:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
detailsView: y.detailsView,
|
|
52
|
-
messages: b
|
|
53
|
-
}), E = u(() => {
|
|
54
|
-
if (!y.counterpart) return;
|
|
55
|
-
let e = r(y.counterpart, y.primaryAddress);
|
|
56
|
-
return x ? {
|
|
57
|
-
...e,
|
|
58
|
-
address: d
|
|
59
|
-
} : e;
|
|
60
|
-
}, [
|
|
61
|
-
y.counterpart,
|
|
62
|
-
y.primaryAddress,
|
|
63
|
-
x
|
|
64
|
-
]), D = u(() => y.primaryAddress ? t(y.primaryAddress) : d, [y.primaryAddress]), O = u(() => {
|
|
65
|
-
if (C.form.sheet.mode !== "edit") return;
|
|
66
|
-
let e = y.bankAccounts?.find((e) => e.id === C.form.sheet.id);
|
|
67
|
-
return e ? n(e) : void 0;
|
|
18
|
+
function u({ counterpartType: u, selectedId: d, setSelectedId: f, view: p, setView: m, details: h, messages: g }) {
|
|
19
|
+
let _ = r({
|
|
20
|
+
view: p,
|
|
21
|
+
setView: m,
|
|
22
|
+
selectedId: d,
|
|
23
|
+
setSelectedId: f,
|
|
24
|
+
messages: g,
|
|
25
|
+
counterpartType: u,
|
|
26
|
+
counterpart: h.counterpart,
|
|
27
|
+
primaryAddress: h.primaryAddress,
|
|
28
|
+
includeBankAccount: p === "create"
|
|
29
|
+
}), v = a({
|
|
30
|
+
items: h.bankAccounts,
|
|
31
|
+
selectedId: d,
|
|
32
|
+
messages: g
|
|
33
|
+
}), y = i({
|
|
34
|
+
selectedId: d,
|
|
35
|
+
setSelectedId: f,
|
|
36
|
+
detailsView: h.detailsView,
|
|
37
|
+
messages: g,
|
|
38
|
+
counterpartType: u
|
|
39
|
+
}), b = c(() => h.counterpart ? n(h.counterpart, h.primaryAddress) : void 0, [h.counterpart, h.primaryAddress]), x = c(() => {
|
|
40
|
+
if (v.form.sheet.mode !== "edit") return;
|
|
41
|
+
let e = h.bankAccounts?.find((e) => e.id === v.form.sheet.id);
|
|
42
|
+
return e ? t(e) : void 0;
|
|
68
43
|
}, [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
v.form.sheet.id,
|
|
45
|
+
v.form.sheet.mode,
|
|
46
|
+
h.bankAccounts
|
|
72
47
|
]);
|
|
73
|
-
|
|
74
|
-
open:
|
|
75
|
-
seed:
|
|
76
|
-
setValues:
|
|
77
|
-
}),
|
|
78
|
-
open:
|
|
79
|
-
seed:
|
|
80
|
-
setValues:
|
|
81
|
-
}),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!
|
|
88
|
-
let
|
|
89
|
-
return
|
|
90
|
-
}, [
|
|
91
|
-
E,
|
|
92
|
-
S.values,
|
|
93
|
-
x
|
|
94
|
-
]), A = u(() => !f(w.values, D), [w.values, D]), { close: j } = w, { openEdit: M, setValues: N, submit: P, values: F } = S, I = l(async () => {
|
|
95
|
-
let t = _ === "edit" ? b.updateSucceeded : b.createSucceeded, n = p(F), r = await P();
|
|
96
|
-
return r.ok && e.success(t.replace("{name}", () => n)), r;
|
|
48
|
+
o({
|
|
49
|
+
open: p === "edit",
|
|
50
|
+
seed: b,
|
|
51
|
+
setValues: _.setValues
|
|
52
|
+
}), o({
|
|
53
|
+
open: v.form.sheet.open,
|
|
54
|
+
seed: x,
|
|
55
|
+
setValues: v.form.setValues
|
|
56
|
+
}), v.form.sheet.open && v.form.sheet.mode === "edit" && h.bankAccounts !== void 0 && !h.isBankAccountsFetching && !x && v.form.close();
|
|
57
|
+
let S = c(() => {
|
|
58
|
+
if (!b) return !1;
|
|
59
|
+
let e = _.values;
|
|
60
|
+
return e.legalName !== b.legalName || e.firstName !== b.firstName || e.lastName !== b.lastName || e.email !== b.email || e.phone !== b.phone || e.taxId !== b.taxId || e.remindersEnabled !== b.remindersEnabled || !l(e.address, b.address);
|
|
61
|
+
}, [b, _.values]), { close: C, openEdit: w, submit: T } = _, E = s(async () => {
|
|
62
|
+
if (p === "edit" && !S) return C(), { ok: !0 };
|
|
63
|
+
let t = u === "vendor", n = p === "edit" ? t ? g.vendorUpdated : g.customerUpdated : t ? g.vendorAdded : g.customerAdded, r = await T();
|
|
64
|
+
return r.ok && e.success(n), r;
|
|
97
65
|
}, [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}))) : (j(), M());
|
|
66
|
+
p,
|
|
67
|
+
S,
|
|
68
|
+
C,
|
|
69
|
+
g,
|
|
70
|
+
u,
|
|
71
|
+
T
|
|
72
|
+
]), { close: D, submit: O } = v.form, k = s(() => {
|
|
73
|
+
v.form.sheet.mode === "edit" && !v.isDirty ? D() : O();
|
|
107
74
|
}, [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
75
|
+
v.form.sheet.mode,
|
|
76
|
+
v.isDirty,
|
|
77
|
+
D,
|
|
78
|
+
O
|
|
112
79
|
]);
|
|
113
80
|
return {
|
|
114
81
|
form: {
|
|
115
|
-
...
|
|
116
|
-
submit:
|
|
82
|
+
..._,
|
|
83
|
+
submit: E
|
|
117
84
|
},
|
|
118
|
-
bank:
|
|
119
|
-
|
|
120
|
-
del:
|
|
121
|
-
isEditDirty:
|
|
122
|
-
|
|
123
|
-
closeAddress: j,
|
|
124
|
-
handleEditProfile: L
|
|
85
|
+
bank: v,
|
|
86
|
+
submitBankAccount: k,
|
|
87
|
+
del: y,
|
|
88
|
+
isEditDirty: S,
|
|
89
|
+
handleEditProfile: w
|
|
125
90
|
};
|
|
126
91
|
}
|
|
127
|
-
export {
|
|
92
|
+
export { u as useCounterpartDetailsActions };
|
|
@@ -5,45 +5,45 @@
|
|
|
5
5
|
import { buildAnalyticsMap as e, formatMoney as t } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
6
6
|
import { useCounterpartDetails as n } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
|
|
7
7
|
import "../../../../../shared/counterpart-management/feature/dist/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { useRecentPayablesByCounterpartQuery as m, useRecentReceivablesByCounterpartQuery as h } from "../../../../data-access/dist/index3.js";
|
|
8
|
+
import { PAYABLES_BILLED_STATUSES as r, PAYABLES_OWED_STATUSES as i, PAYABLES_REJECTED_STATUSES as a, RECEIVABLES_BILLED_STATUSES as o, RECEIVABLES_DUE_STATUSES as s } from "./constants.js";
|
|
9
|
+
import { usePayablesAnalyticsByCounterpartQuery as c, useReceivablesAnalyticsByCounterpartQuery as l } from "../../../../data-access/dist/index2.js";
|
|
10
|
+
import { useRecentPayablesByCounterpartQuery as u, useRecentReceivablesByCounterpartQuery as d } from "../../../../data-access/dist/index3.js";
|
|
12
11
|
import "../../../../data-access/dist/index.js";
|
|
12
|
+
import { buildPaymentMethodView as f, buildRecentDocumentRows as p, formatDetailsDate as m, maskTaxId as h } from "./viewModels.js";
|
|
13
13
|
import { useMemo as g } from "react";
|
|
14
14
|
// ../../libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsSheetView.js
|
|
15
15
|
function _({ selectedId: _, isCustomer: v, enabled: y, detailsText: b }) {
|
|
16
16
|
let x = n({
|
|
17
17
|
selectedId: _,
|
|
18
18
|
enabled: y
|
|
19
|
-
}), S = g(() => _ ? [_] : [], [_]), C = S.length > 0, w =
|
|
19
|
+
}), S = g(() => _ ? [_] : [], [_]), C = S.length > 0, w = l({
|
|
20
20
|
type: "invoice",
|
|
21
|
-
statusIn: [...
|
|
21
|
+
statusIn: [...o],
|
|
22
22
|
counterpartIdIn: S,
|
|
23
23
|
enabled: y && v && C
|
|
24
|
-
}), T =
|
|
24
|
+
}), T = l({
|
|
25
25
|
metric: "amount_due",
|
|
26
26
|
type: "invoice",
|
|
27
|
-
statusIn: [...
|
|
27
|
+
statusIn: [...s],
|
|
28
28
|
counterpartIdIn: S,
|
|
29
29
|
enabled: y && v && C
|
|
30
|
-
}), E =
|
|
31
|
-
statusIn: [...
|
|
30
|
+
}), E = c({
|
|
31
|
+
statusIn: [...r],
|
|
32
32
|
counterpartIdIn: S,
|
|
33
33
|
enabled: y && !v && C
|
|
34
|
-
}), D =
|
|
34
|
+
}), D = c({
|
|
35
35
|
metric: "amount_due",
|
|
36
|
-
statusIn: [...
|
|
36
|
+
statusIn: [...i],
|
|
37
37
|
counterpartIdIn: S,
|
|
38
38
|
enabled: y && !v && C
|
|
39
|
-
}), O =
|
|
40
|
-
statusIn: [...
|
|
39
|
+
}), O = c({
|
|
40
|
+
statusIn: [...a],
|
|
41
41
|
counterpartIdIn: S,
|
|
42
42
|
enabled: y && !v && C
|
|
43
|
-
}), k =
|
|
43
|
+
}), k = d({
|
|
44
44
|
counterpartId: _,
|
|
45
45
|
enabled: y && v && C
|
|
46
|
-
}), A =
|
|
46
|
+
}), A = u({
|
|
47
47
|
counterpartId: _,
|
|
48
48
|
enabled: y && !v && C
|
|
49
49
|
});
|
|
@@ -51,24 +51,24 @@ function _({ selectedId: _, isCustomer: v, enabled: y, detailsText: b }) {
|
|
|
51
51
|
details: x,
|
|
52
52
|
detailsSheetView: g(() => {
|
|
53
53
|
if (!x.detailsView || !_) return;
|
|
54
|
-
let n = e(v ? w.data?.data : E.data?.data),
|
|
54
|
+
let n = e(v ? w.data?.data : E.data?.data), r = e(v ? T.data?.data : D.data?.data), i = n.get(_) ?? 0, a = r.get(_) ?? 0, o = i - a, s = v ? w.isLoading : E.isLoading, c = v ? T.isLoading : D.isLoading, l = e(O.data?.data), u = v ? 0 : l.get(_) ?? 0, d = v ? k.data?.data : A.data?.data, g = f(x.bankAccounts, b.paymentMethodTitle), y = v ? b.customerSubtitleLabel : b.vendorSubtitleLabel;
|
|
55
55
|
return {
|
|
56
56
|
...x.detailsView,
|
|
57
|
-
subtitle: b.subtitleTemplate.replace("{type}", y).replace("{date}",
|
|
57
|
+
subtitle: b.subtitleTemplate.replace("{type}", y).replace("{date}", m(x.counterpart?.created_at)),
|
|
58
58
|
entityTypeLabel: x.detailsView.entityType === "individual" ? b.entityTypePersonLabel : b.entityTypeBusinessLabel,
|
|
59
|
-
taxIdMasked:
|
|
59
|
+
taxIdMasked: h(x.detailsView.taxId),
|
|
60
60
|
remindersLabel: x.counterpart?.reminders_enabled ? b.remindersEnabledLabel : b.remindersDisabledLabel,
|
|
61
61
|
summary: {
|
|
62
|
-
primaryAmountLabel: t(
|
|
63
|
-
billedAmountLabel: t(
|
|
64
|
-
receivedOrPaidAmountLabel: t(
|
|
65
|
-
rejectedAmountLabel: v ? void 0 : t(
|
|
66
|
-
isPrimaryAmountLoading:
|
|
67
|
-
isBilledAmountLoading:
|
|
68
|
-
isReceivedOrPaidAmountLoading:
|
|
62
|
+
primaryAmountLabel: t(a),
|
|
63
|
+
billedAmountLabel: t(i),
|
|
64
|
+
receivedOrPaidAmountLabel: t(o),
|
|
65
|
+
rejectedAmountLabel: v ? void 0 : t(u),
|
|
66
|
+
isPrimaryAmountLoading: c,
|
|
67
|
+
isBilledAmountLoading: s,
|
|
68
|
+
isReceivedOrPaidAmountLoading: s || c,
|
|
69
69
|
isRejectedAmountLoading: v ? void 0 : O.isLoading
|
|
70
70
|
},
|
|
71
|
-
recentDocuments:
|
|
71
|
+
recentDocuments: p(d, v ? "invoice" : "bill", b),
|
|
72
72
|
paymentMethod: g
|
|
73
73
|
};
|
|
74
74
|
}, [
|
|
@@ -2,167 +2,134 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import "../../../../../shared/
|
|
7
|
-
import {
|
|
8
|
-
import { useCounterpartsQuery as i } from "../../../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
9
|
-
import { useCounterpartAddressesForRowsQuery as a } from "../../../../../shared/counterpart-management/data-access/dist/index5.js";
|
|
5
|
+
import { buildAnalyticsMap as e, buildCounterpartRows as t } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
6
|
+
import { useCounterpartsQuery as n } from "../../../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
7
|
+
import { useCounterpartAddressesForRowsQuery as r } from "../../../../../shared/counterpart-management/data-access/dist/index5.js";
|
|
10
8
|
import "../../../../../shared/counterpart-management/feature/dist/index.js";
|
|
11
|
-
import { PAGE_SIZE_OPTIONS as
|
|
12
|
-
import { usePayablesAnalyticsByCounterpartQuery as
|
|
9
|
+
import { PAGE_SIZE_OPTIONS as i, PAYABLES_BILLED_STATUSES as a, PAYABLES_OWED_STATUSES as o, RECEIVABLES_BILLED_STATUSES as s, RECEIVABLES_DUE_STATUSES as c, TYPE_FILTER_OPTIONS as ee } from "./constants.js";
|
|
10
|
+
import { usePayablesAnalyticsByCounterpartQuery as l, useReceivablesAnalyticsByCounterpartQuery as u } from "../../../../data-access/dist/index2.js";
|
|
13
11
|
import "../../../../data-access/dist/index.js";
|
|
14
|
-
import { useCallback as
|
|
12
|
+
import { useCallback as d, useEffect as f, useMemo as p, useState as m } from "react";
|
|
15
13
|
// ../../libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsTable.js
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function _({ isCustomer: _, enabled: v = !0, pageSizeOptions: y = o, messages: b, labels: x }) {
|
|
21
|
-
let [S, C] = h([]), [w, ne] = h(y[0] ?? 10), [re, T] = h(), [E, D] = h(""), [O, k] = h(""), [A, j] = h([]), M = A.length === 1 ? A[0] : void 0, N = t();
|
|
22
|
-
p(() => {
|
|
23
|
-
if (E === O) return;
|
|
14
|
+
function h({ isCustomer: h, enabled: g = !0, pageSizeOptions: _ = i, labels: v }) {
|
|
15
|
+
let [y, b] = m([]), [x, S] = m(_[0] ?? 10), [C, w] = m(), [T, E] = m(""), [D, O] = m(""), [k, A] = m(""), j = k || void 0;
|
|
16
|
+
f(() => {
|
|
17
|
+
if (T === D) return;
|
|
24
18
|
let e = setTimeout(() => {
|
|
25
|
-
|
|
19
|
+
O(T), w(void 0);
|
|
26
20
|
}, 400);
|
|
27
21
|
return () => clearTimeout(e);
|
|
28
|
-
}, [
|
|
29
|
-
let
|
|
30
|
-
sort:
|
|
31
|
-
order:
|
|
32
|
-
limit:
|
|
33
|
-
pagination_token:
|
|
34
|
-
counterpart_name__icontains:
|
|
35
|
-
type:
|
|
36
|
-
...
|
|
37
|
-
enabled:
|
|
38
|
-
}),
|
|
39
|
-
counterpartIds:
|
|
40
|
-
enabled:
|
|
41
|
-
}),
|
|
22
|
+
}, [T, D]);
|
|
23
|
+
let M = y[0], N = n({
|
|
24
|
+
sort: M ? "counterpart_name" : void 0,
|
|
25
|
+
order: M ? M.desc ? "desc" : "asc" : void 0,
|
|
26
|
+
limit: x,
|
|
27
|
+
pagination_token: C,
|
|
28
|
+
counterpart_name__icontains: D || void 0,
|
|
29
|
+
type: j,
|
|
30
|
+
...h ? { is_customer: !0 } : { is_vendor: !0 },
|
|
31
|
+
enabled: g
|
|
32
|
+
}), P = p(() => N.data?.data.map((e) => e.id) ?? [], [N.data?.data]), F = P.length > 0, I = r({
|
|
33
|
+
counterpartIds: P,
|
|
34
|
+
enabled: g && F
|
|
35
|
+
}), L = u({
|
|
42
36
|
type: "invoice",
|
|
43
37
|
statusIn: [...s],
|
|
44
|
-
counterpartIdIn:
|
|
45
|
-
enabled:
|
|
46
|
-
}),
|
|
38
|
+
counterpartIdIn: P,
|
|
39
|
+
enabled: g && h && F
|
|
40
|
+
}), R = u({
|
|
47
41
|
metric: "amount_due",
|
|
48
42
|
type: "invoice",
|
|
49
43
|
statusIn: [...c],
|
|
50
|
-
counterpartIdIn:
|
|
51
|
-
enabled:
|
|
52
|
-
}),
|
|
53
|
-
statusIn: [...
|
|
54
|
-
counterpartIdIn:
|
|
55
|
-
enabled:
|
|
56
|
-
}),
|
|
44
|
+
counterpartIdIn: P,
|
|
45
|
+
enabled: g && h && F
|
|
46
|
+
}), z = l({
|
|
47
|
+
statusIn: [...a],
|
|
48
|
+
counterpartIdIn: P,
|
|
49
|
+
enabled: g && !h && F
|
|
50
|
+
}), B = l({
|
|
57
51
|
metric: "amount_due",
|
|
58
|
-
statusIn: [...
|
|
59
|
-
counterpartIdIn:
|
|
60
|
-
enabled:
|
|
61
|
-
}),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
]),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
]),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
isDueOrOwedAmountLoading: W === void 0,
|
|
84
|
-
isBilledAmountError: K,
|
|
85
|
-
isDueOrOwedAmountError: q
|
|
86
|
-
}).map((e) => {
|
|
87
|
-
let t = (U?.get(e.id) ?? 0) - (W?.get(e.id) ?? 0);
|
|
88
|
-
return {
|
|
89
|
-
...e,
|
|
90
|
-
name: e.name || x.unnamedCounterpart,
|
|
91
|
-
isReceivedOrPaidPositive: t > 0
|
|
92
|
-
};
|
|
93
|
-
}), [
|
|
94
|
-
F.data?.data,
|
|
95
|
-
G,
|
|
52
|
+
statusIn: [...o],
|
|
53
|
+
counterpartIdIn: P,
|
|
54
|
+
enabled: g && !h && F
|
|
55
|
+
}), V = p(() => h ? L.data ? e(L.data.data) : void 0 : z.data ? e(z.data.data) : void 0, [
|
|
56
|
+
h,
|
|
57
|
+
L.data,
|
|
58
|
+
z.data
|
|
59
|
+
]), H = p(() => h ? R.data ? e(R.data.data) : void 0 : B.data ? e(B.data.data) : void 0, [
|
|
60
|
+
h,
|
|
61
|
+
R.data,
|
|
62
|
+
B.data
|
|
63
|
+
]), U = p(() => new Map(P.map((e, t) => [e, I[t]?.data?.data?.[0]])), [P, I]), W = h ? L.isError : z.isError, G = h ? R.isError : B.isError, K = p(() => t({
|
|
64
|
+
counterparts: N.data?.data ?? [],
|
|
65
|
+
addresses: U,
|
|
66
|
+
billedAmounts: V,
|
|
67
|
+
dueOrOwedAmounts: H,
|
|
68
|
+
isBilledAmountLoading: V === void 0,
|
|
69
|
+
isDueOrOwedAmountLoading: H === void 0,
|
|
70
|
+
isBilledAmountError: W,
|
|
71
|
+
isDueOrOwedAmountError: G
|
|
72
|
+
}).map((e) => ({
|
|
73
|
+
...e,
|
|
74
|
+
name: e.name || v.unnamedCounterpart
|
|
75
|
+
})), [
|
|
76
|
+
N.data?.data,
|
|
96
77
|
U,
|
|
78
|
+
V,
|
|
79
|
+
H,
|
|
97
80
|
W,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
]), Y = m(() => l.map((e) => ({
|
|
81
|
+
G,
|
|
82
|
+
v.unnamedCounterpart
|
|
83
|
+
]), q = p(() => ee.map((e) => ({
|
|
102
84
|
value: e,
|
|
103
|
-
label: e === "individual" ?
|
|
104
|
-
})), [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
searchValue: E,
|
|
134
|
-
onSearchChange: D,
|
|
135
|
-
isPopoverOpen: N.isMenuOpen || !!N.activePanelId,
|
|
136
|
-
isMenuOpen: N.isMenuOpen,
|
|
137
|
-
isTypePanelOpen: N.activePanelId === g.Type,
|
|
138
|
-
onMenuToggle: N.toggleMenu,
|
|
139
|
-
onPopoverClose: () => {
|
|
140
|
-
N.closeMenu(), N.closePanel();
|
|
141
|
-
},
|
|
142
|
-
onTypeFieldSelect: () => N.openPanel(g.Type),
|
|
143
|
-
activeFilterCount: X.length,
|
|
144
|
-
chips: X,
|
|
145
|
-
onRemoveChip: le,
|
|
146
|
-
onClearAll: ue,
|
|
147
|
-
typeOptions: Y,
|
|
148
|
-
selectedTypes: A,
|
|
149
|
-
onTypeChange: Q
|
|
85
|
+
label: e === "individual" ? v.entityFilterIndividual : v.entityFilterOrganization
|
|
86
|
+
})), [v.entityFilterIndividual, v.entityFilterOrganization]), J = !!(D || j), Y = d((e) => {
|
|
87
|
+
b((t) => typeof e == "function" ? e(t) : e), w(void 0);
|
|
88
|
+
}, []), X = d((e) => {
|
|
89
|
+
S(e), w(void 0);
|
|
90
|
+
}, []), Z = d(() => w(N.data?.next_pagination_token ?? void 0), [N.data?.next_pagination_token]), Q = d(() => w(N.data?.prev_pagination_token ?? void 0), [N.data?.prev_pagination_token]), te = d(() => {
|
|
91
|
+
N.refetch();
|
|
92
|
+
}, [N]), ne = d((e) => {
|
|
93
|
+
A(e), w(void 0);
|
|
94
|
+
}, []), $ = d(() => {
|
|
95
|
+
E(""), O(""), A(""), w(void 0);
|
|
96
|
+
}, []), re = d((e) => {
|
|
97
|
+
e === "search" ? (E(""), O("")) : e === "type" && A(""), w(void 0);
|
|
98
|
+
}, []), ie = h ? [L, R] : [z, B], ae = () => {
|
|
99
|
+
for (let e of ie) e.isError && e.refetch();
|
|
100
|
+
}, oe = {
|
|
101
|
+
searchValue: T,
|
|
102
|
+
onSearchChange: E,
|
|
103
|
+
typeOptions: q,
|
|
104
|
+
selectedType: k,
|
|
105
|
+
onTypeChange: ne,
|
|
106
|
+
chips: [...D ? [{
|
|
107
|
+
key: "search",
|
|
108
|
+
label: v.searchChip(D)
|
|
109
|
+
}] : [], ...k ? [{
|
|
110
|
+
key: "type",
|
|
111
|
+
label: v.typeChip(q.find((e) => e.value === k)?.label ?? k)
|
|
112
|
+
}] : []],
|
|
113
|
+
onRemoveChip: re,
|
|
114
|
+
onClearAll: $
|
|
150
115
|
};
|
|
151
116
|
return {
|
|
152
|
-
rows:
|
|
153
|
-
isLoading:
|
|
154
|
-
isError:
|
|
155
|
-
sorting:
|
|
156
|
-
onSortingChange:
|
|
157
|
-
pageSize:
|
|
158
|
-
onPageSizeChange:
|
|
159
|
-
hasNextPage: !!
|
|
160
|
-
hasPrevPage: !!
|
|
161
|
-
onNextPage:
|
|
162
|
-
onPrevPage:
|
|
163
|
-
filters:
|
|
164
|
-
isFiltering:
|
|
165
|
-
|
|
117
|
+
rows: K,
|
|
118
|
+
isLoading: N.isLoading,
|
|
119
|
+
isError: N.isError,
|
|
120
|
+
sorting: y,
|
|
121
|
+
onSortingChange: Y,
|
|
122
|
+
pageSize: x,
|
|
123
|
+
onPageSizeChange: X,
|
|
124
|
+
hasNextPage: !!N.data?.next_pagination_token,
|
|
125
|
+
hasPrevPage: !!N.data?.prev_pagination_token,
|
|
126
|
+
onNextPage: Z,
|
|
127
|
+
onPrevPage: Q,
|
|
128
|
+
filters: oe,
|
|
129
|
+
isFiltering: J,
|
|
130
|
+
isAmountsError: W || G,
|
|
131
|
+
onRetryAmounts: ae,
|
|
132
|
+
onRetry: te
|
|
166
133
|
};
|
|
167
134
|
}
|
|
168
|
-
export {
|
|
135
|
+
export { h as useCounterpartsTable };
|
|
@@ -41,22 +41,13 @@ function g({ counterpartType: g, pageSizeOptions: _, detailsLabels: v, messageLa
|
|
|
41
41
|
isCustomer: O,
|
|
42
42
|
enabled: j.canRead,
|
|
43
43
|
pageSizeOptions: _,
|
|
44
|
-
messages: T,
|
|
45
44
|
labels: D
|
|
46
45
|
}), { details: z, detailsSheetView: B } = d({
|
|
47
46
|
selectedId: L,
|
|
48
47
|
isCustomer: O,
|
|
49
48
|
enabled: j.canRead,
|
|
50
49
|
detailsText: E
|
|
51
|
-
})
|
|
52
|
-
counterpartType: g,
|
|
53
|
-
selectedId: L,
|
|
54
|
-
setSelectedId: P,
|
|
55
|
-
view: F,
|
|
56
|
-
setView: I,
|
|
57
|
-
details: z,
|
|
58
|
-
messages: T
|
|
59
|
-
}), { closeAddress: H } = V;
|
|
50
|
+
});
|
|
60
51
|
return {
|
|
61
52
|
stateOptions: A,
|
|
62
53
|
selectedId: L,
|
|
@@ -67,13 +58,19 @@ function g({ counterpartType: g, pageSizeOptions: _, detailsLabels: v, messageLa
|
|
|
67
58
|
detailsSheetView: B,
|
|
68
59
|
permissions: j,
|
|
69
60
|
isPermissionLoading: M,
|
|
70
|
-
actions:
|
|
61
|
+
actions: u({
|
|
62
|
+
counterpartType: g,
|
|
63
|
+
selectedId: L,
|
|
64
|
+
setSelectedId: P,
|
|
65
|
+
view: F,
|
|
66
|
+
setView: I,
|
|
67
|
+
details: z,
|
|
68
|
+
messages: T
|
|
69
|
+
}),
|
|
71
70
|
handleRowClick: f((e) => {
|
|
72
|
-
j.canRead && !a() && (
|
|
73
|
-
}, [j.canRead
|
|
74
|
-
closeDetails: f(() =>
|
|
75
|
-
H(), P(void 0);
|
|
76
|
-
}, [H])
|
|
71
|
+
j.canRead && !a() && (P(e.id), I("none"));
|
|
72
|
+
}, [j.canRead]),
|
|
73
|
+
closeDetails: f(() => P(void 0), [])
|
|
77
74
|
};
|
|
78
75
|
}
|
|
79
76
|
export { g as useCounterpartsWidget };
|