@tesouro/embedded-components-react 0.6.3 → 0.6.5

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.
@@ -64,55 +64,55 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
64
64
  let gt = l(), _t = re(), vt = ie(), yt = oe(), bt = u(), xt = o(), y = g("draft"), St = g(!1), [Ct, wt] = _(), b = g(!1), x = g(!1), Tt = g(null), S = g(void 0), C = g([]), Et = g(""), [w, T] = _(!1), [E, Dt] = _("create"), [Ot, kt] = _(), [At, jt] = _(), [D, O] = _(() => Ve()), k = g(D), [Mt, A] = _(!1), [Nt, j] = _({}), [Pt, Ft] = _("none"), It = Te(), M = we(), N = M.data?.data, { unitNamesById: P } = It, [Lt, Rt] = _(), [F, zt] = _(!1), Bt = g(!1), I = g(!1), L = g(!1), R = g({
65
65
  lines: !1,
66
66
  discount: !1
67
- }), [Vt, z] = _(!1), Ht = h(() => t(), []), Ut = h(() => ({
67
+ }), [Vt, z] = _(!1), [Ht, Ut] = _(!1), Wt = h(() => t(), []), Gt = h(() => ({
68
68
  ...r,
69
69
  ...ft
70
- }), [ft]), Wt = s(D.customerId), Gt = a(D.customerId || void 0), Kt = Wt.data?.data?.[0], { billingAddressId: qt, billingAddress: Jt, shippingAddressId: Yt } = qe({
70
+ }), [ft]), Kt = s(D.customerId), qt = a(D.customerId || void 0), Jt = Kt.data?.data?.[0], { billingAddressId: Yt, billingAddress: Xt, shippingAddressId: Zt } = qe({
71
71
  values: D,
72
- counterpart: Gt.data,
73
- addresses: Wt.data?.data
74
- }), B = !!D.customerId && (Wt.isLoading || Gt.isLoading), V = Qe({
72
+ counterpart: qt.data,
73
+ addresses: Kt.data?.data
74
+ }), B = !!D.customerId && (Kt.isLoading || qt.isLoading), V = Qe({
75
75
  counterpartId: D.customerId,
76
- billingAddressId: qt,
77
- billingCountry: Jt?.country,
76
+ billingAddressId: Yt,
77
+ billingCountry: Xt?.country,
78
78
  inlineCustomerType: v && !D.customerId && D.customerName.trim() ? ee : void 0
79
- }), Xt = V.isLoading || B, Zt = p((e) => {
79
+ }), Qt = V.isLoading || B, $t = p((e) => {
80
80
  O((t) => ({
81
81
  ...t,
82
82
  attachments: e(t.attachments)
83
83
  }));
84
84
  }, []), H = rt({
85
85
  attachments: D.attachments,
86
- setAttachments: Zt,
86
+ setAttachments: $t,
87
87
  receivableId: Ot
88
- }), { reset: U, discardUploads: Qt, commitRemovals: $t } = H, en = D.type === "invoice" ? Ce({
88
+ }), { reset: U, discardUploads: en, commitRemovals: tn } = H, nn = D.type === "invoice" ? Ce({
89
89
  attachments: D.attachments,
90
90
  pendingUploads: H.pendingUploads,
91
91
  isCountLimitReached: H.isCountLimitReached,
92
92
  isRecurring: f(D),
93
93
  messages: d
94
- }) : void 0, tn = p((e) => {
94
+ }) : void 0, rn = p((e) => {
95
95
  e && O((t) => ut(t, e));
96
- }, []), nn = c({
96
+ }, []), an = c({
97
97
  view: Pt,
98
98
  setView: Ft,
99
99
  selectedId: D.customerId || void 0,
100
- setSelectedId: tn,
101
- messages: Ut,
100
+ setSelectedId: rn,
101
+ messages: Gt,
102
102
  counterpartType: "customer",
103
103
  counterpart: void 0,
104
- primaryAddress: Kt
105
- }), { openCreate: rn, setValues: an } = nn, on = p(() => {
106
- rn(), an((e) => ne(e, {
104
+ primaryAddress: Jt
105
+ }), { openCreate: on, setValues: sn } = an, cn = p(() => {
106
+ on(), sn((e) => ne(e, {
107
107
  name: D.customerName,
108
108
  email: D.customerEmail
109
109
  }));
110
110
  }, [
111
- rn,
112
- an,
111
+ on,
112
+ sn,
113
113
  D.customerName,
114
114
  D.customerEmail
115
- ]), sn = p((e) => O((t) => {
115
+ ]), ln = p((e) => O((t) => {
116
116
  let n = e({
117
117
  paymentTermsId: t.paymentTermsId,
118
118
  paymentTermsCustomDate: t.paymentTermsCustomDate
@@ -122,14 +122,14 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
122
122
  ...n,
123
123
  ...n.paymentTermsId === "receipt_due" ? { paymentReminderId: "" } : {}
124
124
  };
125
- }), []), cn = it({
125
+ }), []), un = it({
126
126
  paymentTermsId: D.paymentTermsId,
127
127
  paymentTermsCustomDate: D.paymentTermsCustomDate,
128
128
  issueDate: D.issueDate,
129
129
  isRecurring: D.type === "invoice" && f(D),
130
130
  messages: d,
131
- onChange: sn
132
- }), ln = cn.reset, un = p((e, { automatic: t = !1 } = {}) => {
131
+ onChange: ln
132
+ }), dn = un.reset, fn = p((e, { automatic: t = !1 } = {}) => {
133
133
  t && (k.current = {
134
134
  ...k.current,
135
135
  ...e
@@ -143,8 +143,8 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
143
143
  bankAccountType: D.bankAccountType,
144
144
  embeddedBankName: pt,
145
145
  messages: d,
146
- onSelect: un
147
- }), dn = W.reset, fn = ae(At), G = At ? fn.data : void 0, K = ke(G), pn = K > 0, q = !!At && fn.isLoading, J = g(void 0);
146
+ onSelect: fn
147
+ }), pn = W.reset, mn = ae(At), G = At ? mn.data : void 0, K = ke(G), hn = K > 0, q = !!At && mn.isLoading, J = g(void 0);
148
148
  m(() => {
149
149
  if (!G || J.current === G.id) return;
150
150
  J.current = G.id;
@@ -157,21 +157,21 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
157
157
  ...e
158
158
  }));
159
159
  }, [G]);
160
- let mn = p((e) => O(e), []), hn = p((e) => j((t) => {
160
+ let gn = p((e) => O(e), []), _n = p((e) => j((t) => {
161
161
  if (!e.some((e) => e in t)) return t;
162
162
  let n = { ...t };
163
163
  return e.forEach((e) => delete n[e]), n;
164
- }), []), gn = g([]), _n = p((e) => {
164
+ }), []), vn = g([]), yn = p((e) => {
165
165
  if (!F) {
166
- hn(e);
166
+ _n(e);
167
167
  return;
168
168
  }
169
- gn.current.push(...e);
170
- }, [hn, F]);
169
+ vn.current.push(...e);
170
+ }, [_n, F]);
171
171
  m(() => {
172
- let e = gn.current;
172
+ let e = vn.current;
173
173
  if (!e.length) return;
174
- gn.current = [];
174
+ vn.current = [];
175
175
  let t = je({
176
176
  fields: D,
177
177
  issuedCount: K,
@@ -188,18 +188,18 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
188
188
  d,
189
189
  D
190
190
  ]);
191
- let vn = at({
191
+ let bn = at({
192
192
  values: D,
193
193
  errors: Nt,
194
- lockSchedule: pn,
194
+ lockSchedule: hn,
195
195
  messages: d,
196
- onChange: mn,
197
- onClearErrors: hn,
198
- onRevalidateErrors: _n
199
- }), Y = vn.reset, yn = p((e) => O((t) => ({
196
+ onChange: gn,
197
+ onClearErrors: _n,
198
+ onRevalidateErrors: yn
199
+ }), Y = bn.reset, xn = p((e) => O((t) => ({
200
200
  ...t,
201
201
  ...e
202
- })), []), X = xt.isPending || gt.isPending || _t.isPending || vt.isPending || yt.isPending || bt.isPending, bn = st({
202
+ })), []), X = xt.isPending || gt.isPending || _t.isPending || vt.isPending || yt.isPending || bt.isPending, Sn = st({
203
203
  open: w,
204
204
  isInvoice: D.type === "invoice",
205
205
  disabled: X,
@@ -208,43 +208,43 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
208
208
  paymentReminderId: D.paymentReminderId,
209
209
  overdueReminderId: D.overdueReminderId,
210
210
  messages: d,
211
- onSelect: yn
212
- }), xn = bn.reset, Sn = p(() => {
211
+ onSelect: xn
212
+ }), Cn = Sn.reset, wn = p(() => {
213
213
  C.current = [], Rt(void 0), Dt("create"), kt(void 0), jt(void 0), J.current = void 0, S.current = void 0, y.current = "draft", b.current = !1, x.current = !1, O(Ve()), A(!1), j({}), zt(!1), z(!1), R.current = {
214
214
  lines: !1,
215
215
  discount: !1
216
216
  }, U(), Y();
217
- }, [U, Y]), Cn = p((e = "invoice", { customerId: t = "" } = {}) => {
218
- ln(), dn(), Y();
217
+ }, [U, Y]), Tn = p((e = "invoice", { customerId: t = "" } = {}) => {
218
+ dn(), pn(), Y();
219
219
  let n = {
220
220
  ...Ve(),
221
221
  type: e,
222
222
  customerId: t
223
223
  };
224
- xn(Ze(n)), C.current = [], S.current = void 0, y.current = "draft", b.current = !1, x.current = !1, J.current = void 0, Rt(void 0), Dt("create"), kt(void 0), jt(void 0), k.current = n, O(n), A(!1), j({}), U(), zt(!1), z(!1), R.current = {
224
+ Cn(Ze(n)), C.current = [], S.current = void 0, y.current = "draft", b.current = !1, x.current = !1, J.current = void 0, Rt(void 0), Dt("create"), kt(void 0), jt(void 0), k.current = n, O(n), A(!1), j({}), U(), zt(!1), z(!1), R.current = {
225
225
  lines: !1,
226
226
  discount: !1
227
227
  }, T(!0);
228
228
  }, [
229
229
  U,
230
- ln,
231
230
  dn,
231
+ pn,
232
232
  Y,
233
- xn
234
- ]), wn = p((e, { highlightForIssue: t = !1 } = {}) => {
233
+ Cn
234
+ ]), En = p((e, { highlightForIssue: t = !1 } = {}) => {
235
235
  if (e.type === "credit_note") return;
236
- ln(), dn(), Y();
236
+ dn(), pn(), Y();
237
237
  let n = Ke(e, N);
238
- xn(Ze(n)), C.current = e.line_items, Et.current = e.currency, S.current = void 0, y.current = "draft", b.current = !1, x.current = t, J.current = void 0, Rt(void 0), Dt("edit"), kt(e.id), jt(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), k.current = n, O(n), A(!1), j({}), zt(!1), z(!1), R.current = {
238
+ Cn(Ze(n)), C.current = e.line_items, Et.current = e.currency, S.current = void 0, y.current = "draft", b.current = !1, x.current = t, J.current = void 0, Rt(void 0), Dt("edit"), kt(e.id), jt(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), k.current = n, O(n), A(!1), j({}), zt(!1), z(!1), R.current = {
239
239
  lines: !1,
240
240
  discount: !1
241
241
  }, U(), T(!0);
242
242
  }, [
243
243
  U,
244
- ln,
245
244
  dn,
245
+ pn,
246
246
  Y,
247
- xn,
247
+ Cn,
248
248
  N
249
249
  ]);
250
250
  m(() => {
@@ -259,9 +259,9 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
259
259
  };
260
260
  }));
261
261
  }, [N]);
262
- let Z = H.isUploading, Tn = p(() => {
263
- Z || (Qt(), A(!1), T(!1), j({}));
264
- }, [Qt, Z]), En = p(() => {
262
+ let Z = H.isUploading, Dn = p(() => {
263
+ Z || (en(), A(!1), T(!1), j({}));
264
+ }, [en, Z]), On = p(() => {
265
265
  if (Mt) {
266
266
  A(!1);
267
267
  return;
@@ -274,16 +274,16 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
274
274
  A(!0);
275
275
  return;
276
276
  }
277
- Tn();
277
+ Dn();
278
278
  }, [
279
- Tn,
279
+ Dn,
280
280
  Z,
281
281
  d.attachmentsUploading,
282
282
  Mt,
283
283
  D
284
- ]), Dn = p((e) => {
284
+ ]), kn = p((e) => {
285
285
  let t = { ...e };
286
- t.taxRate !== void 0 && (t.taxRate = _e(t.taxRate), L.current = !0), t.type !== void 0 && t.type !== "invoice" && Qt(), t.discount !== void 0 && F && (I.current = !0), t.discountType !== void 0 && (I.current = !0), t.currency !== void 0 && (Bt.current = !0), O((e) => {
286
+ t.taxRate !== void 0 && (t.taxRate = _e(t.taxRate), L.current = !0), t.type !== void 0 && t.type !== "invoice" && en(), t.discount !== void 0 && Ut(!1), t.discount !== void 0 && F && (I.current = !0), t.discountType !== void 0 && (I.current = !0), t.currency !== void 0 && (Bt.current = !0), O((e) => {
287
287
  let n = {
288
288
  ...t.customerId === void 0 ? e : ut(e, t.customerId),
289
289
  ...t
@@ -297,7 +297,13 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
297
297
  currency: n.currency
298
298
  })), n;
299
299
  });
300
- }, [Qt, F]), On = p(() => z(!0), []), kn = p(() => {
300
+ }, [en, F]), An = p(() => {
301
+ z(!0), Ut(Fe(D.discount, D.discountType, D.currency) === 0);
302
+ }, [
303
+ D.discount,
304
+ D.discountType,
305
+ D.currency
306
+ ]), jn = p(() => {
301
307
  z(!1), I.current = !0, O((e) => ({
302
308
  ...e,
303
309
  discount: Ne({
@@ -306,7 +312,7 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
306
312
  currency: e.currency
307
313
  })
308
314
  }));
309
- }, []), An = p(() => {
315
+ }, []), Mn = p(() => {
310
316
  let e = Ye({
311
317
  values: D,
312
318
  messages: d,
@@ -321,7 +327,7 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
321
327
  v,
322
328
  d,
323
329
  D
324
- ]), jn = p(() => {
330
+ ]), Nn = p(() => {
325
331
  L.current = !0, O((e) => {
326
332
  let t = le(e.taxRate);
327
333
  return t === e.taxRate ? e : {
@@ -353,13 +359,13 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
353
359
  d,
354
360
  D
355
361
  ]);
356
- let Mn = p((e, t) => {
362
+ let Pn = p((e, t) => {
357
363
  let { unit: n, ...r } = t, i = ge(r);
358
364
  i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (L.current = !0), Q((t) => t.map((t) => t.id === e ? {
359
365
  ...t,
360
366
  ...i
361
367
  } : t), { validate: F });
362
- }, [Q, F]), Nn = p((e, t) => {
368
+ }, [Q, F]), Fn = p((e, t) => {
363
369
  Q((n) => n.map((n) => n.id === e ? {
364
370
  ...n,
365
371
  ...pe({
@@ -372,39 +378,39 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
372
378
  Q,
373
379
  P,
374
380
  D.currency
375
- ]), Pn = p((e, t) => {
381
+ ]), In = p((e, t) => {
376
382
  t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
377
383
  ...n,
378
384
  ...t.patch
379
385
  } : n), { validate: !0 });
380
- }, [Q]), Fn = p((e, t) => {
386
+ }, [Q]), Ln = p((e, t) => {
381
387
  let n = D.lineItems.find((t) => t.id === e);
382
- n && Pn(e, ce({
388
+ n && In(e, ce({
383
389
  lineItem: n,
384
390
  field: t,
385
391
  rowCount: D.lineItems.length,
386
392
  currency: D.currency
387
393
  }));
388
394
  }, [
389
- Pn,
395
+ In,
390
396
  D.currency,
391
397
  D.lineItems
392
- ]), In = p((e, t) => {
398
+ ]), Rn = p((e, t) => {
393
399
  let n = D.lineItems.find((t) => t.id === e);
394
- n && Pn(e, ve({
400
+ n && In(e, ve({
395
401
  lineItem: n,
396
402
  step: t,
397
403
  rowCount: D.lineItems.length
398
404
  }));
399
- }, [Pn, D.lineItems]), Ln = p(() => {
405
+ }, [In, D.lineItems]), zn = p(() => {
400
406
  let e = de(D.currency);
401
407
  Rt(e.id), O((t) => ({
402
408
  ...t,
403
409
  lineItems: [...t.lineItems, e]
404
410
  }));
405
- }, [D.currency]), Rn = p((e) => {
411
+ }, [D.currency]), Bn = p((e) => {
406
412
  Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
407
- }, [Q]), zn = p((e, t) => e.type === "invoice" && (t === "issue" || Me(e) && K === 0), [K]), Bn = p((e, t) => ({
413
+ }, [Q]), Vn = p((e, t) => e.type === "invoice" && (t === "issue" || Me(e) && K === 0), [K]), Hn = p((e, t) => ({
408
414
  ...Ye({
409
415
  values: e,
410
416
  messages: d,
@@ -421,7 +427,7 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
421
427
  v,
422
428
  K,
423
429
  d
424
- ]), Vn = p(() => {
430
+ ]), Un = p(() => {
425
431
  requestAnimationFrame(() => {
426
432
  let e = Tt.current, t = e?.querySelector("[aria-invalid=\"true\"], [data-invalid=\"true\"]");
427
433
  if (!e || !t) return;
@@ -431,31 +437,31 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
431
437
  behavior: "smooth"
432
438
  });
433
439
  });
434
- }, []), Hn = p((e, t) => {
440
+ }, []), Wn = p((e, t) => {
435
441
  j(e), zt(!0), b.current = t, R.current = {
436
442
  lines: !0,
437
443
  discount: !0
438
- }, Vn();
439
- }, [Vn]), Un = !At || D.frequency !== "once" || fn.isError;
444
+ }, Un();
445
+ }, [Un]), Gn = !At || D.frequency !== "once" || mn.isError;
440
446
  m(() => {
441
- if (!w || !x.current || B || q || !Un) return;
447
+ if (!w || !x.current || B || q || !Gn) return;
442
448
  x.current = !1;
443
- let e = zn(D, "issue");
444
- Hn(Bn(D, e), e);
449
+ let e = Vn(D, "issue");
450
+ Wn(Hn(D, e), e);
445
451
  }, [
446
452
  B,
447
453
  w,
448
- Un,
454
+ Gn,
449
455
  q,
456
+ Wn,
450
457
  Hn,
451
- Bn,
452
458
  D,
453
- zn
459
+ Vn
454
460
  ]);
455
- let Wn = g({ values: D });
461
+ let Kn = g({ values: D });
456
462
  m(() => {
457
- let e = Wn.current;
458
- if (Wn.current = { values: D }, !F) return;
463
+ let e = Kn.current;
464
+ if (Kn.current = { values: D }, !F) return;
459
465
  let t = [
460
466
  "customerId",
461
467
  "customerEmail",
@@ -485,7 +491,7 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
485
491
  F,
486
492
  D
487
493
  ]);
488
- let Gn = p(async (t) => {
494
+ let qn = p(async (t) => {
489
495
  if (y.current = t, q) return;
490
496
  if (Z) {
491
497
  e.error(d.attachmentsUploading);
@@ -500,8 +506,8 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
500
506
  lineItems: r
501
507
  };
502
508
  a !== D && O(a);
503
- let o = a.type === "invoice" && f(a), s = zn(a, t);
504
- if (s && (Xt || W.isLoading)) {
509
+ let o = a.type === "invoice" && f(a), s = Vn(a, t);
510
+ if (s && (Qt || W.isLoading)) {
505
511
  e.error(d.issueChecksLoading);
506
512
  return;
507
513
  }
@@ -509,9 +515,9 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
509
515
  e.error(d.issueBankAccountUnavailable);
510
516
  return;
511
517
  }
512
- let c = Bn(a, s);
518
+ let c = Hn(a, s);
513
519
  if (He(c)) {
514
- Hn(c, s);
520
+ Wn(c, s);
515
521
  return;
516
522
  }
517
523
  if (j({}), s && V.isTaxIdMissing) {
@@ -561,12 +567,12 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
561
567
  path: { receivable_id: l },
562
568
  body: Ge({
563
569
  values: a,
564
- billingAddressId: qt,
565
- shippingAddressId: Yt,
570
+ billingAddressId: Yt,
571
+ shippingAddressId: Zt,
566
572
  lineItemChanges: e
567
573
  })
568
574
  });
569
- $t(), u = l, re = t?.type ?? a.type, o && t && (C.current = t.line_items, Et.current = t.currency, a = {
575
+ tn(), u = l, re = t?.type ?? a.type, o && t && (C.current = t.line_items, Et.current = t.currency, a = {
570
576
  ...a,
571
577
  lineItems: me(a.lineItems, t.line_items)
572
578
  }, O(a));
@@ -574,12 +580,12 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
574
580
  ae = Je({ values: a });
575
581
  let e = await gt.mutateAsync({ body: Ue({
576
582
  values: a,
577
- billingAddressId: qt,
578
- shippingAddressId: Yt,
583
+ billingAddressId: Yt,
584
+ shippingAddressId: Zt,
579
585
  unitNamesById: P
580
586
  }) });
581
587
  if (!e?.id) {
582
- T(!1), Sn();
588
+ T(!1), wn();
583
589
  return;
584
590
  }
585
591
  u = e.id, re = e.type, ie = e.counterpart_name ?? "", o && (S.current = e.id, C.current = e.line_items, Et.current = e.currency, a = {
@@ -594,7 +600,7 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
594
600
  });
595
601
  e.error((l ? d.updateFailed : d.createFailed).replace("{errorMessage}", r));
596
602
  let { errors: i, listError: o } = et(nt(t, n), ae), c = be(i.lineItems, void 0, o);
597
- Hn({
603
+ Wn({
598
604
  ...i,
599
605
  ...c ? { lineItemsSummary: c } : {}
600
606
  }, s);
@@ -604,7 +610,7 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
604
610
  if (o) try {
605
611
  G ? (await yt.mutateAsync({
606
612
  path: { recurrence_id: G.id },
607
- body: Oe(a, { lockSchedule: pn })
613
+ body: Oe(a, { lockSchedule: hn })
608
614
  }), e.success(d.recurrenceUpdated)) : (await vt.mutateAsync({ body: De(a, u) }), e.success(d.recurrenceActivated));
609
615
  } catch (t) {
610
616
  e.error(tt(t, { messages: d }));
@@ -617,7 +623,7 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
617
623
  }
618
624
  else E === "create" ? e.success(d.createSucceeded.replace("{customer}", ie)) : e.success(d.updateSucceeded);
619
625
  let se = E === "create" ? mt : ht;
620
- T(!1), Sn(), se?.(u, re, {
626
+ T(!1), wn(), se?.(u, re, {
621
627
  mode: oe,
622
628
  counterpartId: a.customerId,
623
629
  inlineItems: Ee(a.lineItems, a.currency),
@@ -627,9 +633,9 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
627
633
  W.canAddAccount,
628
634
  W.hasAccounts,
629
635
  W.isLoading,
630
- qt,
636
+ Yt,
631
637
  v,
632
- $t,
638
+ tn,
633
639
  xt,
634
640
  gt,
635
641
  vt,
@@ -637,9 +643,9 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
637
643
  G,
638
644
  B,
639
645
  Z,
640
- Xt,
646
+ Qt,
641
647
  bt,
642
- pn,
648
+ hn,
643
649
  d,
644
650
  E,
645
651
  mt,
@@ -647,58 +653,62 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
647
653
  V.counterpart,
648
654
  V.isTaxIdMissing,
649
655
  q,
650
- Sn,
651
- Yt,
652
- Hn,
656
+ wn,
657
+ Zt,
658
+ Wn,
653
659
  N,
654
660
  P,
655
661
  M.isLoading,
656
662
  _t,
657
663
  yt,
658
- Bn,
664
+ Hn,
659
665
  D,
660
- zn
666
+ Vn
661
667
  ]), $ = p(async (e = y.current) => {
662
668
  if (!St.current) {
663
669
  St.current = !0, wt(e);
664
670
  try {
665
- await Gn(e);
671
+ await qn(e);
666
672
  } finally {
667
673
  St.current = !1, wt(void 0);
668
674
  }
669
675
  }
670
- }, [Gn]), Kn = h(() => ({
676
+ }, [qn]), Jn = h(() => ({
671
677
  ...D,
672
- discount: Vt ? D.discount : Pe(Fe(D.discount, D.discountType, D.currency), D.discountType, D.currency),
678
+ discount: Vt ? Ht ? "" : D.discount : Pe(Fe(D.discount, D.discountType, D.currency), D.discountType, D.currency),
673
679
  lineItems: D.lineItems.map(xe)
674
- }), [Vt, D]), qn = h(() => se(D.lineItems), [D.lineItems]), Jn = h(() => Re(D), [D]), Yn = D.type === "invoice", Xn = Yn && f(D), Zn = X || M.isLoading || W.isLoading, Qn = Zn || B || H.isUploading || q, $n = E === "edit" ? d.updateDraftButton : d.saveDraftButton, er = Xn ? G ? d.recurrenceUpdateButton : d.recurrenceActivateButton : Yn ? d.issueButton : $n, tr = Yn && !Xn ? "issue" : "draft", nr = p(() => $("draft"), [$]), rr = p(() => $(tr), [tr, $]), ir = p(() => $(), [$]), ar = p(() => {
680
+ }), [
681
+ Ht,
682
+ Vt,
683
+ D
684
+ ]), Yn = h(() => se(D.lineItems), [D.lineItems]), Xn = h(() => Re(D), [D]), Zn = D.type === "invoice", Qn = Zn && f(D), $n = X || M.isLoading || W.isLoading, er = $n || B || H.isUploading || q, tr = E === "edit" ? d.updateDraftButton : d.saveDraftButton, nr = Qn ? G ? d.recurrenceUpdateButton : d.recurrenceActivateButton : Zn ? d.issueButton : tr, rr = Zn && !Qn ? "issue" : "draft", ir = p(() => $("draft"), [$]), ar = p(() => $(rr), [rr, $]), or = p(() => $(), [$]), sr = p(() => {
675
685
  y.current = "draft";
676
- }, []), or = p(() => {
677
- y.current = tr;
678
- }, [tr]), sr = Qn || Xn, cr = p(async () => {
679
- if (!sr) try {
686
+ }, []), cr = p(() => {
687
+ y.current = rr;
688
+ }, [rr]), lr = er || Qn, ur = p(async () => {
689
+ if (!lr) try {
680
690
  await $("draft");
681
691
  } finally {
682
692
  A(!1);
683
693
  }
684
- }, [sr, $]), lr = p(() => A(!1), []), ur = h(() => ({
694
+ }, [lr, $]), dr = p(() => A(!1), []), fr = h(() => ({
685
695
  open: Mt,
686
- onSaveDraft: () => void cr(),
687
- onDiscard: Tn,
688
- onCancel: lr,
696
+ onSaveDraft: () => void ur(),
697
+ onDiscard: Dn,
698
+ onCancel: dr,
689
699
  isSaving: X,
690
- isSaveDraftDisabled: sr
700
+ isSaveDraftDisabled: lr
691
701
  }), [
692
- lr,
693
- Tn,
702
+ dr,
703
+ Dn,
694
704
  X,
695
- sr,
696
- cr,
705
+ lr,
706
+ ur,
697
707
  Mt
698
- ]), dr = h(() => Le(Jn, D.currency), [Jn, D.currency]), fr = ct({
708
+ ]), pr = h(() => Le(Xn, D.currency), [Xn, D.currency]), mr = ct({
699
709
  values: D,
700
- totals: Jn,
701
- billingAddress: Jt,
710
+ totals: Xn,
711
+ billingAddress: Xt,
702
712
  bankAccount: W.selectedAccount,
703
713
  unitNamesById: P,
704
714
  messages: d,
@@ -709,28 +719,28 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
709
719
  setOpen: T,
710
720
  mode: E,
711
721
  values: D,
712
- sheetValues: Kn,
722
+ sheetValues: Jn,
713
723
  errors: Nt,
714
724
  setValues: O,
715
- updateValues: Dn,
716
- commitTaxRate: jn,
717
- commitCustomerEmail: An,
718
- focusDiscount: On,
719
- commitDiscount: kn,
720
- updateLineItem: Mn,
721
- selectProduct: Nn,
722
- commitLineItem: Fn,
723
- stepLineItem: In,
724
- addLineItem: Ln,
725
- removeLineItem: Rn,
726
- attachmentsView: en,
725
+ updateValues: kn,
726
+ commitTaxRate: Nn,
727
+ commitCustomerEmail: Mn,
728
+ focusDiscount: An,
729
+ commitDiscount: jn,
730
+ updateLineItem: Pn,
731
+ selectProduct: Fn,
732
+ commitLineItem: Ln,
733
+ stepLineItem: Rn,
734
+ addLineItem: zn,
735
+ removeLineItem: Bn,
736
+ attachmentsView: nn,
727
737
  attachmentsUploading: H.isUploading,
728
- draftButtonLabel: Yn && !Xn ? $n : void 0,
729
- draftDisabled: Qn,
738
+ draftButtonLabel: Zn && !Qn ? tr : void 0,
739
+ draftDisabled: er,
730
740
  draftLoading: X && Ct === "draft",
731
- primaryButtonLabel: er,
732
- primaryLoading: X && Ct === tr,
733
- primaryDisabled: Qn || Yn && (Xt || !Xn && V.isCounterpartLoading),
741
+ primaryButtonLabel: nr,
742
+ primaryLoading: X && Ct === rr,
743
+ primaryDisabled: er || Zn && (Qt || !Qn && V.isCounterpartLoading),
734
744
  scrollContainerRef: Tt,
735
745
  selectAttachmentFiles: H.selectFiles,
736
746
  setAttachmentIncludeInEmail: H.setIncludeInEmail,
@@ -738,41 +748,41 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
738
748
  autoFocusLineItemId: Lt,
739
749
  lineItemUnitOptions: It.unitOptions,
740
750
  lineItemsLoading: M.isLoading,
741
- lineItemControls: qn,
742
- totals: Jn,
743
- preview: fr,
744
- totalsView: dr,
751
+ lineItemControls: Yn,
752
+ totals: Xn,
753
+ preview: mr,
754
+ totalsView: pr,
745
755
  currencySymbol: fe(D.currency),
746
756
  isSubmitting: X,
747
- fieldsDisabled: Zn,
748
- paymentTerms: cn,
757
+ fieldsDisabled: $n,
758
+ paymentTerms: un,
749
759
  showBillingSection: D.type === "invoice" || E === "edit",
750
760
  purchaseOrder: E === "create" ? {
751
761
  value: D.purchaseOrder,
752
762
  error: Nt.purchaseOrder
753
763
  } : void 0,
754
- recurrence: vn,
764
+ recurrence: bn,
755
765
  showRecurrenceSection: D.type === "invoice",
756
766
  recurrenceLoading: q,
757
767
  showDueDateField: D.type === "quote",
758
- openCreate: Cn,
759
- openEdit: wn,
760
- close: Tn,
761
- requestClose: En,
762
- unsavedPrompt: ur,
763
- submit: ir,
764
- submitDraft: nr,
765
- submitPrimary: rr,
766
- selectDraftMode: ar,
767
- selectPrimaryMode: or,
768
+ openCreate: Tn,
769
+ openEdit: En,
770
+ close: Dn,
771
+ requestClose: On,
772
+ unsavedPrompt: fr,
773
+ submit: or,
774
+ submitDraft: ir,
775
+ submitPrimary: ar,
776
+ selectDraftMode: sr,
777
+ selectPrimaryMode: cr,
768
778
  units: It,
769
779
  counterpartView: Pt,
770
- counterpartForm: nn,
771
- stateOptions: Ht,
772
- openCounterpartCreate: on,
773
- customer: Gt.data?.id === D.customerId ? Gt.data : void 0,
780
+ counterpartForm: an,
781
+ stateOptions: Wt,
782
+ openCounterpartCreate: cn,
783
+ customer: qt.data?.id === D.customerId ? qt.data : void 0,
774
784
  bankAccount: W,
775
- reminders: bn
785
+ reminders: Sn
776
786
  };
777
787
  }
778
788
  //#endregion
@@ -245,14 +245,17 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
245
245
  ...e,
246
246
  amount_paid: r
247
247
  });
248
- return R(e, "payment_received", {
248
+ R(e, "payment_received", {
249
249
  amount_paid: t,
250
250
  amount_due: i.amount_due,
251
251
  ...n
252
- }), F({
253
- ...z(e, i.amount_due === 0 ? "paid" : "partially_paid"),
252
+ });
253
+ let a = i.amount_due === 0;
254
+ return F({
255
+ ...z(e, a ? "paid" : "partially_paid"),
254
256
  amount_paid: i.amount_paid,
255
- amount_due: i.amount_due
257
+ amount_due: i.amount_due,
258
+ ...a ? { paid_at: n.paid_at } : {}
256
259
  });
257
260
  }, V = (e) => (k.recurrences = k.recurrences.map((t) => t.id === e.id ? e : t), b(e)), Y = (e, t, n) => v(e, `${h}/recurrences/:id${t}`, (e, { id: t }) => {
258
261
  let r = k.recurrences.find((e) => e.id === t);
@@ -504,7 +507,7 @@ function Z({ invoices: e = O, customers: l = D, list: f, writes: p }) {
504
507
  return k.recurrences.push(a), F({
505
508
  ...z(n, "recurring"),
506
509
  recurrence_id: a.id
507
- }), b(a, 201);
510
+ }), b(a);
508
511
  }),
509
512
  Y("GET", "", (e) => b(e)),
510
513
  Y("PATCH", "", (e, t) => {
@@ -22,7 +22,7 @@ function c({ view: t, onSelect: c, labels: l }) {
22
22
  className: "ttw:flex ttw:gap-2",
23
23
  children: Array.from({ length: o }).map((t, n) => /* @__PURE__ */ i(e, { className: "ttw:h-16.5 ttw:w-42 ttw:rounded-xl" }, n))
24
24
  }) : /* @__PURE__ */ a("div", {
25
- className: "ttw:mb-6 ttw:flex ttw:gap-2 ttw:overflow-x-auto ttw:[scrollbar-width:none] ttw:[&::-webkit-scrollbar]:hidden",
25
+ className: "ttw:mb-2 ttw:flex ttw:gap-2 ttw:overflow-x-auto ttw:[scrollbar-width:none] ttw:[&::-webkit-scrollbar]:hidden",
26
26
  children: [/* @__PURE__ */ a(s, {
27
27
  selected: t.all.selected,
28
28
  onClick: () => c(t.all.value),
@@ -166,6 +166,7 @@ function D({ rows: n, isLoading: u, isError: d, isAccessRestricted: h, sorting:
166
166
  type: "button",
167
167
  variant: "outline",
168
168
  size: "lg",
169
+ className: "ttw:w-11 ttw:rounded-xl",
169
170
  "aria-label": G.settingsButton,
170
171
  onClick: V,
171
172
  children: /* @__PURE__ */ p(v, {
@@ -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.6.3", n = "847f3668071b4265ee6380ef00faab07e7925610", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.6.5", n = "2ef1662a3c14da0417ca4bd4b704b17b9beeea33", 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.6.3",
3
+ "version": "0.6.5",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [