@tesouro/embedded-components-react 0.5.292 → 0.5.294

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +26 -1
  3. package/dist/lib/CounterpartsWidget.d.ts +2 -0
  4. package/dist/lib/CounterpartsWidgetPublic.d.ts +2 -0
  5. package/dist/lib/CustomersWidget.d.ts +2 -0
  6. package/dist/lib/ReceivablesWidget.d.ts +26 -1
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +4 -4
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +3 -2
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +5 -88
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index15.js +70 -173
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index16.js +210 -17
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index17.js +29 -0
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +6 -7
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +142 -141
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +84 -54
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +21 -3
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +27 -27
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurrence.js +2 -1
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/reminders.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +13 -10
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +84 -80
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +32 -30
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +417 -414
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +1 -1
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +83 -66
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +133 -129
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useSendReceivableWithPaymentLink.js +26 -22
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useUtcDayStart.js +16 -0
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +0 -1
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +20 -22
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +2 -2
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +1 -1
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +91 -85
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +1 -0
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +119 -88
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +19 -16
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index57.js +130 -96
  41. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +24 -8
  42. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +2 -0
  43. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +101 -98
  44. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index9.js +34 -20
  45. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  46. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +4 -3
  47. package/dist/packages/shared-ui-shadcn/dist/index.js +15 -10
  48. package/package.json +1 -1
@@ -6,7 +6,7 @@ import { useMyEntityQuery as e } from "../../../../../shared/data-access/dist/li
6
6
  import "../../../../../shared/data-access/dist/index.js";
7
7
  import { useCounterpartQuery as t } from "../../../../../shared/counterpart-management/data-access/dist/index3.js";
8
8
  import "../../../../../shared/counterpart-management/feature/dist/index.js";
9
- import { useReceivableRequiredFieldsQuery as n } from "../../../../data-access/dist/index14.js";
9
+ import { useReceivableRequiredFieldsQuery as n } from "../../../../data-access/dist/index15.js";
10
10
  import "../../../../data-access/dist/index.js";
