@tesouro/embedded-components-react 0.7.32 → 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 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 { addressResponseToFormValues as e, bankAccountToAchFormValues as t, counterpartToFormValues as n } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
6
- import { useAddressForm as r } from "../../../../../shared/counterpart-management/feature/dist/lib/useAddressForm.js";
7
- import { useCounterpartForm as i } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
8
- import { useDeleteController as a } from "../../../../../shared/counterpart-management/feature/dist/lib/useDeleteController.js";
9
- import { useBankAccountForm as o } from "../../../../../shared/counterpart-management/feature/dist/lib/subEntityForms.js";
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 s } from "./useRebaseOnRefresh.js";
12
- import { useCallback as c, useMemo as l } from "react";
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 u = {
16
+ var d = {
15
17
  line1: "",
16
18
  line2: "",
17
19
  city: "",
18
20
  state: "",
19
21
  postalCode: ""
20
22
  };
21
- function d(e, t) {
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 f({ counterpartType: f, selectedId: p, setSelectedId: m, view: h, setView: g, details: _, messages: v }) {
25
- let y = f === "customer", b = i({
26
- view: h,
27
- setView: g,
28
- selectedId: p,
29
- setSelectedId: m,
30
- messages: v,
31
- counterpartType: f,
32
- counterpart: _.counterpart,
33
- primaryAddress: y && h === "edit" ? void 0 : _.primaryAddress,
34
- includeBankAccount: h === "create"
35
- }), x = o({
36
- items: _.bankAccounts,
37
- selectedId: p,
38
- messages: v
39
- }), S = r({
40
- selectedId: p,
41
- primaryAddress: _.primaryAddress,
42
- messages: v
43
- }), C = a({
44
- selectedId: p,
45
- setSelectedId: m,
46
- detailsView: _.detailsView,
47
- messages: v
48
- }), w = l(() => {
49
- if (!_.counterpart) return;
50
- let e = n(_.counterpart, _.primaryAddress);
51
- return y ? {
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: u
58
+ address: d
54
59
  } : e;
55
60
  }, [
56
- _.counterpart,
57
- _.primaryAddress,
58
- y
59
- ]), T = l(() => _.primaryAddress ? e(_.primaryAddress) : u, [_.primaryAddress]), E = l(() => {
60
- if (x.form.sheet.mode !== "edit") return;
61
- let e = _.bankAccounts?.find((e) => e.id === x.form.sheet.id);
62
- return e ? t(e) : void 0;
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
- x.form.sheet.id,
65
- x.form.sheet.mode,
66
- _.bankAccounts
69
+ C.form.sheet.id,
70
+ C.form.sheet.mode,
71
+ y.bankAccounts
67
72
  ]);
68
- s({
69
- open: h === "edit",
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: x.form.setValues
80
- }), x.form.sheet.open && x.form.sheet.mode === "edit" && _.bankAccounts !== void 0 && !_.isBankAccountsFetching && !E && x.form.close();
81
- let D = l(() => {
82
- if (!w) return !1;
83
- let e = b.values;
84
- return e.legalName !== w.legalName || e.firstName !== w.firstName || e.lastName !== w.lastName || e.email !== w.email || e.phone !== w.phone || e.taxId !== w.taxId || e.remindersEnabled !== w.remindersEnabled || !y && !d(e.address, w.address);
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
- w,
87
- b.values,
88
- y
89
- ]), O = l(() => !d(S.values, T), [S.values, T]), { close: k } = S, { openEdit: A, setValues: j } = b;
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: b,
92
- bank: x,
93
- address: S,
94
- del: C,
95
- isEditDirty: D,
96
- isAddressDirty: O,
97
- closeAddress: k,
98
- handleEditProfile: c(() => {
99
- if (!y) {
100
- k(), A();
101
- return;
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 { f as useCounterpartDetailsActions };
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 { bankAccountToAchFormValues as e, counterpartFormBankAccountToCreatePayload as t, counterpartFormBankAccountToUpdatePayload as n, emptyAchFormValues as r, hasAchFormErrors as i, resolveCounterpartBankAccountWrite as a, validateAchFormValues as o } from "./helpers.js";
6
- import { useCreateCounterpartBankAccountMutation as s, useUpdateCounterpartBankAccountMutation as c } from "../../../data-access/dist/index5.js";
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 l } from "./useSubEntityForm.js";
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 u({ items: u, selectedId: d, messages: f }) {
11
- let p = s(), m = c(), h = l({
12
- items: u,
13
- empty: r,
14
- toFormValues: e,
15
- validate: (e) => o(e, f),
16
- hasErrors: (e) => i(e),
17
- genericError: f.genericError,
18
- onSubmit: async ({ mode: e, id: r, values: i }) => {
19
- if (!d) return;
20
- let o = a(u, e === "edit" ? r : void 0);
21
- if (o.kind === "update") {
22
- await m.mutateAsync({
23
- path: {
24
- counterpart_id: d,
25
- bank_account_id: o.bankAccountId
26
- },
27
- body: n(i, { includeAchDefaults: o.includeAchDefaults })
28
- });
29
- return;
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
- }), g = h.sheet.mode === "edit" ? u?.find((e) => e.id === h.sheet.id) : void 0, _ = g ? {
37
- accountHolderName: !h.values.accountHolderName.trim(),
38
- routingNumber: !h.values.routingNumber.trim(),
39
- accountNumber: !h.values.accountNumber.trim()
40
- } : void 0, v = g ? e(g) : r(), y = Object.keys(v).some((e) => h.values[e] !== v[e]);
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: h,
43
- inProgress: p.isPending || m.isPending,
44
- highlightedFields: _,
45
- isDirty: y
40
+ form: g,
41
+ inProgress: m.isPending || h.isPending,
42
+ highlightedFields: v,
43
+ isDirty: b
46
44
  };
47
45
  }
48
46
  //#endregion
49
- export { u as useBankAccountForm };
47
+ export { d as useBankAccountForm };
@@ -2,71 +2,73 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { extractApiErrorMessage as e } from "../../../../util/dist/lib/apiErrors.js";
6
- import { addressFormToCreatePayload as t, addressFormToUpdatePayload as n, addressResponseToFormValues as r, validateAddressForm as i } from "./helpers.js";
7
- import { useCreateCounterpartAddressMutation as a, useUpdateCounterpartAddressMutation as o } from "../../../data-access/dist/index7.js";
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 s, useState as c } from "react";
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 l({ selectedId: l, primaryAddress: u, messages: d }) {
12
- let f = a(), p = o(), [m, h] = c(!1), [g, _] = c(() => ({
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
- })), [v, y] = c({}), [b, x] = c(), S = s(() => {
19
- u && (_(r(u)), y({}), x(void 0), h(!0));
20
- }, [u]), C = s(() => {
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
- }), y({}), x(void 0), h(!0);
28
- }, []), w = s(() => h(!1), []), T = s(async () => {
29
- if (!l) return;
30
- let r = i(g, d);
31
- if (Object.values(r).some(Boolean)) {
32
- y(r);
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
- y({});
37
+ b({});
36
38
  try {
37
- u ? await p.mutateAsync({
39
+ d ? (await m.mutateAsync({
38
40
  path: {
39
- counterpart_id: l,
40
- address_id: u.id
41
+ counterpart_id: u,
42
+ address_id: d.id
41
43
  },
42
- body: n(g)
43
- }) : await f.mutateAsync({
44
- path: { counterpart_id: l },
45
- body: t(g)
46
- }), h(!1);
47
- } catch (t) {
48
- x(e(t) ?? d.genericError);
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: m,
60
- values: g,
61
- setValues: _,
62
- errors: v,
63
- formError: b,
64
- isPending: f.isPending || p.isPending,
65
- openCreate: C,
66
- openEdit: S,
67
- close: w,
68
- submit: T
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 { l as useAddressForm };
74
+ export { u as useAddressForm };
@@ -2,56 +2,62 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { useDeleteCounterpartMutation as e } from "../../../data-access/dist/index3.js";
6
- import { useDeleteCounterpartBankAccountMutation as t } from "../../../data-access/dist/index5.js";
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 n, useState as r } from "react";
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 i({ selectedId: i, setSelectedId: a, detailsView: o, messages: s }) {
11
- let c = e(), l = t(), [u, d] = r(null);
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: u,
14
- requestDeleteCounterpart: n(() => {
15
- i && o && d({
16
+ target: f,
17
+ requestDeleteCounterpart: i(() => {
18
+ o && c && p({
16
19
  kind: "counterpart",
17
- id: i,
18
- label: o.name
20
+ id: o,
21
+ label: c.name
19
22
  });
20
- }, [i, o]),
21
- requestDeleteCounterpartById: n(({ id: e, name: t }) => {
22
- d({
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: n((e) => d(e), []),
29
- close: n(() => d(null), []),
30
- confirm: n(async () => {
31
- if (!u) return;
32
- let { kind: e, id: t } = u;
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 (e === "counterpart") {
35
- await c.mutateAsync({ path: { counterpart_id: t } }), d(null), i === t && a(void 0);
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 (!i) return;
39
- e === "bankAccount" && await l.mutateAsync({ path: {
40
- counterpart_id: i,
41
- bank_account_id: t
42
- } }), d(null);
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
- i,
47
- c,
48
- l,
49
- a
53
+ d,
54
+ s,
55
+ l
50
56
  ]),
51
- isDeleting: c.isPending || l.isPending,
52
- dialogTitle: u ? u.kind === "counterpart" ? s.deleteTitle.replace("{name}", () => u.label) : s.deleteBankAccountTitle.replace("{account}", () => u.label) : "",
53
- dialogMessage: u?.kind === "counterpart" ? s.deleteCounterpartMessage : s.deleteBankAccountMessage
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 { i as useDeleteController };
63
+ export { o as useDeleteController };
@@ -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.32", n = "201a5ddae8f87f5aff188953db851c49a859d236", r = Object.freeze({
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.7.32",
3
+ "version": "0.7.34",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [