@tesouro/embedded-components-react 0.7.31 → 0.7.34
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/dist/index.d.ts +14 -0
- package/dist/lib/CounterpartsWidget.d.ts +14 -0
- package/dist/lib/CounterpartsWidgetPublic.d.ts +14 -0
- package/dist/lib/CustomersWidget.d.ts +14 -0
- package/dist/lib/ReceivablesWidget.d.ts +14 -0
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsActions.js +107 -91
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +11 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/subEntityForms.js +36 -38
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useAddressForm.js +43 -41
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useDeleteController.js +40 -34
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4455,6 +4455,20 @@ interface CounterpartMessageLabels {
|
|
|
4455
4455
|
deleteBankAccountTitle: string;
|
|
4456
4456
|
deleteCounterpartMessage: string;
|
|
4457
4457
|
deleteBankAccountMessage: string;
|
|
4458
|
+
/** Success toast after creating a counterpart; `{name}` is replaced with its name. */
|
|
4459
|
+
createSucceeded: string;
|
|
4460
|
+
/** Success toast after editing a counterpart; `{name}` is replaced with its name. */
|
|
4461
|
+
updateSucceeded: string;
|
|
4462
|
+
addressAdded: string;
|
|
4463
|
+
addressUpdated: string;
|
|
4464
|
+
bankAccountAdded: string;
|
|
4465
|
+
bankAccountUpdated: string;
|
|
4466
|
+
counterpartDeleted: string;
|
|
4467
|
+
bankAccountDeleted: string;
|
|
4468
|
+
/** Error toast when a counterpart delete fails without an API message. */
|
|
4469
|
+
deleteCounterpartFailed: string;
|
|
4470
|
+
/** Error toast when a bank account delete fails without an API message. */
|
|
4471
|
+
deleteBankAccountFailed: string;
|
|
4458
4472
|
}
|
|
4459
4473
|
|
|
4460
4474
|
interface NoPolicyBannerLabels {
|
|
@@ -798,6 +798,20 @@ interface CounterpartMessageLabels {
|
|
|
798
798
|
deleteBankAccountTitle: string;
|
|
799
799
|
deleteCounterpartMessage: string;
|
|
800
800
|
deleteBankAccountMessage: string;
|
|
801
|
+
/** Success toast after creating a counterpart; `{name}` is replaced with its name. */
|
|
802
|
+
createSucceeded: string;
|
|
803
|
+
/** Success toast after editing a counterpart; `{name}` is replaced with its name. */
|
|
804
|
+
updateSucceeded: string;
|
|
805
|
+
addressAdded: string;
|
|
806
|
+
addressUpdated: string;
|
|
807
|
+
bankAccountAdded: string;
|
|
808
|
+
bankAccountUpdated: string;
|
|
809
|
+
counterpartDeleted: string;
|
|
810
|
+
bankAccountDeleted: string;
|
|
811
|
+
/** Error toast when a counterpart delete fails without an API message. */
|
|
812
|
+
deleteCounterpartFailed: string;
|
|
813
|
+
/** Error toast when a bank account delete fails without an API message. */
|
|
814
|
+
deleteBankAccountFailed: string;
|
|
801
815
|
}
|
|
802
816
|
|
|
803
817
|
/**
|
|
@@ -798,6 +798,20 @@ interface CounterpartMessageLabels {
|
|
|
798
798
|
deleteBankAccountTitle: string;
|
|
799
799
|
deleteCounterpartMessage: string;
|
|
800
800
|
deleteBankAccountMessage: string;
|
|
801
|
+
/** Success toast after creating a counterpart; `{name}` is replaced with its name. */
|
|
802
|
+
createSucceeded: string;
|
|
803
|
+
/** Success toast after editing a counterpart; `{name}` is replaced with its name. */
|
|
804
|
+
updateSucceeded: string;
|
|
805
|
+
addressAdded: string;
|
|
806
|
+
addressUpdated: string;
|
|
807
|
+
bankAccountAdded: string;
|
|
808
|
+
bankAccountUpdated: string;
|
|
809
|
+
counterpartDeleted: string;
|
|
810
|
+
bankAccountDeleted: string;
|
|
811
|
+
/** Error toast when a counterpart delete fails without an API message. */
|
|
812
|
+
deleteCounterpartFailed: string;
|
|
813
|
+
/** Error toast when a bank account delete fails without an API message. */
|
|
814
|
+
deleteBankAccountFailed: string;
|
|
801
815
|
}
|
|
802
816
|
|
|
803
817
|
/**
|
|
@@ -788,6 +788,20 @@ interface CounterpartMessageLabels {
|
|
|
788
788
|
deleteBankAccountTitle: string;
|
|
789
789
|
deleteCounterpartMessage: string;
|
|
790
790
|
deleteBankAccountMessage: string;
|
|
791
|
+
/** Success toast after creating a counterpart; `{name}` is replaced with its name. */
|
|
792
|
+
createSucceeded: string;
|
|
793
|
+
/** Success toast after editing a counterpart; `{name}` is replaced with its name. */
|
|
794
|
+
updateSucceeded: string;
|
|
795
|
+
addressAdded: string;
|
|
796
|
+
addressUpdated: string;
|
|
797
|
+
bankAccountAdded: string;
|
|
798
|
+
bankAccountUpdated: string;
|
|
799
|
+
counterpartDeleted: string;
|
|
800
|
+
bankAccountDeleted: string;
|
|
801
|
+
/** Error toast when a counterpart delete fails without an API message. */
|
|
802
|
+
deleteCounterpartFailed: string;
|
|
803
|
+
/** Error toast when a bank account delete fails without an API message. */
|
|
804
|
+
deleteBankAccountFailed: string;
|
|
791
805
|
}
|
|
792
806
|
|
|
793
807
|
/**
|
|
@@ -863,6 +863,20 @@ interface CounterpartMessageLabels {
|
|
|
863
863
|
deleteBankAccountTitle: string;
|
|
864
864
|
deleteCounterpartMessage: string;
|
|
865
865
|
deleteBankAccountMessage: string;
|
|
866
|
+
/** Success toast after creating a counterpart; `{name}` is replaced with its name. */
|
|
867
|
+
createSucceeded: string;
|
|
868
|
+
/** Success toast after editing a counterpart; `{name}` is replaced with its name. */
|
|
869
|
+
updateSucceeded: string;
|
|
870
|
+
addressAdded: string;
|
|
871
|
+
addressUpdated: string;
|
|
872
|
+
bankAccountAdded: string;
|
|
873
|
+
bankAccountUpdated: string;
|
|
874
|
+
counterpartDeleted: string;
|
|
875
|
+
bankAccountDeleted: string;
|
|
876
|
+
/** Error toast when a counterpart delete fails without an API message. */
|
|
877
|
+
deleteCounterpartFailed: string;
|
|
878
|
+
/** Error toast when a bank account delete fails without an API message. */
|
|
879
|
+
deleteBankAccountFailed: string;
|
|
866
880
|
}
|
|
867
881
|
|
|
868
882
|
interface ProductFormSheetLabels {
|
|
@@ -2,115 +2,131 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import "../../../../../shared/ui/dist/index.js";
|
|
7
|
+
import { addressResponseToFormValues as t, bankAccountToAchFormValues as n, counterpartToFormValues as r } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
8
|
+
import { useAddressForm as i } from "../../../../../shared/counterpart-management/feature/dist/lib/useAddressForm.js";
|
|
9
|
+
import { useCounterpartForm as a } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
10
|
+
import { useDeleteController as o } from "../../../../../shared/counterpart-management/feature/dist/lib/useDeleteController.js";
|
|
11
|
+
import { useBankAccountForm as s } from "../../../../../shared/counterpart-management/feature/dist/lib/subEntityForms.js";
|
|
10
12
|
import "../../../../../shared/counterpart-management/feature/dist/index.js";
|
|
11
|
-
import { useRebaseOnRefresh as
|
|
12
|
-
import { useCallback as
|
|
13
|
+
import { useRebaseOnRefresh as c } from "./useRebaseOnRefresh.js";
|
|
14
|
+
import { useCallback as l, useMemo as u } from "react";
|
|
13
15
|
//#region ../../libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsActions.js
|
|
14
|
-
var
|
|
16
|
+
var d = {
|
|
15
17
|
line1: "",
|
|
16
18
|
line2: "",
|
|
17
19
|
city: "",
|
|
18
20
|
state: "",
|
|
19
21
|
postalCode: ""
|
|
20
22
|
};
|
|
21
|
-
function
|
|
23
|
+
function f(e, t) {
|
|
22
24
|
return e.line1 === t.line1 && e.line2 === t.line2 && e.city === t.city && e.state === t.state && e.postalCode === t.postalCode;
|
|
23
25
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
selectedId:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
function p(e) {
|
|
27
|
+
return e.entityType === "organization" ? e.legalName.trim() : [e.firstName.trim(), e.lastName.trim()].filter(Boolean).join(" ");
|
|
28
|
+
}
|
|
29
|
+
function m({ counterpartType: m, selectedId: h, setSelectedId: g, view: _, setView: v, details: y, messages: b }) {
|
|
30
|
+
let x = m === "customer", S = a({
|
|
31
|
+
view: _,
|
|
32
|
+
setView: v,
|
|
33
|
+
selectedId: h,
|
|
34
|
+
setSelectedId: g,
|
|
35
|
+
messages: b,
|
|
36
|
+
counterpartType: m,
|
|
37
|
+
counterpart: y.counterpart,
|
|
38
|
+
primaryAddress: x && _ === "edit" ? void 0 : y.primaryAddress,
|
|
39
|
+
includeBankAccount: _ === "create"
|
|
40
|
+
}), C = s({
|
|
41
|
+
items: y.bankAccounts,
|
|
42
|
+
selectedId: h,
|
|
43
|
+
messages: b
|
|
44
|
+
}), w = i({
|
|
45
|
+
selectedId: h,
|
|
46
|
+
primaryAddress: y.primaryAddress,
|
|
47
|
+
messages: b
|
|
48
|
+
}), T = o({
|
|
49
|
+
selectedId: h,
|
|
50
|
+
setSelectedId: g,
|
|
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 ? {
|
|
52
57
|
...e,
|
|
53
|
-
address:
|
|
58
|
+
address: d
|
|
54
59
|
} : e;
|
|
55
60
|
}, [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
]),
|
|
60
|
-
if (
|
|
61
|
-
let e =
|
|
62
|
-
return e ?
|
|
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;
|
|
63
68
|
}, [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
C.form.sheet.id,
|
|
70
|
+
C.form.sheet.mode,
|
|
71
|
+
y.bankAccounts
|
|
67
72
|
]);
|
|
68
|
-
|
|
69
|
-
open:
|
|
70
|
-
seed: w,
|
|
71
|
-
setValues: b.setValues
|
|
72
|
-
}), s({
|
|
73
|
-
open: S.open,
|
|
74
|
-
seed: T,
|
|
75
|
-
setValues: S.setValues
|
|
76
|
-
}), s({
|
|
77
|
-
open: x.form.sheet.open,
|
|
73
|
+
c({
|
|
74
|
+
open: _ === "edit",
|
|
78
75
|
seed: E,
|
|
79
|
-
setValues:
|
|
80
|
-
}),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
setValues: S.setValues
|
|
77
|
+
}), c({
|
|
78
|
+
open: w.open,
|
|
79
|
+
seed: D,
|
|
80
|
+
setValues: w.setValues
|
|
81
|
+
}), c({
|
|
82
|
+
open: C.form.sheet.open,
|
|
83
|
+
seed: O,
|
|
84
|
+
setValues: C.form.setValues
|
|
85
|
+
}), C.form.sheet.open && C.form.sheet.mode === "edit" && y.bankAccounts !== void 0 && !y.isBankAccountsFetching && !O && C.form.close();
|
|
86
|
+
let k = u(() => {
|
|
87
|
+
if (!E) return !1;
|
|
88
|
+
let e = S.values;
|
|
89
|
+
return e.legalName !== E.legalName || e.firstName !== E.firstName || e.lastName !== E.lastName || e.email !== E.email || e.phone !== E.phone || e.taxId !== E.taxId || e.remindersEnabled !== E.remindersEnabled || !x && !f(e.address, E.address);
|
|
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;
|
|
85
97
|
}, [
|
|
86
|
-
|
|
87
|
-
b
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
_,
|
|
99
|
+
b,
|
|
100
|
+
F,
|
|
101
|
+
P
|
|
102
|
+
]), L = l(() => {
|
|
103
|
+
if (!x) {
|
|
104
|
+
j(), M();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
M(), N((e) => ({
|
|
108
|
+
...e,
|
|
109
|
+
address: d
|
|
110
|
+
}));
|
|
111
|
+
}, [
|
|
112
|
+
j,
|
|
113
|
+
M,
|
|
114
|
+
N,
|
|
115
|
+
x
|
|
116
|
+
]);
|
|
90
117
|
return {
|
|
91
|
-
form:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
A(), j((e) => ({
|
|
104
|
-
...e,
|
|
105
|
-
address: u
|
|
106
|
-
}));
|
|
107
|
-
}, [
|
|
108
|
-
k,
|
|
109
|
-
A,
|
|
110
|
-
j,
|
|
111
|
-
y
|
|
112
|
-
])
|
|
118
|
+
form: {
|
|
119
|
+
...S,
|
|
120
|
+
submit: I
|
|
121
|
+
},
|
|
122
|
+
bank: C,
|
|
123
|
+
address: w,
|
|
124
|
+
del: T,
|
|
125
|
+
isEditDirty: k,
|
|
126
|
+
isAddressDirty: A,
|
|
127
|
+
closeAddress: j,
|
|
128
|
+
handleEditProfile: L
|
|
113
129
|
};
|
|
114
130
|
}
|
|
115
131
|
//#endregion
|
|
116
|
-
export {
|
|
132
|
+
export { m as useCounterpartDetailsActions };
|
|
@@ -20,7 +20,17 @@ var e = {
|
|
|
20
20
|
deleteTitle: "Delete {name}?",
|
|
21
21
|
deleteBankAccountTitle: "Delete bank account “{account}”?",
|
|
22
22
|
deleteCounterpartMessage: "This record and its contacts, bank accounts, and tax ID will be permanently removed. You can't undo this action.",
|
|
23
|
-
deleteBankAccountMessage: "This removes these payment instructions from the vendor. The vendor will not be deleted. You can't undo this action."
|
|
23
|
+
deleteBankAccountMessage: "This removes these payment instructions from the vendor. The vendor will not be deleted. You can't undo this action.",
|
|
24
|
+
createSucceeded: "{name} has been added to the list.",
|
|
25
|
+
updateSucceeded: "{name} has been updated.",
|
|
26
|
+
addressAdded: "Address has been added.",
|
|
27
|
+
addressUpdated: "Address has been updated.",
|
|
28
|
+
bankAccountAdded: "Bank Account has been added.",
|
|
29
|
+
bankAccountUpdated: "Bank account information has been updated.",
|
|
30
|
+
counterpartDeleted: "Counterpart has been deleted.",
|
|
31
|
+
bankAccountDeleted: "Bank Account has been deleted.",
|
|
32
|
+
deleteCounterpartFailed: "Failed to delete Counterpart.",
|
|
33
|
+
deleteBankAccountFailed: "Failed to delete Bank Account."
|
|
24
34
|
};
|
|
25
35
|
//#endregion
|
|
26
36
|
export { e as COUNTERPART_MESSAGE_LABELS_EN };
|
|
@@ -2,48 +2,46 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import "../../../../ui/dist/index.js";
|
|
7
|
+
import { bankAccountToAchFormValues as t, counterpartFormBankAccountToCreatePayload as n, counterpartFormBankAccountToUpdatePayload as r, emptyAchFormValues as i, hasAchFormErrors as a, resolveCounterpartBankAccountWrite as o, validateAchFormValues as s } from "./helpers.js";
|
|
8
|
+
import { useCreateCounterpartBankAccountMutation as c, useUpdateCounterpartBankAccountMutation as l } from "../../../data-access/dist/index5.js";
|
|
7
9
|
import "../../../data-access/dist/index.js";
|
|
8
|
-
import { useSubEntityForm as
|
|
10
|
+
import { useSubEntityForm as u } from "./useSubEntityForm.js";
|
|
9
11
|
//#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/subEntityForms.js
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
items:
|
|
13
|
-
empty:
|
|
14
|
-
toFormValues:
|
|
15
|
-
validate: (e) =>
|
|
16
|
-
hasErrors: (e) =>
|
|
17
|
-
genericError:
|
|
18
|
-
onSubmit: async ({ mode:
|
|
19
|
-
if (!
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
await p.mutateAsync({
|
|
32
|
-
path: { counterpart_id: d },
|
|
33
|
-
body: t(i, { isDefaultForCurrency: o.isDefaultForCurrency })
|
|
34
|
-
});
|
|
12
|
+
function d({ items: d, selectedId: f, messages: p }) {
|
|
13
|
+
let m = c(), h = l(), g = u({
|
|
14
|
+
items: d,
|
|
15
|
+
empty: i,
|
|
16
|
+
toFormValues: t,
|
|
17
|
+
validate: (e) => s(e, p),
|
|
18
|
+
hasErrors: (e) => a(e),
|
|
19
|
+
genericError: p.genericError,
|
|
20
|
+
onSubmit: async ({ mode: t, id: i, values: a }) => {
|
|
21
|
+
if (!f) return;
|
|
22
|
+
let s = o(d, t === "edit" ? i : void 0);
|
|
23
|
+
s.kind === "update" ? await h.mutateAsync({
|
|
24
|
+
path: {
|
|
25
|
+
counterpart_id: f,
|
|
26
|
+
bank_account_id: s.bankAccountId
|
|
27
|
+
},
|
|
28
|
+
body: r(a, { includeAchDefaults: s.includeAchDefaults })
|
|
29
|
+
}) : await m.mutateAsync({
|
|
30
|
+
path: { counterpart_id: f },
|
|
31
|
+
body: n(a, { isDefaultForCurrency: s.isDefaultForCurrency })
|
|
32
|
+
}), e.success(t === "edit" && i ? p.bankAccountUpdated : p.bankAccountAdded);
|
|
35
33
|
}
|
|
36
|
-
}),
|
|
37
|
-
accountHolderName: !
|
|
38
|
-
routingNumber: !
|
|
39
|
-
accountNumber: !
|
|
40
|
-
} : void 0,
|
|
34
|
+
}), _ = g.sheet.mode === "edit" ? d?.find((e) => e.id === g.sheet.id) : void 0, v = _ ? {
|
|
35
|
+
accountHolderName: !g.values.accountHolderName.trim(),
|
|
36
|
+
routingNumber: !g.values.routingNumber.trim(),
|
|
37
|
+
accountNumber: !g.values.accountNumber.trim()
|
|
38
|
+
} : void 0, y = _ ? t(_) : i(), b = Object.keys(y).some((e) => g.values[e] !== y[e]);
|
|
41
39
|
return {
|
|
42
|
-
form:
|
|
43
|
-
inProgress:
|
|
44
|
-
highlightedFields:
|
|
45
|
-
isDirty:
|
|
40
|
+
form: g,
|
|
41
|
+
inProgress: m.isPending || h.isPending,
|
|
42
|
+
highlightedFields: v,
|
|
43
|
+
isDirty: b
|
|
46
44
|
};
|
|
47
45
|
}
|
|
48
46
|
//#endregion
|
|
49
|
-
export {
|
|
47
|
+
export { d as useBankAccountForm };
|
|
@@ -2,71 +2,73 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
5
|
+
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import { extractApiErrorMessage as t } from "../../../../util/dist/lib/apiErrors.js";
|
|
7
|
+
import "../../../../ui/dist/index.js";
|
|
8
|
+
import { addressFormToCreatePayload as n, addressFormToUpdatePayload as r, addressResponseToFormValues as i, validateAddressForm as a } from "./helpers.js";
|
|
9
|
+
import { useCreateCounterpartAddressMutation as o, useUpdateCounterpartAddressMutation as s } from "../../../data-access/dist/index7.js";
|
|
8
10
|
import "../../../data-access/dist/index.js";
|
|
9
|
-
import { useCallback as
|
|
11
|
+
import { useCallback as c, useState as l } from "react";
|
|
10
12
|
//#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useAddressForm.js
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
+
function u({ selectedId: u, primaryAddress: d, messages: f }) {
|
|
14
|
+
let p = o(), m = s(), [h, g] = l(!1), [_, v] = l(() => ({
|
|
13
15
|
line1: "",
|
|
14
16
|
line2: "",
|
|
15
17
|
city: "",
|
|
16
18
|
state: "",
|
|
17
19
|
postalCode: ""
|
|
18
|
-
})), [
|
|
19
|
-
|
|
20
|
-
}, [
|
|
21
|
-
|
|
20
|
+
})), [y, b] = l({}), [x, S] = l(), C = c(() => {
|
|
21
|
+
d && (v(i(d)), b({}), S(void 0), g(!0));
|
|
22
|
+
}, [d]), w = c(() => {
|
|
23
|
+
v({
|
|
22
24
|
line1: "",
|
|
23
25
|
line2: "",
|
|
24
26
|
city: "",
|
|
25
27
|
state: "",
|
|
26
28
|
postalCode: ""
|
|
27
|
-
}),
|
|
28
|
-
}, []),
|
|
29
|
-
if (!
|
|
30
|
-
let
|
|
31
|
-
if (Object.values(
|
|
32
|
-
|
|
29
|
+
}), b({}), S(void 0), g(!0);
|
|
30
|
+
}, []), T = c(() => g(!1), []), E = c(async () => {
|
|
31
|
+
if (!u) return;
|
|
32
|
+
let i = a(_, f);
|
|
33
|
+
if (Object.values(i).some(Boolean)) {
|
|
34
|
+
b(i);
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
b({});
|
|
36
38
|
try {
|
|
37
|
-
|
|
39
|
+
d ? (await m.mutateAsync({
|
|
38
40
|
path: {
|
|
39
|
-
counterpart_id:
|
|
40
|
-
address_id:
|
|
41
|
+
counterpart_id: u,
|
|
42
|
+
address_id: d.id
|
|
41
43
|
},
|
|
42
|
-
body:
|
|
43
|
-
}) : await
|
|
44
|
-
path: { counterpart_id:
|
|
45
|
-
body:
|
|
46
|
-
}),
|
|
47
|
-
} catch (
|
|
48
|
-
|
|
44
|
+
body: r(_)
|
|
45
|
+
}), e.success(f.addressUpdated)) : (await p.mutateAsync({
|
|
46
|
+
path: { counterpart_id: u },
|
|
47
|
+
body: n(_)
|
|
48
|
+
}), e.success(f.addressAdded)), g(!1);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
S(t(e) ?? f.genericError);
|
|
49
51
|
}
|
|
50
52
|
}, [
|
|
51
|
-
l,
|
|
52
53
|
u,
|
|
53
|
-
g,
|
|
54
54
|
d,
|
|
55
|
+
_,
|
|
55
56
|
f,
|
|
56
|
-
p
|
|
57
|
+
p,
|
|
58
|
+
m
|
|
57
59
|
]);
|
|
58
60
|
return {
|
|
59
|
-
open:
|
|
60
|
-
values:
|
|
61
|
-
setValues:
|
|
62
|
-
errors:
|
|
63
|
-
formError:
|
|
64
|
-
isPending:
|
|
65
|
-
openCreate:
|
|
66
|
-
openEdit:
|
|
67
|
-
close:
|
|
68
|
-
submit:
|
|
61
|
+
open: h,
|
|
62
|
+
values: _,
|
|
63
|
+
setValues: v,
|
|
64
|
+
errors: y,
|
|
65
|
+
formError: x,
|
|
66
|
+
isPending: p.isPending || m.isPending,
|
|
67
|
+
openCreate: w,
|
|
68
|
+
openEdit: C,
|
|
69
|
+
close: T,
|
|
70
|
+
submit: E
|
|
69
71
|
};
|
|
70
72
|
}
|
|
71
73
|
//#endregion
|
|
72
|
-
export {
|
|
74
|
+
export { u as useAddressForm };
|
|
@@ -2,56 +2,62 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import { extractApiErrorMessage as t } from "../../../../util/dist/lib/apiErrors.js";
|
|
7
|
+
import "../../../../ui/dist/index.js";
|
|
8
|
+
import { useDeleteCounterpartMutation as n } from "../../../data-access/dist/index3.js";
|
|
9
|
+
import { useDeleteCounterpartBankAccountMutation as r } from "../../../data-access/dist/index5.js";
|
|
7
10
|
import "../../../data-access/dist/index.js";
|
|
8
|
-
import { useCallback as
|
|
11
|
+
import { useCallback as i, useState as a } from "react";
|
|
9
12
|
//#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useDeleteController.js
|
|
10
|
-
function
|
|
11
|
-
let
|
|
13
|
+
function o({ selectedId: o, setSelectedId: s, detailsView: c, messages: l }) {
|
|
14
|
+
let u = n(), d = r(), [f, p] = a(null);
|
|
12
15
|
return {
|
|
13
|
-
target:
|
|
14
|
-
requestDeleteCounterpart:
|
|
15
|
-
|
|
16
|
+
target: f,
|
|
17
|
+
requestDeleteCounterpart: i(() => {
|
|
18
|
+
o && c && p({
|
|
16
19
|
kind: "counterpart",
|
|
17
|
-
id:
|
|
18
|
-
label:
|
|
20
|
+
id: o,
|
|
21
|
+
label: c.name
|
|
19
22
|
});
|
|
20
|
-
}, [
|
|
21
|
-
requestDeleteCounterpartById:
|
|
22
|
-
|
|
23
|
+
}, [o, c]),
|
|
24
|
+
requestDeleteCounterpartById: i(({ id: e, name: t }) => {
|
|
25
|
+
p({
|
|
23
26
|
kind: "counterpart",
|
|
24
27
|
id: e,
|
|
25
28
|
label: t
|
|
26
29
|
});
|
|
27
30
|
}, []),
|
|
28
|
-
requestDelete:
|
|
29
|
-
close:
|
|
30
|
-
confirm:
|
|
31
|
-
if (!
|
|
32
|
-
let { kind:
|
|
31
|
+
requestDelete: i((e) => p(e), []),
|
|
32
|
+
close: i(() => p(null), []),
|
|
33
|
+
confirm: i(async () => {
|
|
34
|
+
if (!f) return;
|
|
35
|
+
let { kind: n, id: r } = f;
|
|
33
36
|
try {
|
|
34
|
-
if (
|
|
35
|
-
await
|
|
37
|
+
if (n === "counterpart") {
|
|
38
|
+
await u.mutateAsync({ path: { counterpart_id: r } }), e.success(l.counterpartDeleted), p(null), o === r && s(void 0);
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
|
-
if (!
|
|
39
|
-
|
|
40
|
-
counterpart_id:
|
|
41
|
-
bank_account_id:
|
|
42
|
-
} }),
|
|
43
|
-
} catch {
|
|
41
|
+
if (!o) return;
|
|
42
|
+
n === "bankAccount" && (await d.mutateAsync({ path: {
|
|
43
|
+
counterpart_id: o,
|
|
44
|
+
bank_account_id: r
|
|
45
|
+
} }), e.success(l.bankAccountDeleted)), p(null);
|
|
46
|
+
} catch (r) {
|
|
47
|
+
e.error(t(r) ?? (n === "counterpart" ? l.deleteCounterpartFailed : l.deleteBankAccountFailed));
|
|
48
|
+
}
|
|
44
49
|
}, [
|
|
50
|
+
f,
|
|
51
|
+
o,
|
|
45
52
|
u,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
l
|
|
49
|
-
a
|
|
53
|
+
d,
|
|
54
|
+
s,
|
|
55
|
+
l
|
|
50
56
|
]),
|
|
51
|
-
isDeleting:
|
|
52
|
-
dialogTitle:
|
|
53
|
-
dialogMessage:
|
|
57
|
+
isDeleting: u.isPending || d.isPending,
|
|
58
|
+
dialogTitle: f ? f.kind === "counterpart" ? l.deleteTitle.replace("{name}", () => f.label) : l.deleteBankAccountTitle.replace("{account}", () => f.label) : "",
|
|
59
|
+
dialogMessage: f?.kind === "counterpart" ? l.deleteCounterpartMessage : l.deleteBankAccountMessage
|
|
54
60
|
};
|
|
55
61
|
}
|
|
56
62
|
//#endregion
|
|
57
|
-
export {
|
|
63
|
+
export { o as useDeleteController };
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
CHANGED
|
@@ -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.7.
|
|
2
|
+
var e = "@tesouro/embedded-components-react", t = "0.7.34", n = "1d3bf8810b6c516ffe8aff8d8b4d84ee6d80adca", r = Object.freeze({
|
|
3
3
|
library_name: e,
|
|
4
4
|
library_version: t,
|
|
5
5
|
library_sha: n
|