@tesouro/embedded-components-react 0.5.227 → 0.5.230
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -21
- package/dist/index.d.ts +87 -34
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +87 -34
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +29 -59
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +32 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +34 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +120 -52
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +44 -100
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +93 -442
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +356 -201
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +225 -157
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +152 -21
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +18 -221
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +220 -31
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +125 -124
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +58 -150
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +232 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +303 -122
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +43 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +125 -98
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +140 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +46 -232
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +119 -29
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +81 -613
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +116 -39
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +27 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +634 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +39 -119
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +36 -317
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +82 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +139 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +340 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +15 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +55 -468
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +443 -97
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +24 -22
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +32 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +205 -84
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +161 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +12 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +25 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +95 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +3 -18
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +24 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +42 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +14 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +19 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +73 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +17 -261
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +12 -44
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +28 -68
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +288 -479
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +1 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +48 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +72 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +496 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +121 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +106 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +2 -28
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +4 -236
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +0 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +90 -239
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +24 -89
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +231 -54
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -353
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +249 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +100 -207
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +59 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +353 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +35 -29
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +2 -216
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +9 -159
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +27 -14
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +216 -23
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +189 -211
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +43 -59
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +0 -100
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js
CHANGED
|
@@ -1,104 +1,131 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
-
import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
-
import "../../../shared/ui/dist/index.js";
|
|
8
|
-
import { useWidgetConfig as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
|
-
import "../../../shared/feature/dist/index.js";
|
|
10
|
-
import { useCreateEntityBankAccountMutation as r, usePaymentAccountsQuery as i } from "../../data-access/dist/index3.js";
|
|
11
|
-
import "../../data-access/dist/index.js";
|
|
12
|
-
import { EMPTY_BANK_ACCOUNT_FORM_VALUES as a, bankAccountFormToPayload as o, buildBankAccountSectionView as s, buildPaymentAccountOptions as c, getBankAccountPermissions as l, validateBankAccountForm as u } from "./index22.js";
|
|
13
|
-
import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
14
1
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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) : [];
|
|
47
|
+
return {
|
|
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;
|
|
57
103
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
+
}
|
|
72
125
|
return {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
isLoading: w,
|
|
76
|
-
selectedId: _,
|
|
77
|
-
isAddingAccount: D,
|
|
78
|
-
canAddAccount: S.canAddAccount,
|
|
79
|
-
formValues: k,
|
|
80
|
-
formErrors: j,
|
|
81
|
-
isSaving: E.isPending
|
|
82
|
-
}), [
|
|
83
|
-
_,
|
|
84
|
-
E.isPending,
|
|
85
|
-
j,
|
|
86
|
-
k,
|
|
87
|
-
D,
|
|
88
|
-
w,
|
|
89
|
-
B,
|
|
90
|
-
S.canAddAccount
|
|
91
|
-
]),
|
|
92
|
-
isLoading: w,
|
|
93
|
-
hasAccounts: C.length > 0,
|
|
94
|
-
canAddAccount: S.canAddAccount,
|
|
95
|
-
reset: P,
|
|
96
|
-
selectAccount: F,
|
|
97
|
-
openAddAccount: I,
|
|
98
|
-
cancelAddAccount: L,
|
|
99
|
-
updateAccountForm: R,
|
|
100
|
-
saveAccount: z
|
|
126
|
+
errors: i,
|
|
127
|
+
listError: a
|
|
101
128
|
};
|
|
102
129
|
}
|
|
103
130
|
//#endregion
|
|
104
|
-
export { g as
|
|
131
|
+
export { e as UNSUBMITTED_PAYLOAD_VARIANTS, y as apiValidationErrorsToFormErrors, h as getApiErrorMessage, u as parseApiValidationErrors, f as summarizeApiValidationErrors, g as toCreatePayloadPath };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js
CHANGED
|
@@ -2,120 +2,154 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { usePaymentTermsQuery as n } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
|
|
8
|
-
import "../../../shared/ui/dist/index.js";
|
|
9
|
-
import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
10
|
-
import "../../../shared/feature/dist/index.js";
|
|
11
|
-
import { areOverdueTermsValid as i, buildOverdueReminderPayload as a, buildPaymentReminderPayload as o, buildRemindersView as s, canCreateReminders as c, getImpliedDueDate as l, isBeforeDueDaysValid as u, sanitizeReminderDays as d } from "./index14.js";
|
|
12
|
-
import { useCreateOverdueReminderMutation as f, useCreatePaymentReminderMutation as p, useOverdueRemindersQuery as m, usePaymentRemindersQuery as h } from "../../data-access/dist/index11.js";
|
|
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";
|
|
13
7
|
import "../../data-access/dist/index.js";
|
|
14
|
-
import { useCallback as
|
|
8
|
+
import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
|
|
15
9
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
};
|
|
32
|
+
}, []);
|
|
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 ? {
|
|
57
|
+
...t,
|
|
58
|
+
status: "upload_failed"
|
|
59
|
+
} : t));
|
|
49
60
|
}
|
|
50
61
|
}, [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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);
|
|
66
90
|
}
|
|
91
|
+
o.length > 0 && m((e) => [...e, ...o]), g(s);
|
|
67
92
|
}, [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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,
|
|
71
133
|
O,
|
|
72
|
-
|
|
73
|
-
])
|
|
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]);
|
|
74
142
|
return {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
disabled: S,
|
|
85
|
-
beforeDueInput: P,
|
|
86
|
-
overdueTerms: I,
|
|
87
|
-
isCreatingPaymentReminder: V.isPending,
|
|
88
|
-
isCreatingOverdueReminder: H.isPending,
|
|
89
|
-
today: /* @__PURE__ */ new Date(),
|
|
90
|
-
messages: D
|
|
91
|
-
}) : void 0, [
|
|
92
|
-
P,
|
|
93
|
-
j,
|
|
94
|
-
H.isPending,
|
|
95
|
-
V.isPending,
|
|
96
|
-
S,
|
|
97
|
-
x,
|
|
98
|
-
D,
|
|
99
|
-
E,
|
|
100
|
-
B.data?.data,
|
|
101
|
-
I,
|
|
102
|
-
T,
|
|
103
|
-
z.data?.data,
|
|
104
|
-
w,
|
|
105
|
-
C,
|
|
106
|
-
M
|
|
107
|
-
]),
|
|
108
|
-
reset: U,
|
|
109
|
-
toggle: W,
|
|
110
|
-
selectPaymentReminder: G,
|
|
111
|
-
selectOverdueReminder: K,
|
|
112
|
-
changeBeforeDueInput: q,
|
|
113
|
-
saveBeforeDue: Q,
|
|
114
|
-
changeOverdueTerm: J,
|
|
115
|
-
addOverdueTerm: Y,
|
|
116
|
-
clearOverdueTerms: X,
|
|
117
|
-
saveOverdue: $
|
|
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
|
|
118
152
|
};
|
|
119
153
|
}
|
|
120
154
|
//#endregion
|
|
121
|
-
export {
|
|
155
|
+
export { c as useReceivableAttachmentUploads };
|