@tesouro/embedded-components-react 0.5.224 → 0.5.226

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 (41) hide show
  1. package/README.md +335 -413
  2. package/dist/index.d.ts +23 -2
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +23 -2
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +4 -4
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +45 -31
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +51 -32
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +20 -1
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +17 -202
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +220 -31
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +32 -145
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +126 -44
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +145 -117
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +46 -58
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +113 -87
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +58 -116
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +98 -225
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +111 -27
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +225 -462
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +34 -41
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +627 -34
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +39 -77
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +34 -112
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +75 -310
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +124 -0
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +324 -0
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +20 -15
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +56 -53
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +33 -29
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +184 -162
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +1 -3
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +78 -69
  35. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/CounterpartSelector.js +7 -6
  36. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +20 -19
  37. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +39 -39
  38. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +210 -199
  39. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +60 -52
  40. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  41. package/package.json +1 -1
@@ -1,49 +1,131 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { usePaymentTermsQuery as e } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
6
- import { buildCustomDateCalendar as t, buildPaymentTermsView as n, closeCustomDatePickerFields as r, selectPaymentTermsFields as i, toCustomDateValue as a } from "./index9.js";
7
- import "../../data-access/dist/index.js";
8
- import { useCallback as o, useMemo as s, useState as c } from "react";
9
1
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js
10
- function l({ paymentTermsId: l, paymentTermsCustomDate: u, isRecurring: d, messages: f, onChange: p }) {
11
- let m = e(), [h, g] = c(!1);
2
+ var e = {
3
+ invoice: [
4
+ "ReceivableFacadeCreateQuotePayload",
5
+ "ReceivableCreateBasedOnPayload",
6
+ "UpdateQuotePayload",
7
+ "UpdateCreditNotePayload",
8
+ "UpdateIssuedInvoicePayload"
9
+ ],
10
+ quote: [
11
+ "ReceivableFacadeCreateInvoicePayload",
12
+ "ReceivableCreateBasedOnPayload",
13
+ "UpdateInvoicePayload",
14
+ "UpdateCreditNotePayload",
15
+ "UpdateIssuedInvoicePayload"
16
+ ]
17
+ }, t = {
18
+ counterpart_id: "customerId",
19
+ counterpart_billing_address_id: "customerId",
20
+ counterpart_shipping_address_id: "customerId",
21
+ bank_account_id: "bankAccountId",
22
+ bank_account_type: "bankAccountId",
23
+ payment_terms_id: "paymentTermsId",
24
+ "payment_terms.term_final.end_date": "paymentTermsId",
25
+ "payment_terms.term_final.number_of_days": "paymentTermsId",
26
+ memo: "openingNote",
27
+ footer: "closingNote",
28
+ "discount.amount": "discount"
29
+ }, n = {
30
+ quantity: "quantity",
31
+ "product.name": "name",
32
+ "product.price.value": "price",
33
+ "product.price.currency": "price",
34
+ "product.measure_unit.name": "measureUnit"
35
+ }, r = (e) => typeof e == "number" || /^\d+$/.test(e), i = (e) => /^[A-Z]/.test(e) || e.includes("[") || e.includes("-"), a = (e) => e.filter((e, t) => t !== 0 || e !== "body").filter((e) => r(e) || !i(String(e))).join("."), o = (e) => typeof e == "string" || typeof e == "number", s = (e, t) => e === t || RegExp(`(^|[^A-Za-z0-9_])${t}([^A-Za-z0-9_]|$)`).test(e), c = (e) => typeof e == "object" && !!e;
36
+ function l(e) {
37
+ if (typeof e == "string") return e.trim() ? {
38
+ path: "",
39
+ loc: [],
40
+ msg: e,
41
+ type: ""
42
+ } : null;
43
+ if (!c(e)) return null;
44
+ let { loc: t, msg: n, type: r } = e;
45
+ if (typeof n != "string" || !n.trim()) return null;
46
+ let i = Array.isArray(t) ? t.filter(o) : [];
12
47
  return {
13
- view: s(() => n({
14
- terms: m.data?.data,
15
- isLoading: m.isLoading,
16
- fields: {
17
- paymentTermsId: l,
18
- paymentTermsCustomDate: u
19
- },
20
- customDatePickerOpen: h,
21
- isRecurring: d,
22
- messages: f
23
- }), [
24
- h,
25
- d,
26
- f,
27
- u,
28
- l,
29
- m.data?.data,
30
- m.isLoading
31
- ]),
32
- calendar: s(() => t(u), [u]),
33
- select: o((e) => {
34
- p((t) => i(t, e)), g(!1);
35
- }, [p]),
36
- changeCustomDatePickerOpen: o((e) => {
37
- g(e), e || p(r);
38
- }, [p]),
39
- selectCustomDate: o((e) => {
40
- p((t) => r({
41
- ...t,
42
- paymentTermsCustomDate: a(e)
43
- })), g(!1);
44
- }, [p]),
45
- reset: o(() => g(!1), [])
48
+ path: a(i),
49
+ loc: i,
50
+ msg: n,
51
+ type: typeof r == "string" ? r : ""
52
+ };
53
+ }
54
+ function u(e, t = []) {
55
+ if (!c(e) || !Array.isArray(e.detail)) return [];
56
+ let n = [], r = /* @__PURE__ */ new Set();
57
+ for (let i of e.detail) {
58
+ let e = l(i);
59
+ if (!e || e.loc.some((e) => typeof e == "string" && t.some((t) => s(e, t)))) continue;
60
+ let a = `${e.path}:${e.msg}`;
61
+ r.has(a) || (r.add(a), n.push(e));
62
+ }
63
+ return n;
64
+ }
65
+ var d = 3;
66
+ function f(e, t) {
67
+ let n = [...new Set(e.map(({ msg: e }) => e))];
68
+ if (!n.length) return "";
69
+ let r = n.slice(0, d).join("; "), i = n.length - d;
70
+ return i > 0 ? t.apiErrorsSummary.replace("{message}", r).replace("{count}", String(i)) : r;
71
+ }
72
+ var p = 200;
73
+ function m(e) {
74
+ let t = e.trim();
75
+ if (!(!t || t.length > p) && !t.includes("<")) return t;
76
+ }
77
+ function h(e, { irrelevantVariants: t, messages: n }) {
78
+ if (e instanceof Error) return e.message;
79
+ if (typeof e == "string") return m(e) ?? n.unknownError;
80
+ if (!c(e)) return n.unknownError;
81
+ if (c(e.error) && typeof e.error.message == "string") return e.error.message;
82
+ if (Array.isArray(e.detail)) {
83
+ let r = f(u(e, t), n);
84
+ if (r) return r;
85
+ }
86
+ return n.unknownError;
87
+ }
88
+ function g(e) {
89
+ return e.replace(/^(invoice|quote)\./, "");
90
+ }
91
+ var _ = /^line_items\.(?:(add|replace)\.)?(\d+)\.(?:data\.)?(.+)$/;
92
+ function v(e, t, n) {
93
+ return e === "add" ? n.added?.[t] : e === "replace" ? n.replaced?.[t] : n.created?.[t];
94
+ }
95
+ function y(e, r) {
96
+ let i = {}, a;
97
+ for (let { path: o, msg: s } of e) {
98
+ if (!o) continue;
99
+ let e = g(o);
100
+ if (e === "line_items") {
101
+ a = s;
102
+ continue;
103
+ }
104
+ let c = t[e];
105
+ if (c) {
106
+ i[c] = s;
107
+ continue;
108
+ }
109
+ let l = e.match(_);
110
+ if (!l) continue;
111
+ let [, u, d, f] = l;
112
+ if (f === "tax_rate_value") {
113
+ i.taxRate = s;
114
+ continue;
115
+ }
116
+ let p = n[f], m = v(u, Number(d), r);
117
+ p && m && (i.lineItems = {
118
+ ...i.lineItems,
119
+ [m]: {
120
+ ...i.lineItems?.[m],
121
+ [p]: s
122
+ }
123
+ });
124
+ }
125
+ return {
126
+ errors: i,
127
+ listError: a
46
128
  };
47
129
  }
48
130
  //#endregion
49
- export { l as useReceivablePaymentTerms };
131
+ export { e as UNSUBMITTED_PAYLOAD_VARIANTS, y as apiValidationErrorsToFormErrors, h as getApiErrorMessage, u as parseApiValidationErrors, f as summarizeApiValidationErrors, g as toCreatePayloadPath };
@@ -2,126 +2,154 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { getCounterpartEmail as e } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
6
- import { useCounterpartQuery as t } from "../../../shared/counterpart-management/data-access/dist/index3.js";
7
- import "../../../shared/counterpart-management/feature/dist/index.js";
8
- import { applyRecurrenceEmailDraft as n, buildRecurrenceEmailView as r, buildRecurrenceView as i, clearRecurrenceRecipients as a, createRecurrenceEmailDraft as o, selectRecurrenceDate as s, selectRecurrenceDayOfWeek as c, selectRecurrenceEndMode as l, selectRecurrenceFrequency as u, selectRecurrenceIssueMode as d, shouldOpenRecurrenceEmail as f } from "./index8.js";
9
- import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
5
+ import { toFileArray as e, validateAttachmentFile as t } from "./index7.js";
6
+ import { useDeleteReceivableAttachmentMutation as n, useUploadReceivableAttachmentMutation as r } from "../../data-access/dist/index4.js";
7
+ import "../../data-access/dist/index.js";
8
+ import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
10
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js
11
- var v = [
12
- "recurrenceStartDate",
13
- "recurrenceEndDate",
14
- "recurrenceIssueMode",
15
- "recurrenceDayOfWeek",
16
- "recurrenceEndMode",
17
- "recurrenceMaxOccurrences"
18
- ], y = [
19
- "recurrenceSubject",
20
- "recurrenceBody",
21
- "recurrenceRecipientsTo",
22
- "recurrenceRecipientsCc",
23
- "recurrenceRecipientsBcc"
24
- ];
25
- function b({ values: b, errors: x, lockSchedule: S, messages: C, onChange: w, onClearErrors: T, onRevalidateErrors: E }) {
26
- let D = t(b.customerId || void 0), O = D.data ? e(D.data).trim() : "", [k, A] = _(!1), [j, M] = _(b), [N, P] = _(null), F = h(() => N ?? o(j, O), [
27
- O,
28
- N,
29
- j
30
- ]), I = g(O);
31
- m(() => {
32
- let e = I.current;
33
- I.current = O, e && e !== O && w(a);
34
- }, [O, w]);
35
- let L = p((e) => {
36
- M(e), P(null), A(!0);
10
+ function c({ attachments: c, setAttachments: l, receivableId: u }) {
11
+ let { mutateAsync: d } = r(), { mutate: f } = n(), [p, m] = s([]), [h, g] = s(!1), _ = o(0), v = o(/* @__PURE__ */ new Set()), y = o(/* @__PURE__ */ new Set()), b = o(/* @__PURE__ */ new Set()), x = o(0), S = o(!1), C = o({
12
+ deleteFile: f,
13
+ receivableId: u
14
+ });
15
+ a(() => {
16
+ C.current = {
17
+ deleteFile: f,
18
+ receivableId: u
19
+ };
20
+ }, [f, u]), a(() => {
21
+ S.current = !1;
22
+ let e = y.current;
23
+ return () => {
24
+ S.current = !0;
25
+ let { deleteFile: t, receivableId: n } = C.current;
26
+ for (let r of e) t({
27
+ path: { file_id: r },
28
+ receivableId: n
29
+ });
30
+ e.clear();
31
+ };
37
32
  }, []);
38
- return {
39
- view: h(() => i({
40
- fields: b,
41
- errors: x,
42
- lockSchedule: S,
43
- messages: C
44
- }), [
45
- x,
46
- S,
47
- C,
48
- b
49
- ]),
50
- emailView: h(() => r({
51
- open: k,
52
- ready: !D.isLoading,
53
- draft: F,
54
- messages: C
55
- }), [
56
- D.isLoading,
57
- F,
58
- k,
59
- C
60
- ]),
61
- changeFrequency: p((e) => {
62
- T(v), w((t) => u(t, e));
63
- }, [w, T]),
64
- changeMonthDay: p((e) => {
65
- E(["recurrenceIssueMode"]), w((t) => d(t, e, { lockSchedule: S }));
66
- }, [
67
- S,
68
- w,
69
- E
70
- ]),
71
- changeWeekday: p((e) => {
72
- S || (T(["recurrenceStartDate"]), E(["recurrenceDayOfWeek"]), w((t) => c(t, e, { lockSchedule: S })));
73
- }, [
74
- S,
75
- w,
76
- T,
77
- E
78
- ]),
79
- changeStartDate: p((e) => {
80
- E(["recurrenceStartDate"]), w((t) => s(t, "recurrenceStartDate", e));
81
- }, [w, E]),
82
- changeEndDate: p((e) => {
83
- E(["recurrenceEndDate"]), w((t) => s(t, "recurrenceEndDate", e));
84
- }, [w, E]),
85
- changeEndMode: p((e) => {
86
- E(["recurrenceEndMode"]), w((t) => l(t, e));
87
- }, [w, E]),
88
- changeMaxOccurrences: p((e) => {
89
- E(["recurrenceMaxOccurrences"]), w((t) => ({
90
- ...t,
91
- recurrenceMaxOccurrences: e
92
- }));
93
- }, [w, E]),
94
- changeCreationMode: p((e) => {
95
- let t = {
96
- ...b,
97
- recurrenceAutomationLevel: e
98
- };
99
- w((t) => ({
33
+ let w = i(async (e, t) => {
34
+ let n = x.current, r = () => S.current || x.current !== n;
35
+ try {
36
+ let n = await d({
37
+ file: t,
38
+ receivableId: u
39
+ });
40
+ if (r() || v.current.delete(e)) {
41
+ f({
42
+ path: { file_id: n.id },
43
+ receivableId: u
44
+ });
45
+ return;
46
+ }
47
+ y.current.add(n.id), m((t) => t.filter((t) => t.id !== e)), l((e) => [...e, {
48
+ id: n.id,
49
+ includeInEmail: !0,
50
+ name: n.name,
51
+ size: n.size
52
+ }]);
53
+ } catch {
54
+ let t = v.current.delete(e);
55
+ if (r() || t) return;
56
+ m((t) => t.map((t) => t.id === e ? {
100
57
  ...t,
101
- recurrenceAutomationLevel: e
102
- })), f(t, e) && L(t);
103
- }, [
104
- w,
105
- L,
106
- b
107
- ]),
108
- setUpEmail: p(() => L(b), [L, b]),
109
- changeEmailOpen: A,
110
- changeEmail: p((e, t) => P((n) => ({
111
- ...n ?? F,
112
- [e]: t
113
- })), [F]),
114
- saveEmail: p(() => {
115
- w((e) => n(e, F)), T(y), A(!1);
116
- }, [
117
- F,
118
- w,
119
- T
120
- ]),
121
- reset: p(() => {
122
- A(!1), I.current = "";
123
- }, [])
58
+ status: "upload_failed"
59
+ } : t));
60
+ }
61
+ }, [
62
+ f,
63
+ u,
64
+ l,
65
+ d
66
+ ]), T = i((n) => {
67
+ let r = e(n);
68
+ if (r.length === 0) return;
69
+ let i = p.filter((e) => e.status === "uploading").length, a = 10 - c.length - i, o = [], s = !1;
70
+ for (let e of r) {
71
+ _.current += 1;
72
+ let n = `pending-attachment-${_.current}`, r = t(e);
73
+ if (r) {
74
+ o.push({
75
+ id: n,
76
+ name: e.name,
77
+ status: r
78
+ });
79
+ continue;
80
+ }
81
+ if (a <= 0) {
82
+ s = !0;
83
+ continue;
84
+ }
85
+ --a, o.push({
86
+ id: n,
87
+ name: e.name,
88
+ status: "uploading"
89
+ }), w(n, e);
90
+ }
91
+ o.length > 0 && m((e) => [...e, ...o]), g(s);
92
+ }, [
93
+ c.length,
94
+ p,
95
+ w
96
+ ]), E = i((e, t) => {
97
+ l((n) => n.map((n) => n.id === e ? {
98
+ ...n,
99
+ includeInEmail: t
100
+ } : n));
101
+ }, [l]), D = i((e) => {
102
+ g(!1);
103
+ let t = p.find((t) => t.id === e);
104
+ if (t) {
105
+ t.status === "uploading" && v.current.add(e), m((t) => t.filter((t) => t.id !== e));
106
+ return;
107
+ }
108
+ if (l((t) => t.filter((t) => t.id !== e)), !y.current.delete(e)) {
109
+ b.current.add(e);
110
+ return;
111
+ }
112
+ f({
113
+ path: { file_id: e },
114
+ receivableId: u
115
+ });
116
+ }, [
117
+ f,
118
+ p,
119
+ u,
120
+ l
121
+ ]), O = i(() => {
122
+ x.current += 1, v.current.clear(), y.current.clear(), b.current.clear(), m([]), g(!1);
123
+ }, []), k = i(() => {
124
+ let e = new Set(y.current);
125
+ for (let t of e) f({
126
+ path: { file_id: t },
127
+ receivableId: u
128
+ });
129
+ l((t) => t.filter(({ id: t }) => !e.has(t))), O();
130
+ }, [
131
+ f,
132
+ u,
133
+ O,
134
+ l
135
+ ]), A = i(() => {
136
+ for (let e of b.current) f({
137
+ path: { file_id: e },
138
+ receivableId: u
139
+ });
140
+ b.current.clear();
141
+ }, [f, u]);
142
+ return {
143
+ pendingUploads: p,
144
+ isUploading: p.some((e) => e.status === "uploading"),
145
+ isCountLimitReached: h,
146
+ selectFiles: T,
147
+ setIncludeInEmail: E,
148
+ remove: D,
149
+ reset: O,
150
+ discardUploads: k,
151
+ commitRemovals: A
124
152
  };
125
153
  }
126
154
  //#endregion
127
- export { b as useReceivableRecurrence };
155
+ export { c as useReceivableAttachmentUploads };
@@ -1,63 +1,51 @@
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";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { usePaymentTermsQuery as e } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
6
+ import { buildCustomDateCalendar as t, buildPaymentTermsView as n, closeCustomDatePickerFields as r, resolveIssueDate as i, selectPaymentTermsFields as a, toCustomDateValue as o } from "./index9.js";
7
+ import "../../data-access/dist/index.js";
8
+ import { useCallback as s, useMemo as c, useState as l } from "react";
4
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js
5
- var n = {
6
- routingNumber: "",
7
- accountNumber: "",
8
- accountHolderName: "",
9
- displayName: ""
10
- };
11
- function r(n) {
12
- let r = new Set(n ?? []);
10
+ function u({ paymentTermsId: u, paymentTermsCustomDate: d, issueDate: f, isRecurring: p, messages: m, onChange: h }) {
11
+ let g = e(), [_, v] = l(!1);
13
12
  return {
14
- canReadEmbedded: e(r, [t.BankAccountReadOrg]),
15
- canReadExternal: e(r, [t.ExternalBankAccountReadOrg]),
16
- canAddAccount: e(r, [t.BankAccountWriteOrg])
17
- };
18
- }
19
- function i(e, t) {
20
- return [e.displayName || t.bankAccountFallbackName, e.accountNumberLast4].filter(Boolean).join(" - ");
21
- }
22
- function a(e, t, n) {
23
- switch (e) {
24
- case "INTERNAL": return t ? n.bankAccountPoweredBy.replace("{embeddedBankName}", t) : void 0;
25
- case "EXTERNAL": return n.bankAccountLinked;
26
- default: return;
27
- }
28
- }
29
- function o({ accounts: e, embeddedBankName: t, messages: n }) {
30
- return e.map((e) => ({
31
- value: e.id,
32
- label: i(e, n),
33
- sourceLabel: a(e.type, t, n)
34
- })).sort((e, t) => e.label.localeCompare(t.label));
35
- }
36
- function s({ options: e, isLoading: t, selectedId: n, isAddingAccount: r, canAddAccount: i, formValues: a, formErrors: o, isSaving: s }) {
37
- return t ? { kind: "loading" } : e.length > 0 && !r ? {
38
- kind: "picker",
39
- options: e,
40
- selected: e.find((e) => e.value === n),
41
- canAddAccount: i
42
- } : i ? {
43
- kind: "form",
44
- values: a,
45
- errors: o,
46
- canCancel: e.length > 0,
47
- isSaving: s
48
- } : { kind: "restricted" };
49
- }
50
- function c(e, t) {
51
- let n = {}, r = e.accountHolderName.trim(), i = e.accountNumber.trim(), a = e.routingNumber.trim();
52
- return r ? r.length > 255 && (n.accountHolderName = t.bankAccountHolderNameTooLong) : n.accountHolderName = t.bankAccountHolderNameRequired, i ? /^\d+$/.test(i) ? i.length < 4 ? n.accountNumber = t.bankAccountNumberTooShort : i.length > 17 && (n.accountNumber = t.bankAccountNumberTooLong) : n.accountNumber = t.bankAccountNumberDigitsOnly : n.accountNumber = t.bankAccountNumberRequired, a ? /^\d{9}$/.test(a) || (n.routingNumber = t.bankAccountRoutingNumberInvalid) : n.routingNumber = t.bankAccountRoutingNumberRequired, e.displayName.length > 200 && (n.displayName = t.bankAccountNicknameTooLong), n;
53
- }
54
- function l(e) {
55
- return {
56
- display_name: e.displayName || void 0,
57
- account_holder_name: e.accountHolderName.trim() || void 0,
58
- account_number: e.accountNumber.trim() || void 0,
59
- routing_number: e.routingNumber.trim() || void 0
13
+ view: c(() => n({
14
+ terms: g.data?.data,
15
+ isLoading: g.isLoading,
16
+ fields: {
17
+ paymentTermsId: u,
18
+ paymentTermsCustomDate: d
19
+ },
20
+ customDatePickerOpen: _,
21
+ isRecurring: p,
22
+ messages: m,
23
+ issueDate: i(f)
24
+ }), [
25
+ _,
26
+ p,
27
+ f,
28
+ m,
29
+ d,
30
+ u,
31
+ g.data?.data,
32
+ g.isLoading
33
+ ]),
34
+ calendar: c(() => t(d), [d]),
35
+ select: s((e) => {
36
+ h((t) => a(t, e)), v(!1);
37
+ }, [h]),
38
+ changeCustomDatePickerOpen: s((e) => {
39
+ v(e), e || h(r);
40
+ }, [h]),
41
+ selectCustomDate: s((e) => {
42
+ h((t) => r({
43
+ ...t,
44
+ paymentTermsCustomDate: o(e)
45
+ })), v(!1);
46
+ }, [h]),
47
+ reset: s(() => v(!1), [])
60
48
  };
61
49
  }
62
50
  //#endregion
63
- export { n as EMPTY_BANK_ACCOUNT_FORM_VALUES, l as bankAccountFormToPayload, s as buildBankAccountSectionView, o as buildPaymentAccountOptions, r as getBankAccountPermissions, i as getPaymentAccountLineLabel, a as getPaymentAccountSourceLabel, c as validateBankAccountForm };
51
+ export { u as useReceivablePaymentTerms };