@tesouro/embedded-components-react 0.5.205 → 0.5.207
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 +1 -1
- package/dist/index.d.ts +51 -4
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +51 -4
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +84 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +31 -25
- 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 +109 -193
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +154 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +193 -135
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +37 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +140 -86
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +42 -47
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +58 -313
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +91 -65
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +108 -102
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +48 -249
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +365 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +75 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +115 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +285 -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/index8.js +93 -407
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +430 -86
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +17 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +92 -16
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +24 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +0 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +3 -264
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +16 -70
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +1 -424
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +4 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +12 -93
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +5 -179
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +1 -344
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +264 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +72 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +402 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +106 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +249 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +344 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +195 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +29 -202
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +183 -137
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +157 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +16 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +25 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +220 -198
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +124 -84
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js
CHANGED
|
@@ -2,154 +2,212 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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 { useCounterpartQuery as n } from "../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
9
|
+
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
10
|
+
import { defaultPaymentValues as r, defaultSendValues as i, fromMajorUnits as a, hasPaymentErrors as o, hasSendErrors as s, splitEmailList as c, validatePaymentValues as l, validateSendValues as ee } from "./index9.js";
|
|
11
|
+
import { getIssueReminderBlocker as te, hasSelectedReminder as u } from "./index11.js";
|
|
12
|
+
import { useSendReceivableEmailMutation as d } from "../../data-access/dist/index5.js";
|
|
13
|
+
import { useAcceptReceivableMutation as f, useCancelReceivableMutation as p, useCloneReceivableMutation as m, useDeclineReceivableMutation as ne, useDeleteReceivableMutation as re, useIssueReceivableMutation as ie } from "../../data-access/dist/index6.js";
|
|
14
|
+
import { useMarkReceivablePaidMutation as h, useMarkReceivablePartiallyPaidMutation as g, useMarkReceivableUncollectibleMutation as _ } from "../../data-access/dist/index8.js";
|
|
7
15
|
import "../../data-access/dist/index.js";
|
|
8
|
-
import { useCallback as
|
|
16
|
+
import { useCallback as v, useState as y } from "react";
|
|
9
17
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
+
function b({ selectedReceivable: b, messages: S, onCreated: C, onDeleted: w }) {
|
|
19
|
+
let T = ie(), E = p(), D = m(), O = f(), k = ne(), A = re(), j = d(), M = h(), N = g(), P = _(), [F, I] = y(), [ae, L] = y(), [R, z] = y(), [B, V] = y(() => i(void 0, S)), [H, U] = y({}), [W, G] = y(), [K, q] = y(() => r()), [J, Y] = y({}), X = n(F?.reminderCounterpartId), Z = !!F?.reminderCounterpartId && X.isLoading, oe = v((e, t, n) => {
|
|
20
|
+
let a = "documentLabel" in t ? t.documentLabel : t.title, o = {
|
|
21
|
+
id: t.id,
|
|
22
|
+
type: t.type,
|
|
23
|
+
title: a,
|
|
24
|
+
action: e
|
|
25
|
+
}, s = n === void 0 ? b : n ?? void 0;
|
|
26
|
+
if (e === "send") {
|
|
27
|
+
z(o), V(i(s, S)), U({});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (e === "recordPayment") {
|
|
31
|
+
G({
|
|
32
|
+
...o,
|
|
33
|
+
currency: s?.currency
|
|
34
|
+
}), q(r()), Y({});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
L(void 0), I({
|
|
38
|
+
...o,
|
|
39
|
+
reminderCounterpartId: e === "issue" && s && u(s) ? s.counterpart_id : void 0
|
|
40
|
+
});
|
|
41
|
+
}, [S, b]), se = v(() => {
|
|
42
|
+
I(void 0), L(void 0);
|
|
43
|
+
}, []), Q = v(() => {
|
|
44
|
+
z(void 0), U({});
|
|
45
|
+
}, []), $ = v(() => {
|
|
46
|
+
G(void 0), Y({});
|
|
47
|
+
}, []), ce = v(async () => {
|
|
48
|
+
if (!F) return;
|
|
49
|
+
let n = { receivable_id: F.id };
|
|
50
|
+
if (F.reminderCounterpartId) {
|
|
51
|
+
if (Z) return;
|
|
52
|
+
let t = te(X.data, S);
|
|
53
|
+
if (t) {
|
|
54
|
+
e.error(t), I(void 0);
|
|
45
55
|
return;
|
|
46
56
|
}
|
|
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));
|
|
60
57
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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);
|
|
58
|
+
try {
|
|
59
|
+
if (F.action === "issue") await T.mutateAsync({ path: n });
|
|
60
|
+
else if (F.action === "cancel") await E.mutateAsync({ path: n });
|
|
61
|
+
else if (F.action === "clone") {
|
|
62
|
+
let e = await D.mutateAsync({ path: n });
|
|
63
|
+
e?.id && C?.(e.id, e.type);
|
|
64
|
+
} else F.action === "accept" ? await O.mutateAsync({ path: n }) : F.action === "decline" ? await k.mutateAsync({ path: n }) : F.action === "delete" ? (await A.mutateAsync({ path: n }), w?.(F.id)) : F.action === "markPaid" ? await M.mutateAsync({
|
|
65
|
+
path: n,
|
|
66
|
+
body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
67
|
+
}) : F.action === "markUncollectible" && await P.mutateAsync({ path: n });
|
|
68
|
+
I(void 0), L(void 0);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
L(t(e) ?? S.genericError);
|
|
90
71
|
}
|
|
91
|
-
o.length > 0 && m((e) => [...e, ...o]), g(s);
|
|
92
72
|
}, [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
73
|
+
O,
|
|
74
|
+
F,
|
|
75
|
+
E,
|
|
76
|
+
D,
|
|
77
|
+
k,
|
|
78
|
+
A,
|
|
79
|
+
Z,
|
|
80
|
+
T,
|
|
81
|
+
M,
|
|
82
|
+
S,
|
|
83
|
+
C,
|
|
84
|
+
w,
|
|
85
|
+
X.data,
|
|
86
|
+
P
|
|
87
|
+
]), le = v(async () => {
|
|
88
|
+
if (!R) return;
|
|
89
|
+
let e = ee(B, S);
|
|
90
|
+
if (s(e)) {
|
|
91
|
+
U(e);
|
|
106
92
|
return;
|
|
107
93
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
94
|
+
try {
|
|
95
|
+
await j.mutateAsync({
|
|
96
|
+
path: { receivable_id: R.id },
|
|
97
|
+
body: {
|
|
98
|
+
body_text: B.body,
|
|
99
|
+
subject_text: B.subject,
|
|
100
|
+
recipients: {
|
|
101
|
+
to: c(B.to),
|
|
102
|
+
cc: c(B.cc),
|
|
103
|
+
bcc: c(B.bcc)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}), Q();
|
|
107
|
+
} catch (e) {
|
|
108
|
+
U({ form: t(e) ?? S.genericError });
|
|
111
109
|
}
|
|
112
|
-
f({
|
|
113
|
-
path: { file_id: e },
|
|
114
|
-
receivableId: u
|
|
115
|
-
});
|
|
116
110
|
}, [
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
let e =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
111
|
+
Q,
|
|
112
|
+
S,
|
|
113
|
+
j,
|
|
114
|
+
R,
|
|
115
|
+
B
|
|
116
|
+
]), ue = v(async () => {
|
|
117
|
+
if (!W) return;
|
|
118
|
+
let e = l(K, S, W.currency);
|
|
119
|
+
if (o(e)) {
|
|
120
|
+
Y(e);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
|
|
125
|
+
K.mode === "full" ? await M.mutateAsync({
|
|
126
|
+
path: e,
|
|
127
|
+
body: {
|
|
128
|
+
comment: K.comment || void 0,
|
|
129
|
+
paid_at: t
|
|
130
|
+
}
|
|
131
|
+
}) : await N.mutateAsync({
|
|
132
|
+
path: e,
|
|
133
|
+
body: {
|
|
134
|
+
amount_paid: a(K.amountPaid, W.currency) ?? 0,
|
|
135
|
+
comment: K.comment || void 0
|
|
136
|
+
}
|
|
137
|
+
}), $();
|
|
138
|
+
} catch (e) {
|
|
139
|
+
Y({ form: t(e) ?? S.genericError });
|
|
140
|
+
}
|
|
130
141
|
}, [
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
receivableId: u
|
|
139
|
-
});
|
|
140
|
-
b.current.clear();
|
|
141
|
-
}, [f, u]);
|
|
142
|
+
$,
|
|
143
|
+
M,
|
|
144
|
+
S,
|
|
145
|
+
N,
|
|
146
|
+
W,
|
|
147
|
+
K
|
|
148
|
+
]);
|
|
142
149
|
return {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
actionTarget: F,
|
|
151
|
+
actionDialog: F ? x(F.action, S) : void 0,
|
|
152
|
+
actionError: ae,
|
|
153
|
+
actionInProgress: Z || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || A.isPending || M.isPending || P.isPending,
|
|
154
|
+
openAction: oe,
|
|
155
|
+
closeAction: se,
|
|
156
|
+
confirmAction: ce,
|
|
157
|
+
sendOpen: !!R,
|
|
158
|
+
sendValues: B,
|
|
159
|
+
sendErrors: H,
|
|
160
|
+
sendInProgress: j.isPending,
|
|
161
|
+
setSendValues: V,
|
|
162
|
+
closeSend: Q,
|
|
163
|
+
submitSend: le,
|
|
164
|
+
paymentOpen: !!W,
|
|
165
|
+
paymentValues: K,
|
|
166
|
+
paymentErrors: J,
|
|
167
|
+
paymentInProgress: M.isPending || N.isPending,
|
|
168
|
+
setPaymentValues: q,
|
|
169
|
+
closePayment: $,
|
|
170
|
+
submitPayment: ue
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function x(e, t) {
|
|
174
|
+
return e === "issue" ? {
|
|
175
|
+
title: t.issueTitle,
|
|
176
|
+
description: t.issueDescription,
|
|
177
|
+
confirmLabel: t.issueConfirm
|
|
178
|
+
} : e === "accept" ? {
|
|
179
|
+
title: t.acceptTitle,
|
|
180
|
+
description: t.acceptDescription,
|
|
181
|
+
confirmLabel: t.acceptConfirm
|
|
182
|
+
} : e === "decline" ? {
|
|
183
|
+
title: t.declineTitle,
|
|
184
|
+
description: t.declineDescription,
|
|
185
|
+
confirmLabel: t.declineConfirm,
|
|
186
|
+
destructive: !0
|
|
187
|
+
} : e === "cancel" ? {
|
|
188
|
+
title: t.cancelTitle,
|
|
189
|
+
description: t.cancelDescription,
|
|
190
|
+
confirmLabel: t.cancelConfirm,
|
|
191
|
+
destructive: !0
|
|
192
|
+
} : e === "clone" ? {
|
|
193
|
+
title: t.cloneTitle,
|
|
194
|
+
description: t.cloneDescription,
|
|
195
|
+
confirmLabel: t.cloneConfirm
|
|
196
|
+
} : e === "delete" ? {
|
|
197
|
+
title: t.deleteTitle,
|
|
198
|
+
description: t.deleteDescription,
|
|
199
|
+
confirmLabel: t.deleteConfirm,
|
|
200
|
+
destructive: !0
|
|
201
|
+
} : e === "markPaid" ? {
|
|
202
|
+
title: t.markPaidTitle,
|
|
203
|
+
description: t.markPaidDescription,
|
|
204
|
+
confirmLabel: t.markPaidConfirm
|
|
205
|
+
} : {
|
|
206
|
+
title: t.markUncollectibleTitle,
|
|
207
|
+
description: t.markUncollectibleDescription,
|
|
208
|
+
confirmLabel: t.markUncollectibleConfirm,
|
|
209
|
+
destructive: !0
|
|
152
210
|
};
|
|
153
211
|
}
|
|
154
212
|
//#endregion
|
|
155
|
-
export {
|
|
213
|
+
export { b as useReceivableActions };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js
CHANGED
|
@@ -1,63 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { buildReceivableDetailsView as e } from "./index9.js";
|
|
6
|
+
import { useReceivableHistoryQuery as t, useReceivableMailsQuery as n, useReceivablePdfLinkQuery as r, useReceivableQuery as i } from "../../data-access/dist/index9.js";
|
|
7
|
+
import "../../data-access/dist/index.js";
|
|
8
|
+
import { useMemo as a } from "react";
|
|
4
9
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
function o({ selectedReceivableId: o, enabled: s = !0, messages: c }) {
|
|
11
|
+
let l = i(o, { enabled: s }), u = t(o, {
|
|
12
|
+
enabled: s,
|
|
13
|
+
limit: 25,
|
|
14
|
+
sort: "timestamp",
|
|
15
|
+
order: "desc"
|
|
16
|
+
}), d = n(o, {
|
|
17
|
+
enabled: s,
|
|
18
|
+
limit: 10,
|
|
19
|
+
sort: "created_at",
|
|
20
|
+
order: "desc"
|
|
21
|
+
}), f = r(o, { enabled: s && !!l.data }), p = a(() => e({
|
|
22
|
+
receivable: l.data,
|
|
23
|
+
history: u.data?.data ?? [],
|
|
24
|
+
mails: d.data?.data ?? [],
|
|
25
|
+
pdfUrl: f.data?.file_url || f.data?.original_file_url || void 0,
|
|
26
|
+
messages: c
|
|
27
|
+
}), [
|
|
28
|
+
l.data,
|
|
29
|
+
u.data?.data,
|
|
30
|
+
d.data?.data,
|
|
31
|
+
c,
|
|
32
|
+
f.data
|
|
33
|
+
]);
|
|
13
34
|
return {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
35
|
+
receivable: l.data,
|
|
36
|
+
detailsView: p,
|
|
37
|
+
isLoading: l.isLoading || u.isLoading || d.isLoading || f.isLoading,
|
|
38
|
+
isError: l.isError
|
|
60
39
|
};
|
|
61
40
|
}
|
|
62
41
|
//#endregion
|
|
63
|
-
export {
|
|
42
|
+
export { o as useReceivableDetails };
|