@tesouro/embedded-components-react 0.5.243 → 0.5.246

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 (16) hide show
  1. package/dist/fixtures/index.d.ts +4 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/lib/ReceivablesWidget.d.ts +2 -0
  4. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +253 -251
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +84 -80
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/permissions.js +13 -0
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +1 -0
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +28 -26
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +16 -16
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +60 -58
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +188 -115
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +2 -0
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +222 -219
  14. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +5 -2
  15. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  16. package/package.json +1 -1
@@ -171,7 +171,7 @@ function E({ invoice: e, recurrence: t, iterationInvoices: n, date: r, statusLab
171
171
  };
172
172
  });
173
173
  }
174
- function D(e) {
174
+ function ee(e) {
175
175
  if (!e?.line1) return;
176
176
  let t = [e.city, [e.state, e.postal_code].filter(Boolean).join(" ")].filter(Boolean).join(", ");
177
177
  return [
@@ -180,7 +180,7 @@ function D(e) {
180
180
  e.country ? l(e.country) : void 0
181
181
  ].filter(Boolean).join(", ");
182
182
  }
183
- function ee(e, t, n) {
183
+ function te(e, t, n) {
184
184
  let r = {
185
185
  label: n.detailsAmountReceived,
186
186
  value: t(e.amount_paid)
@@ -242,7 +242,7 @@ function ee(e, t, n) {
242
242
  };
243
243
  }
244
244
  }
245
- function te(t, i, a) {
245
+ function ne(t, i, a) {
246
246
  let o = t.line_items.reduce((t, n) => {
247
247
  let r = n.total_before_tax ?? 0;
248
248
  return e(n.tax_status) ? {
@@ -287,161 +287,165 @@ function te(t, i, a) {
287
287
  emphasis: !0
288
288
  }), m;
289
289
  }
290
- function O({ receivable: e, pdfUrl: n, paymentReminder: r, overdueReminder: s, depositAccount: l, isAccountListIncomplete: u, recurrence: h, paymentRecords: S = [], isLoadingPaymentRecords: C = !1, iterationInvoices: T = /* @__PURE__ */ new Map(), auditHistory: O, statusLabels: k, messages: A, onOpenReceivable: j, now: M }) {
290
+ var D = {
291
+ primary: [],
292
+ overflow: []
293
+ };
294
+ function O({ receivable: e, pdfUrl: n, paymentReminder: r, overdueReminder: s, depositAccount: l, isAccountListIncomplete: u, recurrence: h, paymentRecords: S = [], isLoadingPaymentRecords: C = !1, iterationInvoices: T = /* @__PURE__ */ new Map(), auditHistory: O, statusLabels: k, messages: A, canWrite: j = !0, onOpenReceivable: M, now: N }) {
291
295
  if (!e || e.type !== "invoice") return;
292
- let N = e, P = (e) => o({
296
+ let P = e, F = (e) => o({
293
297
  amount: e ?? 0,
294
- currency: N.currency,
298
+ currency: P.currency,
295
299
  fallback: ""
296
- }), F = (e) => a(e, "-"), I = (e) => e ? F(e) : A.detailsPending, { status: L } = N, R = L === "canceled", z = L === "recurring" ? h : void 0, B = N.recurrence_id && L !== "recurring" ? h : void 0, V = L === "overdue" ? m(N.due_date, M) : 0, { amountTone: H, amountRows: U } = ee(N, P, A), W = N.counterpart_contact, G = D(N.counterpart_billing_address), K = [
297
- ...N.counterpart_name ? [{
300
+ }), I = (e) => a(e, "-"), L = (e) => e ? I(e) : A.detailsPending, { status: R } = P, z = R === "canceled", B = R === "recurring" ? h : void 0, V = P.recurrence_id && R !== "recurring" ? h : void 0, H = R === "overdue" ? m(P.due_date, N) : 0, { amountTone: U, amountRows: W } = te(P, F, A), G = P.counterpart_contact, K = ee(P.counterpart_billing_address), re = [
301
+ ...P.counterpart_name ? [{
298
302
  label: A.detailsCustomerName,
299
- value: N.counterpart_name
303
+ value: P.counterpart_name
300
304
  }] : [],
301
- ...W?.email ? [{
305
+ ...G?.email ? [{
302
306
  label: A.detailsCustomerEmail,
303
- value: W.email
307
+ value: G.email
304
308
  }] : [],
305
- ...W?.phone ? [{
309
+ ...G?.phone ? [{
306
310
  label: A.detailsCustomerPhone,
307
- value: W.phone
311
+ value: G.phone
308
312
  }] : [],
309
- ...G ? [{
313
+ ...K ? [{
310
314
  label: A.detailsCustomerAddress,
311
- value: G
315
+ value: K
312
316
  }] : []
313
317
  ], q = {
314
318
  label: A.detailsPaymentReminders,
315
319
  value: g({
316
320
  paymentReminder: r,
317
321
  overdueReminder: s,
318
- remindersConfigured: !!(N.payment_reminder_id || N.overdue_reminder_id),
322
+ remindersConfigured: !!(P.payment_reminder_id || P.overdue_reminder_id),
319
323
  messages: A
320
324
  })
321
325
  }, J = {
322
326
  label: A.detailsDepositAccount,
323
- value: l ? c(l, A) : u && N.bank_account_id ? "-" : A.detailsNotProvided
327
+ value: l ? c(l, A) : u && P.bank_account_id ? "-" : A.detailsNotProvided
324
328
  }, Y = {
325
329
  label: A.detailsPaymentTerms,
326
- value: N.payment_terms?.name ?? A.detailsPending
327
- }, ne = z ? [
330
+ value: P.payment_terms?.name ?? A.detailsPending
331
+ }, ie = B ? [
328
332
  {
329
333
  label: A.detailsFrequency,
330
- value: _(z.frequency, A)
334
+ value: _(B.frequency, A)
331
335
  },
332
336
  {
333
337
  label: A.detailsInvoiceAmount,
334
- value: P(N.total_amount)
338
+ value: F(P.total_amount)
335
339
  },
336
340
  Y,
337
341
  q,
338
342
  {
339
343
  label: A.detailsPoNumber,
340
- value: N.purchase_order || A.detailsNotProvided
344
+ value: P.purchase_order || A.detailsNotProvided
341
345
  },
342
346
  J
343
347
  ] : [
344
- ...N.document_id ? [{
348
+ ...P.document_id ? [{
345
349
  label: A.detailsInvoiceNumber,
346
- value: N.document_id
350
+ value: P.document_id
347
351
  }] : [],
348
352
  {
349
353
  label: A.detailsInvoiceAmount,
350
- value: P(N.total_amount)
354
+ value: F(P.total_amount)
351
355
  },
352
356
  {
353
357
  label: A.detailsInvoiceDate,
354
- value: I(N.issue_date)
358
+ value: L(P.issue_date)
355
359
  },
356
360
  {
357
361
  label: A.detailsDueDate,
358
- value: I(N.due_date)
362
+ value: L(P.due_date)
359
363
  },
360
364
  Y,
361
365
  q,
362
- ...N.purchase_order ? [{
366
+ ...P.purchase_order ? [{
363
367
  label: A.detailsPoNumber,
364
- value: N.purchase_order
368
+ value: P.purchase_order
365
369
  }] : [],
366
370
  J
367
- ], X = z ? void 0 : i(N), { primary: Z, overflow: Q } = d[L] ?? {
371
+ ], X = B ? void 0 : i(P), { primary: Z, overflow: Q } = j ? d[R] ?? {
368
372
  primary: [],
369
373
  overflow: ["clone"]
370
- };
371
- if (z) {
372
- let e = z.status === "active" || z.status === "paused";
373
- Q = z.status === "active" ? ["pauseRecurrence", "cancelRecurrence"] : z.status === "paused" ? ["resumeRecurrence", "cancelRecurrence"] : [], Z = e ? ["edit"] : [];
374
+ } : D;
375
+ if (B && j) {
376
+ let e = B.status === "active" || B.status === "paused";
377
+ Q = B.status === "active" ? ["pauseRecurrence", "cancelRecurrence"] : B.status === "paused" ? ["resumeRecurrence", "cancelRecurrence"] : [], Z = e ? ["edit"] : [];
374
378
  }
375
- let re = f.has(L) ? {
379
+ let ae = f.has(R) ? {
376
380
  rows: S.map((e) => ({
377
381
  id: e.id,
378
- dateLabel: F(e.paid_at),
379
- amountLabel: P(e.amount)
382
+ dateLabel: I(e.paid_at),
383
+ amountLabel: F(e.amount)
380
384
  })),
381
- totalLabel: P(N.amount_paid),
382
- emptyTone: L === "overdue" ? "danger" : "default",
385
+ totalLabel: F(P.amount_paid),
386
+ emptyTone: R === "overdue" ? "danger" : "default",
383
387
  isLoading: C
384
- } : void 0, ie = z ? {
385
- statusLabel: y(z.status, A),
386
- statusTone: b[z.status] ?? "neutral",
387
- statusIcon: x[z.status],
388
- amountLabel: P(N.total_amount),
389
- amountPeriodLabel: v(z.frequency, A),
390
- startsOnLabel: I(z.start_date),
391
- endsOnLabel: F(z.end_date),
392
- scheduleTitle: A.detailsScheduleTitle.replace("{frequency}", _(z.frequency, A)),
388
+ } : void 0, oe = B ? {
389
+ statusLabel: y(B.status, A),
390
+ statusTone: b[B.status] ?? "neutral",
391
+ statusIcon: x[B.status],
392
+ amountLabel: F(P.total_amount),
393
+ amountPeriodLabel: v(B.frequency, A),
394
+ startsOnLabel: L(B.start_date),
395
+ endsOnLabel: I(B.end_date),
396
+ scheduleTitle: A.detailsScheduleTitle.replace("{frequency}", _(B.frequency, A)),
393
397
  schedule: E({
394
- invoice: N,
395
- recurrence: z,
398
+ invoice: P,
399
+ recurrence: B,
396
400
  iterationInvoices: T,
397
- date: F,
401
+ date: I,
398
402
  statusLabels: k,
399
403
  messages: A,
400
- onOpenReceivable: j
404
+ onOpenReceivable: M
401
405
  })
402
- } : void 0, $ = B ? w(N, B, A) : void 0, ae = B && $ ? {
406
+ } : void 0, $ = V ? w(P, V, A) : void 0, se = V && $ ? {
403
407
  title: $,
404
408
  backLabel: A.detailsSeriesBack.replace("{title}", $),
405
- onOpen: () => j(B.invoice_id)
409
+ onOpen: () => M(V.invoice_id)
406
410
  } : void 0;
407
411
  return {
408
- id: N.id,
409
- type: N.type,
410
- title: z ? w(N, z, A) : N.counterpart_name ?? A.invoiceType,
411
- status: L,
412
- statusTone: p[L] ?? "neutral",
412
+ id: P.id,
413
+ type: P.type,
414
+ title: B ? w(P, B, A) : P.counterpart_name ?? A.invoiceType,
415
+ status: R,
416
+ statusTone: p[R] ?? "neutral",
413
417
  pdfUrl: n,
414
- lineItems: N.line_items.map((e, t) => ({
418
+ lineItems: P.line_items.map((e, t) => ({
415
419
  id: `${e.product.id ?? "item"}-${t}`,
416
420
  name: e.product.name,
417
421
  quantityLabel: String(e.quantity),
418
- unitPriceLabel: P(e.product.price?.value),
419
- totalLabel: P(e.total_before_tax ?? (e.product.price?.value ?? 0) * e.quantity)
422
+ unitPriceLabel: F(e.product.price?.value),
423
+ totalLabel: F(e.total_before_tax ?? (e.product.price?.value ?? 0) * e.quantity)
420
424
  })),
421
425
  panel: {
422
- subtitle: z ? A.detailsSeriesSubtitle : N.document_id ? A.detailsInvoiceSubtitle.replace("{number}", N.document_id) : void 0,
423
- statusLabel: L === "partially_paid" ? k.issued : k[L] ?? k.unknown,
424
- recurring: !!N.recurrence_id || L === "recurring",
425
- overdueLabel: V > 0 ? A.detailsDaysOverdue.replace("{days}", String(V)) : void 0,
426
- amountTone: H,
427
- amountRows: U,
428
- issueDateLabel: I(N.issue_date),
429
- dueDateLabel: R ? F(N.updated_at) : I(N.due_date),
430
- dueDateCaption: R ? A.detailsCancelledOnCaption : A.detailsDueDate,
431
- paymentHistory: re,
432
- customerContact: K,
433
- recurringSeries: ie,
434
- seriesLink: ae,
435
- billingItems: ne,
436
- lineItemsSection: z ? void 0 : {
437
- countLabel: String(N.line_items.length),
438
- totals: te(N, P, A)
426
+ subtitle: B ? A.detailsSeriesSubtitle : P.document_id ? A.detailsInvoiceSubtitle.replace("{number}", P.document_id) : void 0,
427
+ statusLabel: R === "partially_paid" ? k.issued : k[R] ?? k.unknown,
428
+ recurring: !!P.recurrence_id || R === "recurring",
429
+ overdueLabel: H > 0 ? A.detailsDaysOverdue.replace("{days}", String(H)) : void 0,
430
+ amountTone: U,
431
+ amountRows: W,
432
+ issueDateLabel: L(P.issue_date),
433
+ dueDateLabel: z ? I(P.updated_at) : L(P.due_date),
434
+ dueDateCaption: z ? A.detailsCancelledOnCaption : A.detailsDueDate,
435
+ paymentHistory: ae,
436
+ customerContact: re,
437
+ recurringSeries: oe,
438
+ seriesLink: se,
439
+ billingItems: ie,
440
+ lineItemsSection: B ? void 0 : {
441
+ countLabel: String(P.line_items.length),
442
+ totals: ne(P, F, A)
439
443
  },
440
444
  notes: X && {
441
445
  ...X,
442
446
  countLabel: String([X.opening, X.closing].filter(Boolean).length)
443
447
  },
444
- attachments: t(N, A),
448
+ attachments: t(P, A),
445
449
  auditHistory: O,
446
450
  primaryActions: Z,
447
451
  overflowActions: Q
@@ -0,0 +1,13 @@
1
+ import { hasAnyScope as e } from "../../../../../shared/data-access/dist/lib/hasAnyScope.js";
2
+ import { Scope as t } from "../../../../../shared/data-access/dist/lib/scopes.js";
3
+ import "../../../../../shared/data-access/dist/index.js";
4
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/permissions.js
5
+ function n(n) {
6
+ let r = new Set(n ?? []);
7
+ return {
8
+ canRead: e(r, [t.InvoiceReadOrg]),
9
+ canWrite: e(r, [t.InvoiceWriteOrg])
10
+ };
11
+ }
12
+ //#endregion
13
+ export { n as getReceivablePermissions };
@@ -118,6 +118,7 @@ function g({ messages: g }) {
118
118
  isOpen: !!_,
119
119
  view: $,
120
120
  open: H,
121
+ close: U,
121
122
  skip: G,
122
123
  changeSubject: w,
123
124
  changeMessage: E,
@@ -4,40 +4,40 @@
4
4
  "use client";
5
5
  import { buildReceivableAuditHistory as e } from "../../../../../shared/util/dist/lib/auditHistory/buildReceivableAuditHistory.js";
6
6
  import { hasAnyScope as t } from "../../../../../shared/data-access/dist/lib/hasAnyScope.js";
7
- import { Scope as n } from "../../../../../shared/data-access/dist/lib/scopes.js";
7
+ import { Scope as ee } from "../../../../../shared/data-access/dist/lib/scopes.js";
8
8
  import "../../../../../shared/data-access/dist/index.js";
9
- import { useWidgetConfig as ee } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
- import { useOrganizationUserNames as r } from "../../../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
9
+ import { useWidgetConfig as te } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useOrganizationUserNames as n } from "../../../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
11
11
  import "../../../../../shared/feature/dist/index.js";
12
- import { RECEIVABLE_DETAILS_SECTION as i } from "../../../../ui/dist/index25.js";
12
+ import { RECEIVABLE_DETAILS_SECTION as r } from "../../../../ui/dist/index25.js";
13
13
  import "../../../../ui/dist/index.js";
14
- import { useAllReceivableHistoryQuery as a } from "../../../../data-access/dist/index3.js";
15
- import { usePaymentAccountsQuery as o } from "../../../../data-access/dist/index4.js";
16
- import { useReceivablePaymentRecordsQuery as s } from "../../../../data-access/dist/index9.js";
17
- import { useReceivablePdfLinkQuery as c, useReceivableQuery as te, useReceivablesByIdQueries as l } from "../../../../data-access/dist/index11.js";
18
- import { useOverdueRemindersQuery as u, usePaymentRemindersQuery as ne, useRecurrenceQuery as d } from "../../../../data-access/dist/index12.js";
14
+ import { useAllReceivableHistoryQuery as ne } from "../../../../data-access/dist/index3.js";
15
+ import { usePaymentAccountsQuery as i } from "../../../../data-access/dist/index4.js";
16
+ import { useReceivablePaymentRecordsQuery as a } from "../../../../data-access/dist/index9.js";
17
+ import { useReceivablePdfLinkQuery as o, useReceivableQuery as s, useReceivablesByIdQueries as re } from "../../../../data-access/dist/index11.js";
18
+ import { useOverdueRemindersQuery as ie, usePaymentRemindersQuery as c, useRecurrenceQuery as l } from "../../../../data-access/dist/index12.js";
19
19
  import "../../../../data-access/dist/index.js";
20
- import { buildReceivableAuditHistoryLabels as f } from "./auditHistory/labels.js";
21
- import { getBankAccountPermissions as re } from "./bankAccounts.js";
22
- import { buildReceivableDetailsView as p, buildUnsupportedDetailsView as m } from "./details.js";
23
- import { useMemo as h, useState as g } from "react";
20
+ import { buildReceivableAuditHistoryLabels as u } from "./auditHistory/labels.js";
21
+ import { getBankAccountPermissions as d } from "./bankAccounts.js";
22
+ import { buildReceivableDetailsView as f, buildUnsupportedDetailsView as p } from "./details.js";
23
+ import { useMemo as m, useState as h } from "react";
24
24
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js
25
- var _ = [i.attachments];
26
- function v({ selectedReceivableId: v, enabled: y = !0, messages: b, statusLabels: x, auditHistoryLabels: S, onOpenReceivable: C }) {
27
- let { initResponse: w } = ee(), T = h(() => re(w?.scopes), [w?.scopes]), E = te(v, { enabled: y }), D = E.data, O = D?.type === "invoice" ? D : void 0, k = c(v, { enabled: y && !!O }), ie = ne({ enabled: y && !!O?.payment_reminder_id }), ae = u({ enabled: y && !!O?.overdue_reminder_id }), A = o({
28
- enabled: y && !!O,
25
+ var g = [r.attachments];
26
+ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, messages: b, statusLabels: x, auditHistoryLabels: S, onOpenReceivable: C }) {
27
+ let { initResponse: w } = te(), T = m(() => d(w?.scopes), [w?.scopes]), E = s(_, { enabled: v }), D = E.data, O = D?.type === "invoice" ? D : void 0, k = o(_, { enabled: v && !!O }), ae = c({ enabled: v && !!O?.payment_reminder_id }), oe = ie({ enabled: v && !!O?.overdue_reminder_id }), A = i({
28
+ enabled: v && !!O,
29
29
  canReadEmbedded: T.canReadEmbedded,
30
30
  canReadExternal: T.canReadExternal
31
- }), j = d(y ? O?.recurrence_id : void 0), M = j.data, N = s(O?.id, { enabled: y }), P = a(O?.id, { enabled: y && !!O }), F = h(() => O?.status === "recurring" ? (M?.iterations ?? []).flatMap((e) => e.issued_invoice_id ? [e.issued_invoice_id] : []) : [], [O?.status, M?.iterations]), I = l(F, { enabled: y }), L = h(() => new Map(I.filter((e) => !!e).map((e) => [e.id, e])), [I]), [R, z] = g(_), [B, V] = g(v);
32
- B !== v && (V(v), z(_));
33
- let H = R.includes(i.auditHistory), U = h(() => P.data?.data ?? [], [P.data]), W = U.some((e) => e.recorded_by === "user" && !!e.entity_user_id), G = t(w?.scopes, [n.UserReadOrg]), { userNames: K, isError: q } = r({ enabled: y && H && G && W }), J = h(() => ({
34
- ...f(b, x),
31
+ }), j = l(v ? O?.recurrence_id : void 0), M = j.data, N = a(O?.id, { enabled: v }), P = ne(O?.id, { enabled: v && !!O }), F = m(() => O?.status === "recurring" ? (M?.iterations ?? []).flatMap((e) => e.issued_invoice_id ? [e.issued_invoice_id] : []) : [], [O?.status, M?.iterations]), I = re(F, { enabled: v }), L = m(() => new Map(I.filter((e) => !!e).map((e) => [e.id, e])), [I]), [R, z] = h(g), [B, V] = h(_);
32
+ B !== _ && (V(_), z(g));
33
+ let H = R.includes(r.auditHistory), U = m(() => P.data?.data ?? [], [P.data]), W = U.some((e) => e.recorded_by === "user" && !!e.entity_user_id), G = t(w?.scopes, [ee.UserReadOrg]), { userNames: K, isError: q } = n({ enabled: v && H && G && W }), J = m(() => ({
34
+ ...u(b, x),
35
35
  ...S
36
36
  }), [
37
37
  b,
38
38
  x,
39
39
  S
40
- ]), Y = h(() => {
40
+ ]), Y = m(() => {
41
41
  let t = O ? e(U, K, J, {
42
42
  documentType: "invoice",
43
43
  currency: O.currency,
@@ -62,11 +62,11 @@ function v({ selectedReceivableId: v, enabled: y = !0, messages: b, statusLabels
62
62
  G,
63
63
  q,
64
64
  W
65
- ]), X = ie.data?.data.find((e) => e.id === O?.payment_reminder_id), Z = ae.data?.data.find((e) => e.id === O?.overdue_reminder_id), Q = A.paymentAccounts.find((e) => e.id === O?.bank_account_id), $ = k.data?.file_url || void 0;
65
+ ]), X = ae.data?.data.find((e) => e.id === O?.payment_reminder_id), Z = oe.data?.data.find((e) => e.id === O?.overdue_reminder_id), Q = A.paymentAccounts.find((e) => e.id === O?.bank_account_id), $ = k.data?.file_url || void 0;
66
66
  return {
67
67
  receivable: D,
68
68
  recurrence: M,
69
- detailsView: h(() => p({
69
+ detailsView: m(() => f({
70
70
  receivable: D,
71
71
  pdfUrl: $,
72
72
  paymentReminder: X,
@@ -80,6 +80,7 @@ function v({ selectedReceivableId: v, enabled: y = !0, messages: b, statusLabels
80
80
  auditHistory: Y,
81
81
  statusLabels: x,
82
82
  messages: b,
83
+ canWrite: y,
83
84
  onOpenReceivable: C
84
85
  }), [
85
86
  D,
@@ -95,9 +96,10 @@ function v({ selectedReceivableId: v, enabled: y = !0, messages: b, statusLabels
95
96
  Y,
96
97
  x,
97
98
  b,
99
+ y,
98
100
  C
99
101
  ]),
100
- unsupportedView: h(() => m(D, b), [D, b]),
102
+ unsupportedView: m(() => p(D, b), [D, b]),
101
103
  openSections: R,
102
104
  setOpenSections: z,
103
105
  isLoading: E.isLoading || k.isLoading || j.isLoading,
@@ -105,4 +107,4 @@ function v({ selectedReceivableId: v, enabled: y = !0, messages: b, statusLabels
105
107
  };
106
108
  }
107
109
  //#endregion
108
- export { v as useReceivableDetails };
110
+ export { _ as useReceivableDetails };
@@ -7,36 +7,36 @@ import "../../../../data-access/dist/index.js";
7
7
  import { buildReceivableStatusCardsView as t } from "./statusCards.js";
8
8
  import { useMemo as n } from "react";
9
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js
10
- function r({ enabled: r, statusFilter: i, messages: a, statusLabels: o }) {
11
- let s = e({
10
+ function r({ enabled: r, visible: i = r, statusFilter: a, messages: o, statusLabels: s }) {
11
+ let c = e({
12
12
  enabled: r,
13
13
  dimension: "status",
14
14
  metric: "id",
15
15
  aggregation_function: "count",
16
16
  type: "invoice"
17
- }), c = e({
17
+ }), l = e({
18
18
  enabled: r,
19
19
  dimension: "status",
20
20
  metric: "total_amount",
21
21
  aggregation_function: "summary",
22
22
  type: "invoice"
23
- }), l = s.data?.data, u = c.data?.data, d = s.isPending || c.isPending;
23
+ }), u = c.data?.data, d = l.data?.data, f = c.isPending || l.isPending;
24
24
  return n(() => {
25
- if (r) return d ? { kind: "loading" } : t({
26
- counts: l ?? [],
27
- amounts: u ?? [],
28
- statusFilter: i,
29
- statusLabels: o,
30
- fallback: a.notAvailable
25
+ if (i) return f ? { kind: "loading" } : t({
26
+ counts: u ?? [],
27
+ amounts: d ?? [],
28
+ statusFilter: a,
29
+ statusLabels: s,
30
+ fallback: o.notAvailable
31
31
  });
32
32
  }, [
33
- u,
34
- l,
35
- r,
36
33
  d,
37
- a.notAvailable,
38
- i,
39
- o
34
+ u,
35
+ f,
36
+ o.notAvailable,
37
+ a,
38
+ s,
39
+ i
40
40
  ]);
41
41
  }
42
42
  //#endregion
@@ -11,79 +11,81 @@ import { useReceivableStatusCards as o } from "./useReceivableStatusCards.js";
11
11
  import { useCallback as s, useEffect as c, useMemo as l, useState as u } from "react";
12
12
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js
13
13
  var d = [];
14
- function f({ activeTab: f, initialCounterpartId: m, messages: h, statusLabels: g, filterLabels: _ }) {
15
- let [v, y] = u([]), [b, x] = u(10), [S, C] = u(), [w, T] = u(""), [E, D] = u(""), [O, k] = u("all"), A = f === "invoices", j = s(() => C(void 0), []), M = i({
14
+ function f({ activeTab: f, initialCounterpartId: m, messages: h, statusLabels: g, filterLabels: _, enabled: v = !0, visible: y = v }) {
15
+ let [b, x] = u([]), [S, C] = u(10), [w, T] = u(), [E, D] = u(""), [O, k] = u(""), [A, j] = u("all"), M = f === "invoices", N = s(() => T(void 0), []), P = i({
16
16
  initialCounterpartId: m,
17
- search: w,
18
- onSearchChange: T,
19
- onFiltersChange: j,
17
+ search: E,
18
+ onSearchChange: D,
19
+ onFiltersChange: N,
20
20
  statusLabels: g,
21
21
  labels: _
22
- }), N = M.reset;
22
+ }), F = P.reset;
23
23
  c(() => {
24
- C(void 0), k("all"), T(""), D(""), N();
25
- }, [f, N]), c(() => {
24
+ T(void 0), j("all"), D(""), k(""), F();
25
+ }, [f, F]), c(() => {
26
26
  let e = setTimeout(() => {
27
- D(w), C(void 0);
27
+ k(E), T(void 0);
28
28
  }, 300);
29
29
  return () => clearTimeout(e);
30
- }, [w]);
31
- let P = v[0]?.id, F = P ? p[P] : void 0, I = v[0] ? v[0].desc ? "desc" : "asc" : void 0, L = r({
30
+ }, [E]);
31
+ let I = b[0]?.id, L = I ? p[I] : void 0, R = b[0] ? b[0].desc ? "desc" : "asc" : void 0, z = r({
32
+ enabled: v,
32
33
  type: n(f),
33
- limit: b,
34
- pagination_token: S,
35
- search_text: E || void 0,
36
- ...A ? M.query : { status: O === "all" ? void 0 : O },
37
- ...F ? {
38
- sort: F,
39
- order: I
34
+ limit: S,
35
+ pagination_token: w,
36
+ search_text: O || void 0,
37
+ ...M ? P.query : { status: A === "all" ? void 0 : A },
38
+ ...L ? {
39
+ sort: L,
40
+ order: R
40
41
  } : {}
41
- }), R = o({
42
- enabled: A,
43
- statusFilter: M.cardStatus,
42
+ }), B = o({
43
+ enabled: v && M,
44
+ visible: y && M,
45
+ statusFilter: P.cardStatus,
44
46
  messages: h,
45
47
  statusLabels: g
46
- }), z = L.data?.data ?? d, B = l(() => new Map(z.map((e) => [e.id, e])), [z]), V = s((e) => B.get(e), [B]), H = a(z), U = l(() => e({
47
- receivables: z,
48
+ }), V = z.data?.data ?? d, H = l(() => new Map(V.map((e) => [e.id, e])), [V]), U = s((e) => H.get(e), [H]), W = a(V), G = l(() => e({
49
+ receivables: V,
48
50
  messages: h,
49
- customerNames: H
51
+ customerNames: W
50
52
  }), [
51
- H,
53
+ W,
52
54
  h,
53
- z
54
- ]), W = A ? M.isFiltering : !!E || O !== "all", G = s((e) => {
55
- let t = typeof e == "function" ? e(v) : e;
56
- y(t), C(void 0);
57
- }, [v]), K = s((e) => {
58
- x(e), C(void 0);
59
- }, []), q = s((e) => {
60
- k(e), C(void 0);
61
- }, []), J = s(() => C(L.data?.next_pagination_token ?? void 0), [L.data?.next_pagination_token]), Y = s(() => C(L.data?.prev_pagination_token ?? void 0), [L.data?.prev_pagination_token]), X = s(() => {
62
- L.refetch();
63
- }, [L]);
55
+ V
56
+ ]), K = M ? P.isFiltering : !!O || A !== "all", q = s((e) => {
57
+ let t = typeof e == "function" ? e(b) : e;
58
+ x(t), T(void 0);
59
+ }, [b]), J = s((e) => {
60
+ C(e), T(void 0);
61
+ }, []), Y = s((e) => {
62
+ j(e), T(void 0);
63
+ }, []), X = s(() => T(z.data?.next_pagination_token ?? void 0), [z.data?.next_pagination_token]), Z = s(() => T(z.data?.prev_pagination_token ?? void 0), [z.data?.prev_pagination_token]), Q = s(() => {
64
+ z.refetch();
65
+ }, [z]);
64
66
  return {
65
- rows: U,
66
- isLoading: L.isLoading,
67
- isError: L.isError,
68
- sorting: v,
69
- onSortingChange: G,
70
- pageSize: b,
71
- onPageSizeChange: K,
72
- hasNextPage: !!L.data?.next_pagination_token,
73
- hasPrevPage: !!L.data?.prev_pagination_token,
74
- onNextPage: J,
75
- onPrevPage: Y,
76
- searchValue: w,
77
- onSearchChange: T,
78
- statusFilter: O,
79
- statusOptions: t(O),
80
- onStatusFilterChange: q,
81
- statusCards: R,
82
- onStatusCardSelect: M.selectStatusCard,
83
- invoicesFilterBar: A ? M.filterBar : void 0,
84
- isFiltering: W,
85
- onRetry: X,
86
- getReceivableById: V
67
+ rows: G,
68
+ isLoading: z.isLoading,
69
+ isError: z.isError,
70
+ sorting: b,
71
+ onSortingChange: q,
72
+ pageSize: S,
73
+ onPageSizeChange: J,
74
+ hasNextPage: !!z.data?.next_pagination_token,
75
+ hasPrevPage: !!z.data?.prev_pagination_token,
76
+ onNextPage: X,
77
+ onPrevPage: Z,
78
+ searchValue: E,
79
+ onSearchChange: D,
80
+ statusFilter: A,
81
+ statusOptions: t(A),
82
+ onStatusFilterChange: Y,
83
+ statusCards: B,
84
+ onStatusCardSelect: P.selectStatusCard,
85
+ invoicesFilterBar: M ? P.filterBar : void 0,
86
+ isFiltering: K,
87
+ onRetry: Q,
88
+ getReceivableById: U
87
89
  };
88
90
  }
89
91
  var p = {