11
11
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js
12
12
  function r({ counterpartId: r, billingAddressId: i, billingCountry: a, inlineCustomerType: o, checkRequiredFields: s = !0 }) {
@@ -8,7 +8,7 @@ import { usePaymentTermsQuery as n } from "../../../../../shared/data-access/dis
8
8
  import "../../../../../shared/ui/dist/index.js";
9
9
  import { useWidgetConfig as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
10
  import "../../../../../shared/feature/dist/index.js";
11
- import { useCreateOverdueReminderMutation as i, useCreatePaymentReminderMutation as a, useOverdueRemindersQuery as o, usePaymentRemindersQuery as s } from "../../../../data-access/dist/index15.js";
11
+ import { useCreateOverdueReminderMutation as i, useCreatePaymentReminderMutation as a, useOverdueRemindersQuery as o, usePaymentRemindersQuery as s } from "../../../../data-access/dist/index16.js";
12
12
  import "../../../../data-access/dist/index.js";
13
13
  import { areOverdueTermsValid as c, buildOverdueReminderPayload as l, buildPaymentReminderPayload as u, buildRemindersView as d, canCreateReminders as f, getImpliedDueDate as p, isBeforeDueDaysValid as m, sanitizeReminderDays as h } from "./reminders.js";
14
14
  import { useCallback as g, useMemo as _, useState as v } from "react";
@@ -2,7 +2,7 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { useReceivablesAnalyticsQuery as e } from "../../../../data-access/dist/index16.js";
5
+ import { useReceivablesAnalyticsQuery as e } from "../../../../data-access/dist/index17.js";
6
6
  import "../../../../data-access/dist/index.js";
7
7
  import { buildReceivableStatusCardsView as t } from "./statusCards.js";
8
8
  import { useMemo as n } from "react";
@@ -2,87 +2,104 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { useReceivablesQuery as e } from "../../../../data-access/dist/index14.js";
5
+ import { useReceivablesQuery as e } from "../../../../data-access/dist/index15.js";
6
+ import { useRecurrencesByIdQueries as t } from "../../../../data-access/dist/index16.js";
6
7
  import "../../../../data-access/dist/index.js";
7
- import { buildReceivableRows as t } from "./helpers.js";
8
- import { useInvoicesFilter as n } from "./useInvoicesFilter.js";
9
- import { useReceivableCustomerNames as r } from "./useReceivableCustomerNames.js";
10
- import { useReceivableStatusCards as i } from "./useReceivableStatusCards.js";
11
- import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
8
+ import { buildReceivableRows as n } from "./helpers.js";
9
+ import { buildSeriesStatusChipView as r } from "./details.js";
10
+ import { useInvoicesFilter as i } from "./useInvoicesFilter.js";
11
+ import { useReceivableCustomerNames as a } from "./useReceivableCustomerNames.js";
12
+ import { useReceivableStatusCards as o } from "./useReceivableStatusCards.js";
13
+ import { useUtcDayStart as s } from "./useUtcDayStart.js";
14
+ import { useCallback as c, useEffect as l, useMemo as u, useState as d } from "react";
12
15
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js
13
- var l = [], u = [{
16
+ var f = [], p = [{
14
17
  id: "dueDateLabel",
15
18
  desc: !0
16
19
  }];
17
- function d({ initialCounterpartId: d, messages: p, statusLabels: m, filterLabels: h, pageSizeOptions: g, enabled: _ = !0, visible: v = _ }) {
18
- let [y, b] = c(u), [x, S] = c(g?.[0] ?? 10), [C, w] = c(), [T, E] = c(""), [D, O] = c(""), k = a(() => w(void 0), []), A = n({
19
- initialCounterpartId: d,
20
- search: T,
21
- onSearchChange: E,
22
- onFiltersChange: k,
23
- statusLabels: m,
24
- labels: h
20
+ function m({ initialCounterpartId: m, messages: g, statusLabels: _, filterLabels: v, pageSizeOptions: y, enabled: b = !0, visible: x = b }) {
21
+ let [S, C] = d(p), [w, T] = d(y?.[0] ?? 10), [E, D] = d(), [O, k] = d(""), [A, j] = d(""), M = c(() => D(void 0), []), N = i({
22
+ initialCounterpartId: m,
23
+ search: O,
24
+ onSearchChange: k,
25
+ onFiltersChange: M,
26
+ statusLabels: _,
27
+ labels: v
25
28
  });
26
- o(() => {
29
+ l(() => {
27
30
  let e = setTimeout(() => {
28
- O(T), w(void 0);
31
+ j(O), M();
29
32
  }, 300);
30
33
  return () => clearTimeout(e);
31
- }, [T]);
32
- let j = y[0]?.id, M = j ? f[j] : void 0, N = y[0] ? y[0].desc ? "desc" : "asc" : void 0, P = e({
33
- enabled: _,
34
+ }, [M, O]);
35
+ let P = S[0]?.id, F = P ? h[P] : void 0, I = S[0] ? S[0].desc ? "desc" : "asc" : void 0, L = e({
36
+ enabled: b,
34
37
  type: "invoice",
35
- limit: x,
36
- pagination_token: C,
37
- search_text: D || void 0,
38
- ...A.query,
39
- ...M ? {
40
- sort: M,
41
- order: N
38
+ limit: w,
39
+ pagination_token: E,
40
+ search_text: A || void 0,
41
+ ...N.query,
42
+ ...F ? {
43
+ sort: F,
44
+ order: I
42
45
  } : {}
43
- }), F = i({
44
- enabled: _,
45
- visible: v,
46
- statusFilter: A.cardStatus,
47
- messages: p,
48
- statusLabels: m
49
- }), I = P.data?.data ?? l, L = s(() => new Map(I.map((e) => [e.id, e])), [I]), R = a((e) => L.get(e), [L]), z = r(I), B = s(() => t({
50
- receivables: I,
51
- messages: p,
52
- customerNames: z
46
+ }), R = o({
47
+ enabled: b,
48
+ visible: x,
49
+ statusFilter: N.cardStatus,
50
+ messages: g,
51
+ statusLabels: _
52
+ }), z = L.data?.data ?? f, B = u(() => new Map(z.map((e) => [e.id, e])), [z]), V = c((e) => B.get(e), [B]), H = a(z), U = u(() => [...new Set(z.flatMap((e) => e.type === "invoice" && e.status === "recurring" && e.recurrence_id ? [e.recurrence_id] : []))], [z]), W = t(U, { enabled: b }), G = u(() => new Map(U.map((e, t) => {
53
+ let n = W[t], i = n?.data?.status;
54
+ return [e, {
55
+ status: i ? r(i, g) : void 0,
56
+ isLoading: n?.isLoading ?? !1
57
+ }];
58
+ })), [
59
+ g,
60
+ U,
61
+ W
62
+ ]), K = s(), q = u(() => n({
63
+ receivables: z,
64
+ messages: g,
65
+ customerNames: H,
66
+ seriesStatuses: G,
67
+ now: new Date(K)
53
68
  }), [
69
+ H,
70
+ g,
54
71
  z,
55
- p,
56
- I
57
- ]), V = a((e) => {
58
- let t = typeof e == "function" ? e(y) : e;
59
- b(t[0] && Object.hasOwn(f, t[0].id) ? t : u), w(void 0);
60
- }, [y]), H = a((e) => {
61
- S(e), w(void 0);
62
- }, []), U = a(() => w(P.data?.next_pagination_token ?? void 0), [P.data?.next_pagination_token]), W = a(() => w(P.data?.prev_pagination_token ?? void 0), [P.data?.prev_pagination_token]), G = a(() => {
63
- P.refetch();
64
- }, [P]);
72
+ G,
73
+ K
74
+ ]), J = c((e) => {
75
+ let t = typeof e == "function" ? e(S) : e;
76
+ C(t[0] && Object.hasOwn(h, t[0].id) ? t : p), M();
77
+ }, [M, S]), Y = c((e) => {
78
+ T(e), M();
79
+ }, [M]), X = c(() => D(L.data?.next_pagination_token ?? void 0), [L.data?.next_pagination_token]), Z = c(() => D(L.data?.prev_pagination_token ?? void 0), [L.data?.prev_pagination_token]), Q = c(() => {
80
+ L.refetch();
81
+ }, [L]);
65
82
  return {
66
- rows: B,
67
- isLoading: P.isLoading,
68
- isError: P.isError,
69
- sorting: y,
70
- onSortingChange: V,
71
- pageSize: x,
72
- onPageSizeChange: H,
73
- hasNextPage: !!P.data?.next_pagination_token,
74
- hasPrevPage: !!P.data?.prev_pagination_token,
75
- onNextPage: U,
76
- onPrevPage: W,
77
- statusCards: F,
78
- onStatusCardSelect: A.selectStatusCard,
79
- filterBar: A.filterBar,
80
- isFiltering: A.isFiltering,
81
- onRetry: G,
82
- getReceivableById: R
83
+ rows: q,
84
+ isLoading: L.isLoading,
85
+ isError: L.isError,
86
+ sorting: S,
87
+ onSortingChange: J,
88
+ pageSize: w,
89
+ onPageSizeChange: Y,
90
+ hasNextPage: !!L.data?.next_pagination_token,
91
+ hasPrevPage: !!L.data?.prev_pagination_token,
92
+ onNextPage: X,
93
+ onPrevPage: Z,
94
+ statusCards: R,
95
+ onStatusCardSelect: N.selectStatusCard,
96
+ filterBar: N.filterBar,
97
+ isFiltering: N.isFiltering,
98
+ onRetry: Q,
99
+ getReceivableById: V
83
100
  };
84
101
  }
85
- var f = {
102
+ var h = {
86
103
  documentLabel: "document_id",
87
104
  status: "status",
88
105
  issueDateLabel: "issue_date",
@@ -90,4 +107,4 @@ var f = {
90
107
  totalLabel: "total_amount"
91
108
  };
92
109
  //#endregion
93
- export { d as useReceivablesTable };
110
+ export { m as useReceivablesTable };
@@ -24,53 +24,53 @@ import { useReceivableForm as pe } from "./useReceivableForm.js";
24
24
  import { useReceivablesTable as me } from "./useReceivablesTable.js";
25
25
  import { useCallback as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
26
26
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js
27
- function he({ auditHistoryLabels: he, counterpartMessageLabels: ge, embeddedBankName: _e, filterLabels: ve, initialCounterpartId: d, initialView: f, messageLabels: p, onReceivableCreated: m, onReceivableOpened: h, pageSizeOptions: ye, screenLabels: be }) {
28
- let g = n();
27
+ function u({ auditHistoryLabels: u, counterpartMessageLabels: he, embeddedBankName: ge, filterLabels: _e, initialCounterpartId: f, initialView: p, messageLabels: m, onReceivableCreated: h, onReceivableOpened: g, pageSizeOptions: ve, screenLabels: ye }) {
28
+ let _ = n();
29
29
  o(() => {
30
- g(re.Mounted);
31
- }, [g]);
32
- let { initResponse: _, widgetToken: xe } = i(), v = ne(), Se = ee(), Ce = r(), y = te(), b = !!_ && !y, x = s(() => le(_?.scopes), [_?.scopes]), we = !!_ && y, S = !!_ && x.canRead, C = !!_ && x.canWrite, w = b && x.canRead, T = b && x.canWrite, E = !!Se && !b && !v, D = !b && !E && !!(xe || v), O = s(() => ({
30
+ _(re.Mounted);
31
+ }, [_]);
32
+ let { initResponse: v, widgetToken: be } = i(), y = ne(), xe = ee(), Se = r(), b = te(), x = !!v && !b, S = s(() => le(v?.scopes), [v?.scopes]), Ce = !!v && b, C = !!v && S.canRead, w = !!v && S.canWrite, T = x && S.canRead, E = x && S.canWrite, D = !!xe && !x && !y, O = !x && !D && !!(be || y), k = s(() => ({
33
33
  ...ce,
34
- ...p
35
- }), [p]), k = be?.statusBadge, A = s(() => ({
34
+ ...m
35
+ }), [m]), A = ye?.statusBadge, j = s(() => ({
36
36
  ...ie,
37
- ...k
38
- }), [k]), [j, M] = l(), [N, P] = l(!1), [F, Te] = l(j);
39
- j && j !== F && Te(j);
40
- let [I, L] = l(!1), [Ee, R] = l(), z = e(_?.scopes, [t.CounterpartReadOrg]), De = a(() => R(void 0), []), [B, V] = l(!1), Oe = a(() => V(!0), []), H = a(() => V(!1), []), ke = a((e, t) => {
41
- M(e), P(!0), m?.(e, t);
42
- }, [m]), U = de({ messages: O }), W = U.open, Ae = a((e, t, n) => {
37
+ ...A
38
+ }), [A]), [M, N] = l(), [P, F] = l(!1), [I, we] = l(M);
39
+ M && M !== I && we(M);
40
+ let [L, R] = l(!1), [Te, z] = l(), B = e(v?.scopes, [t.CounterpartReadOrg]), Ee = a(() => z(void 0), []), [V, H] = l(!1), De = a(() => H(!0), []), U = a(() => H(!1), []), Oe = a((e) => {
41
+ N(e), F(!0);
42
+ }, []), W = de({ messages: k }), G = W.open, ke = a((e, t, n) => {
43
43
  let r = oe(n);
44
- r.openDetails && (M(e), P(!0)), r.actionsModal && W({
44
+ r.openDetails && (N(e), F(!0)), r.actionsModal && G({
45
45
  action: n.mode,
46
46
  receivableId: e,
47
47
  documentType: t,
48
48
  counterpartId: n.counterpartId,
49
49
  inlineItems: n.inlineItems,
50
50
  showEmailStep: r.actionsModal.showEmailStep
51
- }), m?.(e, t);
52
- }, [m, W]), G = me({
53
- initialCounterpartId: f === "create" ? void 0 : d,
54
- messages: O,
55
- statusLabels: A,
56
- filterLabels: ve,
57
- pageSizeOptions: ye,
58
- enabled: w,
59
- visible: S
60
- }), je = a((e) => {
61
- M(e), P(!0), h?.(e, "invoice");
62
- }, [h]), K = fe({
63
- selectedReceivableId: j,
64
- enabled: N && w,
65
- canWrite: C,
66
- messages: O,
67
- statusLabels: A,
68
- auditHistoryLabels: he,
69
- onOpenReceivable: je,
70
- onOpenCustomer: z ? R : void 0
71
- }), q = c("edit"), Me = a((e, t, n) => {
72
- let r = n.mode === "issue", i = r && q.current !== "issue" && n.hasCustomerEmail;
73
- (i || n.inlineItems.length !== 0) && W({
51
+ }), h?.(e, t);
52
+ }, [h, G]), K = me({
53
+ initialCounterpartId: p === "create" ? void 0 : f,
54
+ messages: k,
55
+ statusLabels: j,
56
+ filterLabels: _e,
57
+ pageSizeOptions: ve,
58
+ enabled: T,
59
+ visible: C
60
+ }), Ae = a((e) => {
61
+ N(e), F(!0), g?.(e, "invoice");
62
+ }, [g]), q = fe({
63
+ selectedReceivableId: M,
64
+ enabled: P && T,
65
+ canWrite: w,
66
+ messages: k,
67
+ statusLabels: j,
68
+ auditHistoryLabels: u,
69
+ onOpenReceivable: Ae,
70
+ onOpenCustomer: B ? z : void 0
71
+ }), J = c("edit"), je = a((e, t, n) => {
72
+ let r = n.mode === "issue", i = r && J.current !== "issue" && n.hasCustomerEmail;
73
+ (i || n.inlineItems.length !== 0) && G({
74
74
  action: r || n.mode === "recurrence" ? n.mode : "update",
75
75
  receivableId: e,
76
76
  documentType: t,
@@ -78,36 +78,36 @@ function he({ auditHistoryLabels: he, counterpartMessageLabels: ge, embeddedBank
78
78
  inlineItems: n.inlineItems,
79
79
  showEmailStep: i
80
80
  });
81
- }, [W]), J = pe({
82
- messages: O,
83
- counterpartMessageLabels: ge,
84
- embeddedBankName: _e,
85
- canCreateCustomer: x.canCreateCustomer,
86
- onCreated: Ae,
87
- onUpdated: Me
88
- }), Ne = a(() => {
89
- T && J.openCreate("invoice");
90
- }, [T, J.openCreate]), Y = c(!1);
81
+ }, [G]), Y = pe({
82
+ messages: k,
83
+ counterpartMessageLabels: he,
84
+ embeddedBankName: ge,
85
+ canCreateCustomer: S.canCreateCustomer,
86
+ onCreated: ke,
87
+ onUpdated: je
88
+ }), Me = a(() => {
89
+ E && Y.openCreate("invoice");
90
+ }, [E, Y.openCreate]), X = c(!1);
91
91
  o(() => {
92
- Y.current || f === "create" && T && (Y.current = !0, J.openCreate("invoice", { customerId: d }));
92
+ X.current || p === "create" && E && (X.current = !0, Y.openCreate("invoice", { customerId: f }));
93
93
  }, [
94
- T,
95
- J.openCreate,
96
- d,
97
- f
94
+ E,
95
+ Y.openCreate,
96
+ f,
97
+ p
98
98
  ]);
99
- let X = ue({
100
- selectedReceivable: K.receivable,
101
- selectedRecurrence: K.recurrence,
102
- messages: O,
103
- onCreated: ke,
99
+ let Z = ue({
100
+ selectedReceivable: q.receivable,
101
+ selectedRecurrence: q.recurrence,
102
+ messages: k,
103
+ onCreated: Oe,
104
104
  onDeleted: (e) => {
105
- e === j && (M(void 0), P(!1));
105
+ e === M && (N(void 0), F(!1));
106
106
  },
107
107
  onCompleteBeforeIssue: (e, t) => {
108
- q.current = t, J.openEdit(e, { highlightForIssue: !0 }), N && L(!0), P(!1);
108
+ J.current = t, Y.openEdit(e, { highlightForIssue: !0 }), P && R(!0), F(!1);
109
109
  },
110
- onIssuedForSend: (e, t) => W({
110
+ onIssuedForSend: (e, t) => G({
111
111
  action: "issue",
112
112
  receivableId: e,
113
113
  documentType: "invoice",
@@ -115,7 +115,7 @@ function he({ auditHistoryLabels: he, counterpartMessageLabels: ge, embeddedBank
115
115
  inlineItems: [],
116
116
  showEmailStep: !0
117
117
  }),
118
- onResend: (e, t) => W({
118
+ onResend: (e, t) => G({
119
119
  action: "issue",
120
120
  receivableId: e,
121
121
  documentType: "invoice",
@@ -126,111 +126,115 @@ function he({ auditHistoryLabels: he, counterpartMessageLabels: ge, embeddedBank
126
126
  })
127
127
  });
128
128
  o(() => {
129
- J.open || (q.current = "edit");
130
- }, [J.open]), o(() => {
131
- !J.open && I && (L(!1), P(!0));
132
- }, [J.open, I]);
133
- let Z = b && !x.canWrite, Q = J.open || J.counterpartView !== "none" || !!X.actionTarget || X.payment.isOpen || U.isOpen || B, Pe = J.close, Fe = J.counterpartForm.close, { closeAction: Ie } = X, Le = X.payment.close, $ = U.close;
129
+ Y.open || (J.current = "edit");
130
+ }, [Y.open]), o(() => {
131
+ Y.open || W.isOpen || !L || (R(!1), F(!0));
132
+ }, [
133
+ W.isOpen,
134
+ Y.open,
135
+ L
136
+ ]);
137
+ let Q = x && !S.canWrite, $ = Y.open || Y.counterpartView !== "none" || !!Z.actionTarget || Z.payment.isOpen || W.isOpen || V, Ne = Y.close, Pe = Y.counterpartForm.close, { closeAction: Fe } = Z, Ie = Z.payment.close, Le = W.close;
134
138
  o(() => {
135
- Z && Q && (Pe(), Fe(), Ie(), Le(), $(), H());
139
+ Q && $ && (Ne(), Pe(), Fe(), Ie(), Le(), U());
136
140
  }, [
137
- Ie,
138
- $,
139
141
  Fe,
140
- Pe,
141
- H,
142
142
  Le,
143
- Q,
144
- Z
143
+ Pe,
144
+ Ne,
145
+ U,
146
+ Ie,
147
+ $,
148
+ Q
145
149
  ]);
146
150
  let Re = a((e) => {
147
- ae() || (M(e.id), P(!0), h?.(e.id, e.type));
148
- }, [h]), ze = a(() => {
149
- P(!1), M(void 0), R(void 0);
151
+ ae() || (N(e.id), F(!0), g?.(e.id, e.type));
152
+ }, [g]), ze = a(() => {
153
+ F(!1), N(void 0), z(void 0);
150
154
  }, []), Be = a((e, t) => {
151
- if (T) {
155
+ if (E) {
152
156
  if (e === "edit") {
153
- K.receivable && (q.current = "edit", J.openEdit(K.receivable), L(!0), P(!1));
157
+ q.receivable && (J.current = "edit", Y.openEdit(q.receivable), R(!0), F(!1));
154
158
  return;
155
159
  }
156
- X.openAction(e, {
160
+ Z.openAction(e, {
157
161
  id: t.id,
158
- title: K.receivable ? se(K.receivable, O) : t.title,
162
+ title: q.receivable ? se(q.receivable, k) : t.title,
159
163
  type: t.type
160
- }, K.receivable ?? null);
164
+ }, q.receivable ?? null);
161
165
  }
162
166
  }, [
163
- X,
164
- T,
165
- K.receivable,
166
- J.openEdit,
167
- O
167
+ Z,
168
+ E,
169
+ q.receivable,
170
+ Y.openEdit,
171
+ k
168
172
  ]);
169
173
  return {
170
- canWrite: C,
171
- canEditSettings: S && x.canEditSettings,
172
- actionsSuspended: we,
173
- isAccessRestricted: b && !x.canRead,
174
- table: S ? G : {
175
- ...G,
174
+ canWrite: w,
175
+ canEditSettings: C && S.canEditSettings,
176
+ actionsSuspended: Ce,
177
+ isAccessRestricted: x && !S.canRead,
178
+ table: C ? K : {
179
+ ...K,
176
180
  rows: [],
177
181
  statusCards: void 0,
178
182
  isError: !1
179
183
  },
180
- isTableLoading: S ? G.isLoading || D && G.rows.length === 0 : D,
181
- isError: E || S && G.isError,
182
- onRetry: E ? Ce : G.onRetry,
183
- details: K,
184
- detailsOpen: N && S,
184
+ isTableLoading: C ? K.isLoading || O && K.rows.length === 0 : O,
185
+ isError: D || C && K.isError,
186
+ onRetry: D ? Se : K.onRetry,
187
+ details: q,
188
+ detailsOpen: P && C,
185
189
  closeDetails: ze,
186
- detailsPanelKey: F,
187
- customerDetailsId: Ee,
188
- closeCustomerDetails: De,
189
- openCustomerDetails: z ? R : void 0,
190
- canCreateCustomer: x.canCreateCustomer,
191
- messages: O,
190
+ detailsPanelKey: I,
191
+ customerDetailsId: Te,
192
+ closeCustomerDetails: Ee,
193
+ openCustomerDetails: B ? z : void 0,
194
+ canCreateCustomer: S.canCreateCustomer,
195
+ messages: k,
192
196
  form: {
193
- ...J,
194
- open: C && J.open,
195
- counterpartView: C ? J.counterpartView : "none",
197
+ ...Y,
198
+ open: w && Y.open,
199
+ counterpartView: w ? Y.counterpartView : "none",
196
200
  counterpartForm: {
197
- ...J.counterpartForm,
198
- submit: u(T, J.counterpartForm.submit)
201
+ ...Y.counterpartForm,
202
+ submit: d(E, Y.counterpartForm.submit)
199
203
  },
200
- submit: u(T, J.submit),
201
- submitDraft: u(T, J.submitDraft),
202
- submitPrimary: u(T, J.submitPrimary)
204
+ submit: d(E, Y.submit),
205
+ submitDraft: d(E, Y.submitDraft),
206
+ submitPrimary: d(E, Y.submitPrimary)
203
207
  },
204
- openCreate: Ne,
205
- measureUnitsOpen: C && B,
206
- openMeasureUnits: Oe,
207
- closeMeasureUnits: H,
208
+ openCreate: Me,
209
+ measureUnitsOpen: w && V,
210
+ openMeasureUnits: De,
211
+ closeMeasureUnits: U,
208
212
  actions: {
209
- ...X,
210
- actionDialog: C ? X.actionDialog : void 0,
211
- openAction: u(T, X.openAction),
212
- confirmAction: u(T, X.confirmAction),
213
+ ...Z,
214
+ actionDialog: w ? Z.actionDialog : void 0,
215
+ openAction: d(E, Z.openAction),
216
+ confirmAction: d(E, Z.confirmAction),
213
217
  payment: {
214
- ...X.payment,
215
- isOpen: C && X.payment.isOpen,
216
- save: u(T, X.payment.save),
217
- confirm: u(T, X.payment.confirm)
218
+ ...Z.payment,
219
+ isOpen: w && Z.payment.isOpen,
220
+ save: d(E, Z.payment.save),
221
+ confirm: d(E, Z.payment.confirm)
218
222
  }
219
223
  },
220
224
  actionsModal: {
221
- ...U,
222
- isOpen: C && U.isOpen,
223
- send: u(T, U.send),
224
- saveItems: u(T, U.saveItems)
225
+ ...W,
226
+ isOpen: w && W.isOpen,
227
+ send: d(E, W.send),
228
+ saveItems: d(E, W.saveItems)
225
229
  },
226
230
  handleRowClick: Re,
227
231
  handleDetailsActionClick: Be
228
232
  };
229
233
  }
230
- function u(e, t) {
234
+ function d(e, t) {
231
235
  return (...n) => {
232
236
  e && t(...n);
233
237
  };
234
238
  }
235
239
  //#endregion
236
- export { he as useReceivablesWidget };
240
+ export { u as useReceivablesWidget };
@@ -15,40 +15,44 @@ import { useCreatePaymentLinkMutation as o } from "../../../../data-access/dist/
15
15
  import { useSendReceivableEmailMutation as s } from "../../../../data-access/dist/index10.js";
16
16
  import "../../../../data-access/dist/index.js";
17
17
  import { getReceivePaymentMethods as c } from "./preview.js";
18
- import { useCallback as l } from "react";
18
+ import { useCallback as l, useEffect as u, useRef as d } from "react";
19
19
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useSendReceivableWithPaymentLink.js
20
- function u({ messages: u, documentType: d }) {
21
- let { initResponse: f } = i(), p = d === "invoice" && t(f?.scopes, [r.PaymentLinkWrite]), m = n({ enabled: p }), h = m.data?.id, g = a({
22
- entityId: h,
23
- enabled: p
24
- }), _ = o(), v = s(), y = g.data?.data, b = m.error ?? g.error, x = _.mutateAsync, S = v.mutateAsync, C = u.actionsSendWithoutPaymentLink;
20
+ function f({ messages: f, documentType: p }) {
21
+ let { initResponse: m } = i(), h = p === "invoice", g = t(m?.scopes, [r.PaymentLinkWrite]), _ = h && g, v = n({ enabled: _ }), y = v.data?.id, b = a({
22
+ entityId: y,
23
+ enabled: _
24
+ }), x = o(), S = s(), C = v.error || b.error ? void 0 : b.data?.data, w = d(void 0);
25
+ u(() => {
26
+ p || (w.current = void 0);
27
+ }, [p]);
28
+ let T = x.mutateAsync, E = S.mutateAsync, D = f.actionsSendWithoutPaymentLink, O = f.actionsSendWithoutPaymentLinkScope;
25
29
  return {
26
30
  send: l(async (t) => {
27
- if (!p) return S(t);
28
- if (b || !h || !y) throw b ?? /* @__PURE__ */ Error();
29
- let n = c(y);
30
- return n.length === 0 ? e.error(C) : await x({ body: {
31
+ if (!_) return h && e.error(O), E(t);
32
+ let n = t.path.receivable_id, r = c(C);
33
+ return !y || r.length === 0 ? e.error(D) : w.current !== n && (await T({ body: {
31
34
  recipient: {
32
- id: h,
35
+ id: y,
33
36
  type: "entity"
34
37
  },
35
- payment_methods: n.map((e) => e.type),
38
+ payment_methods: r.map((e) => e.type),
36
39
  object: {
37
- id: t.path.receivable_id,
40
+ id: n,
38
41
  type: "receivable"
39
42
  }
40
- } }), S(t);
43
+ } }), w.current = n), E(t);
41
44
  }, [
42
- p,
43
- x,
44
- h,
45
- b,
45
+ _,
46
+ T,
46
47
  y,
47
- S,
48
- C
48
+ h,
49
+ C,
50
+ O,
51
+ E,
52
+ D
49
53
  ]),
50
- isPending: p && (m.isFetching || g.isFetching) || _.isPending || v.isPending
54
+ isPending: _ && (v.isFetching || b.isFetching) || x.isPending || S.isPending
51
55
  };
52
56
  }
53
57
  //#endregion
54
- export { u as useSendReceivableWithPaymentLink };
58
+ export { f as useSendReceivableWithPaymentLink };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useEffect as e, useState as t } from "react";
6
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useUtcDayStart.js
7
+ var n = 864e5, r = (e) => e - e % n;
8
+ function i() {
9
+ let [i, a] = t(() => r(Date.now()));
10
+ return e(() => {
11
+ let e = setTimeout(() => a(r(Date.now())), Math.max(i + n - Date.now(), 0));
12
+ return () => clearTimeout(e);
13
+ }, [i]), i;
14
+ }
15
+ //#endregion
16
+ export { i as useUtcDayStart };