@txgw/payout-components 0.1.2 → 0.1.4
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.
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { bX as g, ab as p } from "./vendor-C7cpyYhi.js";
|
|
2
|
+
import { t as E, d as j, r as w, T as x } from "./amis-bclZq1Od.js";
|
|
3
|
+
const O = "bankDetails";
|
|
4
|
+
async function b(r, t, s, u = 0) {
|
|
5
|
+
if (u < 0)
|
|
6
|
+
throw new Error("[payout-sdk] fetchWithAuth retries exceeded");
|
|
7
|
+
const { headers: n, authCode: m, domain: a, codeVerifier: _ } = s, e = localStorage.getItem("access_token");
|
|
8
|
+
if (e)
|
|
9
|
+
t.access_token = e;
|
|
10
|
+
else {
|
|
11
|
+
const o = await R(
|
|
12
|
+
m,
|
|
13
|
+
a,
|
|
14
|
+
_
|
|
15
|
+
);
|
|
16
|
+
if (!o.access_token || !o.refresh_token)
|
|
17
|
+
throw localStorage.removeItem("access_token"), localStorage.removeItem("refresh_token"), new Error(
|
|
18
|
+
"[payout-sdk] getAccessToken failed, check authCode validity"
|
|
19
|
+
);
|
|
20
|
+
t.access_token = o.access_token, localStorage.setItem("access_token", o.access_token), localStorage.setItem("refresh_token", o.refresh_token);
|
|
21
|
+
}
|
|
22
|
+
const f = await fetch(r, {
|
|
23
|
+
...s,
|
|
24
|
+
body: JSON.stringify(t),
|
|
25
|
+
headers: {
|
|
26
|
+
...n,
|
|
27
|
+
"Content-Type": "application/json"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (f.status === 400) {
|
|
31
|
+
const o = await f.json();
|
|
32
|
+
if (o.name != "INTERNAL_ERROR")
|
|
33
|
+
throw E.error(`${o.name}: ${o.message}`), new Error(`[payout-sdk] ${o.name}: ${o.message}`);
|
|
34
|
+
const h = localStorage.getItem("refresh_token");
|
|
35
|
+
if (h) {
|
|
36
|
+
const d = await M(
|
|
37
|
+
h,
|
|
38
|
+
a
|
|
39
|
+
);
|
|
40
|
+
if (!d.access_token || !d.refresh_token)
|
|
41
|
+
localStorage.removeItem("access_token"), localStorage.removeItem("refresh_token");
|
|
42
|
+
else
|
|
43
|
+
return localStorage.setItem(
|
|
44
|
+
"refresh_token",
|
|
45
|
+
d.refresh_token
|
|
46
|
+
), localStorage.setItem("access_token", d.access_token), b(r, t, s, --u);
|
|
47
|
+
}
|
|
48
|
+
const l = await R(
|
|
49
|
+
m,
|
|
50
|
+
a,
|
|
51
|
+
_
|
|
52
|
+
);
|
|
53
|
+
if (!l.access_token || !l.refresh_token)
|
|
54
|
+
throw new Error(
|
|
55
|
+
"[payout-sdk] getAccessToken failed, check authCode validity"
|
|
56
|
+
);
|
|
57
|
+
return localStorage.setItem("refresh_token", l.refresh_token), localStorage.setItem("access_token", l.access_token), b(r, t, s, --u);
|
|
58
|
+
}
|
|
59
|
+
return f;
|
|
60
|
+
}
|
|
61
|
+
async function R(r, t, s) {
|
|
62
|
+
const u = {
|
|
63
|
+
authorization_code: r,
|
|
64
|
+
code_verifier: s
|
|
65
|
+
};
|
|
66
|
+
return await (await fetch(`${t}/v1/payout/auth/token`, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: JSON.stringify(u),
|
|
69
|
+
headers: {
|
|
70
|
+
"Content-Type": "application/json"
|
|
71
|
+
}
|
|
72
|
+
})).json();
|
|
73
|
+
}
|
|
74
|
+
async function M(r, t) {
|
|
75
|
+
const s = {
|
|
76
|
+
refresh_token: r
|
|
77
|
+
};
|
|
78
|
+
return await (await fetch(`${t}/v1/payout/auth/token/refresh`, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
body: JSON.stringify(s),
|
|
81
|
+
headers: {
|
|
82
|
+
"Content-Type": "application/json"
|
|
83
|
+
}
|
|
84
|
+
})).json();
|
|
85
|
+
}
|
|
86
|
+
async function A(r, t, s) {
|
|
87
|
+
return (await (await b(
|
|
88
|
+
"/v1/payout/beneficiary/token/countryinfos",
|
|
89
|
+
{},
|
|
90
|
+
{
|
|
91
|
+
method: "POST",
|
|
92
|
+
authCode: r,
|
|
93
|
+
domain: t,
|
|
94
|
+
codeVerifier: s
|
|
95
|
+
}
|
|
96
|
+
)).json()).country_infos || [];
|
|
97
|
+
}
|
|
98
|
+
async function B({ inputRegionCode: r, inputPayoutType: t, inputCurrency: s }, u, n, m, a) {
|
|
99
|
+
const e = await (await b(
|
|
100
|
+
"/v1/payout/beneficiary/token/paymentmethodinfos",
|
|
101
|
+
{
|
|
102
|
+
region_code: r
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
method: "POST",
|
|
106
|
+
authCode: u,
|
|
107
|
+
domain: n,
|
|
108
|
+
codeVerifier: m
|
|
109
|
+
}
|
|
110
|
+
)).json(), f = [];
|
|
111
|
+
for (const o of Object.values(e.countries)) {
|
|
112
|
+
const h = o.payoutTypes?.[t]?.currencies;
|
|
113
|
+
if (h)
|
|
114
|
+
for (const [l, d] of Object.entries(h))
|
|
115
|
+
l === s && f.push(d);
|
|
116
|
+
}
|
|
117
|
+
if (f.length !== 0)
|
|
118
|
+
return {
|
|
119
|
+
type: "list-select",
|
|
120
|
+
name: "inputPaymentMethod",
|
|
121
|
+
label: "Transfer method",
|
|
122
|
+
options: f.map((o) => ({
|
|
123
|
+
value: o.payment_method,
|
|
124
|
+
body: /* @__PURE__ */ g.jsxs("div", { children: [
|
|
125
|
+
/* @__PURE__ */ g.jsx("span", { className: "flex font-bold", children: o.display_name }),
|
|
126
|
+
/* @__PURE__ */ g.jsx("span", { className: "flex mt-1", children: o.description })
|
|
127
|
+
] })
|
|
128
|
+
})),
|
|
129
|
+
value: a?.transfer_method
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
async function N({
|
|
133
|
+
inputRegionCode: r,
|
|
134
|
+
inputCurrency: t,
|
|
135
|
+
inputPaymentMethod: s
|
|
136
|
+
}, u, n, m) {
|
|
137
|
+
const e = await (await b(
|
|
138
|
+
"/v1/payout/beneficiary/form/schema/token/query",
|
|
139
|
+
{
|
|
140
|
+
payment_method: s,
|
|
141
|
+
region: r,
|
|
142
|
+
currency: t,
|
|
143
|
+
local_clearing_system: "",
|
|
144
|
+
version: "v1",
|
|
145
|
+
entity_type: "ENTITY_TYPE_PERSONAL"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
method: "POST",
|
|
149
|
+
authCode: u,
|
|
150
|
+
domain: n,
|
|
151
|
+
codeVerifier: m
|
|
152
|
+
}
|
|
153
|
+
)).json();
|
|
154
|
+
return JSON.parse(
|
|
155
|
+
e.beneficiary_schema.amis_page.replace(/Area Code/g, "AREA_CODE")
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
function q({
|
|
159
|
+
authCode: r,
|
|
160
|
+
domain: t,
|
|
161
|
+
codeVerifier: s,
|
|
162
|
+
emitter: u,
|
|
163
|
+
defaultValues: n,
|
|
164
|
+
customizations: m
|
|
165
|
+
}) {
|
|
166
|
+
const [a, _] = p.useState([]), [e, f] = p.useState(), [o, h] = p.useState(), [l, d] = p.useState(), C = p.useMemo(() => !m?.layout?.find(
|
|
167
|
+
(c) => c.name === O
|
|
168
|
+
)?.hidden, [m?.layout]), S = p.useCallback(
|
|
169
|
+
(i) => {
|
|
170
|
+
const c = i.body.findIndex(
|
|
171
|
+
(k) => k.type === "form"
|
|
172
|
+
), y = i.body[c];
|
|
173
|
+
i.body[c].onFinished = (k) => {
|
|
174
|
+
const P = j(y.api.data, k, void 0, !0);
|
|
175
|
+
u.emit("submit", P);
|
|
176
|
+
}, d(i);
|
|
177
|
+
},
|
|
178
|
+
[u]
|
|
179
|
+
), T = p.useMemo(() => {
|
|
180
|
+
const i = /* @__PURE__ */ new Set();
|
|
181
|
+
return a.filter(
|
|
182
|
+
(y) => y.country_number && !i.has(y.country_number) && i.add(y.country_number)
|
|
183
|
+
).map((y) => ({
|
|
184
|
+
label: y.country_name_standard || y.country_name,
|
|
185
|
+
value: y.country_code
|
|
186
|
+
})).sort((y, k) => y.label.localeCompare(k.label));
|
|
187
|
+
}, [a]), v = p.useMemo(() => Array.from(
|
|
188
|
+
new Set(a.map((c) => c.currency_code))
|
|
189
|
+
).map((c) => ({
|
|
190
|
+
label: c,
|
|
191
|
+
value: c
|
|
192
|
+
})).filter((c) => !!c.label && c.label !== "-").sort((c, y) => c.label.localeCompare(y.label)), [a]);
|
|
193
|
+
p.useEffect(() => {
|
|
194
|
+
a.length !== 0 && e?.inputRegionCode && e?.inputCurrency && e?.inputPayoutType && B(
|
|
195
|
+
{
|
|
196
|
+
inputRegionCode: e.inputRegionCode,
|
|
197
|
+
inputCurrency: e.inputCurrency,
|
|
198
|
+
inputPayoutType: e.inputPayoutType
|
|
199
|
+
},
|
|
200
|
+
r,
|
|
201
|
+
t,
|
|
202
|
+
s,
|
|
203
|
+
n
|
|
204
|
+
).then(h);
|
|
205
|
+
}, [
|
|
206
|
+
a,
|
|
207
|
+
r,
|
|
208
|
+
t,
|
|
209
|
+
e?.inputRegionCode,
|
|
210
|
+
e?.inputCurrency,
|
|
211
|
+
e?.inputPayoutType,
|
|
212
|
+
n,
|
|
213
|
+
s
|
|
214
|
+
]), p.useEffect(() => {
|
|
215
|
+
a.length !== 0 && o && e?.inputPaymentMethod && e?.inputRegionCode && e?.inputCurrency && N(
|
|
216
|
+
{
|
|
217
|
+
inputPaymentMethod: e.inputPaymentMethod,
|
|
218
|
+
inputRegionCode: e.inputRegionCode,
|
|
219
|
+
inputCurrency: e.inputCurrency
|
|
220
|
+
},
|
|
221
|
+
r,
|
|
222
|
+
t,
|
|
223
|
+
s
|
|
224
|
+
).then((i) => i && S(i));
|
|
225
|
+
}, [
|
|
226
|
+
a,
|
|
227
|
+
o,
|
|
228
|
+
r,
|
|
229
|
+
t,
|
|
230
|
+
s,
|
|
231
|
+
e?.inputPaymentMethod,
|
|
232
|
+
e?.inputRegionCode,
|
|
233
|
+
e?.inputCurrency,
|
|
234
|
+
S
|
|
235
|
+
]), p.useEffect(() => {
|
|
236
|
+
e?.inputCurrency || h(void 0);
|
|
237
|
+
}, [e?.inputCurrency]), p.useEffect(() => {
|
|
238
|
+
n && f({
|
|
239
|
+
inputPayoutType: n.payout_type || "B2P",
|
|
240
|
+
inputPaymentMethod: n.transfer_method,
|
|
241
|
+
inputRegionCode: n.region_code,
|
|
242
|
+
inputCurrency: n.currency
|
|
243
|
+
});
|
|
244
|
+
}, [n]);
|
|
245
|
+
const I = p.useMemo(
|
|
246
|
+
() => ({
|
|
247
|
+
type: "page",
|
|
248
|
+
visible: C,
|
|
249
|
+
body: {
|
|
250
|
+
type: "spinner",
|
|
251
|
+
show: a.length === 0,
|
|
252
|
+
overlay: !0,
|
|
253
|
+
body: [
|
|
254
|
+
{
|
|
255
|
+
type: "form",
|
|
256
|
+
title: "Bank Details",
|
|
257
|
+
submitText: "",
|
|
258
|
+
onChange: (i) => {
|
|
259
|
+
f(i);
|
|
260
|
+
},
|
|
261
|
+
body: [
|
|
262
|
+
{
|
|
263
|
+
label: "Bank Location",
|
|
264
|
+
type: "input-text",
|
|
265
|
+
creatable: !1,
|
|
266
|
+
name: "inputRegionCode",
|
|
267
|
+
options: T,
|
|
268
|
+
value: n?.region_code
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
label: "Bank account type",
|
|
272
|
+
type: "radios",
|
|
273
|
+
name: "inputPayoutType",
|
|
274
|
+
selectFirst: !0,
|
|
275
|
+
options: [
|
|
276
|
+
{
|
|
277
|
+
label: "Individual",
|
|
278
|
+
value: "B2P"
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
value: n?.payout_type
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
label: "Account currency",
|
|
285
|
+
type: "input-text",
|
|
286
|
+
creatable: !1,
|
|
287
|
+
name: "inputCurrency",
|
|
288
|
+
options: v,
|
|
289
|
+
value: n?.currency
|
|
290
|
+
},
|
|
291
|
+
o
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
}),
|
|
297
|
+
[
|
|
298
|
+
C,
|
|
299
|
+
a.length,
|
|
300
|
+
T,
|
|
301
|
+
n?.region_code,
|
|
302
|
+
n?.payout_type,
|
|
303
|
+
n?.currency,
|
|
304
|
+
v,
|
|
305
|
+
o
|
|
306
|
+
]
|
|
307
|
+
);
|
|
308
|
+
return p.useEffect(() => {
|
|
309
|
+
async function i() {
|
|
310
|
+
const c = await A(
|
|
311
|
+
r,
|
|
312
|
+
t,
|
|
313
|
+
s
|
|
314
|
+
);
|
|
315
|
+
_(c);
|
|
316
|
+
}
|
|
317
|
+
i();
|
|
318
|
+
}, [r, s, t]), /* @__PURE__ */ g.jsxs(g.Fragment, { children: [
|
|
319
|
+
/* @__PURE__ */ g.jsx(x, {}),
|
|
320
|
+
w(I),
|
|
321
|
+
l && w(l)
|
|
322
|
+
] });
|
|
323
|
+
}
|
|
324
|
+
export {
|
|
325
|
+
q as default
|
|
326
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare interface BaseProps<T extends keyof typeof ElementsMap> extends InitOpti
|
|
|
12
12
|
emitter: Emitter<Events<T>>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
declare function BeneficiaryForm({ authCode, domain, emitter, defaultValues, customizations, }: Props): JSX_2.Element;
|
|
15
|
+
declare function BeneficiaryForm({ authCode, domain, codeVerifier, emitter, defaultValues, customizations, }: Props): JSX_2.Element;
|
|
16
16
|
|
|
17
17
|
declare interface BeneficiaryFormCustomizations {
|
|
18
18
|
layout?: LayoutSection[];
|
|
@@ -75,6 +75,7 @@ export declare function init(options: InitOptions): void;
|
|
|
75
75
|
declare interface InitOptions {
|
|
76
76
|
authCode: string;
|
|
77
77
|
domain: string;
|
|
78
|
+
codeVerifier: string;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
declare interface LayoutSection {
|
|
@@ -88,6 +89,7 @@ declare type PayoutType = "B2P";
|
|
|
88
89
|
declare interface Props {
|
|
89
90
|
authCode: string;
|
|
90
91
|
domain: string;
|
|
92
|
+
codeVerifier: string;
|
|
91
93
|
emitter: Emitter<ElementEventsMap["beneficiaryForm"]>;
|
|
92
94
|
defaultValues?: BeneficiaryFormDefaultValues;
|
|
93
95
|
customizations?: BeneficiaryFormCustomizations;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@txgw/payout-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"@vitejs/plugin-react-swc": "^4.0.0",
|
|
33
33
|
"postcss-discard-comments": "^7.0.4",
|
|
34
34
|
"rollup-plugin-visualizer": "^6.0.3",
|
|
35
|
-
"terser": "^5.44.0",
|
|
36
35
|
"vite": "^7.1.2",
|
|
37
36
|
"vite-plugin-dts": "^4.5.4"
|
|
38
37
|
},
|
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import { bX as _, ab as i } from "./vendor-C7cpyYhi.js";
|
|
2
|
-
import { t as P, d as E, r as v, T as j } from "./amis-bclZq1Od.js";
|
|
3
|
-
const x = "bankDetails";
|
|
4
|
-
async function k(o, n, r, t = 0) {
|
|
5
|
-
if (t < 0)
|
|
6
|
-
throw new Error("[payout-sdk] fetchWithAuth retries exceeded");
|
|
7
|
-
const y = localStorage.getItem("access_token");
|
|
8
|
-
if (y)
|
|
9
|
-
n.access_token = y;
|
|
10
|
-
else {
|
|
11
|
-
const s = await w(
|
|
12
|
-
r.authCode,
|
|
13
|
-
r.domain
|
|
14
|
-
);
|
|
15
|
-
if (!s.access_token || !s.refresh_token)
|
|
16
|
-
throw localStorage.removeItem("access_token"), localStorage.removeItem("refresh_token"), new Error(
|
|
17
|
-
"[payout-sdk] getAccessToken failed, check authCode validity"
|
|
18
|
-
);
|
|
19
|
-
n.access_token = s.access_token, localStorage.setItem("access_token", s.access_token), localStorage.setItem("refresh_token", s.refresh_token);
|
|
20
|
-
}
|
|
21
|
-
const { headers: p } = r, h = await fetch(o, {
|
|
22
|
-
...r,
|
|
23
|
-
body: JSON.stringify(n),
|
|
24
|
-
headers: {
|
|
25
|
-
...p,
|
|
26
|
-
"Content-Type": "application/json"
|
|
27
|
-
}
|
|
28
|
-
}), { authCode: e, domain: f } = r;
|
|
29
|
-
if (h.status === 400) {
|
|
30
|
-
const s = await h.json();
|
|
31
|
-
if (s.name != "INTERNAL_ERROR")
|
|
32
|
-
throw P.error(`${s.name}: ${s.message}`), new Error(`[payout-sdk] ${s.name}: ${s.message}`);
|
|
33
|
-
const l = localStorage.getItem("refresh_token");
|
|
34
|
-
if (l) {
|
|
35
|
-
const d = await O(
|
|
36
|
-
l,
|
|
37
|
-
f
|
|
38
|
-
);
|
|
39
|
-
if (!d.access_token || !d.refresh_token)
|
|
40
|
-
localStorage.removeItem("access_token"), localStorage.removeItem("refresh_token");
|
|
41
|
-
else
|
|
42
|
-
return localStorage.setItem(
|
|
43
|
-
"refresh_token",
|
|
44
|
-
d.refresh_token
|
|
45
|
-
), localStorage.setItem("access_token", d.access_token), k(o, n, r, --t);
|
|
46
|
-
}
|
|
47
|
-
const m = await w(e, f);
|
|
48
|
-
if (!m.access_token || !m.refresh_token)
|
|
49
|
-
throw new Error(
|
|
50
|
-
"[payout-sdk] getAccessToken failed, check authCode validity"
|
|
51
|
-
);
|
|
52
|
-
return localStorage.setItem("refresh_token", m.refresh_token), localStorage.setItem("access_token", m.access_token), k(o, n, r, --t);
|
|
53
|
-
}
|
|
54
|
-
return h;
|
|
55
|
-
}
|
|
56
|
-
async function w(o, n) {
|
|
57
|
-
const r = {
|
|
58
|
-
authorization_code: o,
|
|
59
|
-
code_verifier: "code_verifier"
|
|
60
|
-
};
|
|
61
|
-
return await (await fetch(`${n}/v1/payout/auth/token`, {
|
|
62
|
-
method: "POST",
|
|
63
|
-
body: JSON.stringify(r),
|
|
64
|
-
headers: {
|
|
65
|
-
"Content-Type": "application/json"
|
|
66
|
-
}
|
|
67
|
-
})).json();
|
|
68
|
-
}
|
|
69
|
-
async function O(o, n) {
|
|
70
|
-
const r = {
|
|
71
|
-
refresh_token: o
|
|
72
|
-
};
|
|
73
|
-
return await (await fetch(`${n}/v1/payout/auth/token/refresh`, {
|
|
74
|
-
method: "POST",
|
|
75
|
-
body: JSON.stringify(r),
|
|
76
|
-
headers: {
|
|
77
|
-
"Content-Type": "application/json"
|
|
78
|
-
}
|
|
79
|
-
})).json();
|
|
80
|
-
}
|
|
81
|
-
async function M(o, n) {
|
|
82
|
-
return (await (await k(
|
|
83
|
-
"/v1/payout/beneficiary/token/countryinfos",
|
|
84
|
-
{},
|
|
85
|
-
{
|
|
86
|
-
method: "POST",
|
|
87
|
-
authCode: o,
|
|
88
|
-
domain: n
|
|
89
|
-
}
|
|
90
|
-
)).json()).country_infos || [];
|
|
91
|
-
}
|
|
92
|
-
async function A({ inputRegionCode: o, inputPayoutType: n, inputCurrency: r }, t, y, p) {
|
|
93
|
-
const e = await (await k(
|
|
94
|
-
"/v1/payout/beneficiary/token/paymentmethodinfos",
|
|
95
|
-
{
|
|
96
|
-
region_code: o
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
method: "POST",
|
|
100
|
-
authCode: t,
|
|
101
|
-
domain: y
|
|
102
|
-
}
|
|
103
|
-
)).json(), f = [];
|
|
104
|
-
for (const s of Object.values(e.countries)) {
|
|
105
|
-
const l = s.payoutTypes?.[n]?.currencies;
|
|
106
|
-
if (l)
|
|
107
|
-
for (const [m, d] of Object.entries(l))
|
|
108
|
-
m === r && f.push(d);
|
|
109
|
-
}
|
|
110
|
-
if (f.length !== 0)
|
|
111
|
-
return {
|
|
112
|
-
type: "list-select",
|
|
113
|
-
name: "inputPaymentMethod",
|
|
114
|
-
label: "Transfer method",
|
|
115
|
-
options: f.map((s) => ({
|
|
116
|
-
value: s.payment_method,
|
|
117
|
-
body: /* @__PURE__ */ _.jsxs("div", { children: [
|
|
118
|
-
/* @__PURE__ */ _.jsx("span", { className: "flex font-bold", children: s.display_name }),
|
|
119
|
-
/* @__PURE__ */ _.jsx("span", { className: "flex mt-1", children: s.description })
|
|
120
|
-
] })
|
|
121
|
-
})),
|
|
122
|
-
value: p?.transfer_method
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
async function B({
|
|
126
|
-
inputRegionCode: o,
|
|
127
|
-
inputCurrency: n,
|
|
128
|
-
inputPaymentMethod: r
|
|
129
|
-
}, t, y) {
|
|
130
|
-
const e = await (await k(
|
|
131
|
-
"/v1/payout/beneficiary/form/schema/token/query",
|
|
132
|
-
{
|
|
133
|
-
payment_method: r,
|
|
134
|
-
region: o,
|
|
135
|
-
currency: n,
|
|
136
|
-
local_clearing_system: "",
|
|
137
|
-
version: "v1",
|
|
138
|
-
entity_type: "ENTITY_TYPE_PERSONAL"
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
method: "POST",
|
|
142
|
-
authCode: t,
|
|
143
|
-
domain: y
|
|
144
|
-
}
|
|
145
|
-
)).json();
|
|
146
|
-
return JSON.parse(
|
|
147
|
-
e.beneficiary_schema.amis_page.replace(/Area Code/g, "AREA_CODE")
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
function $({
|
|
151
|
-
authCode: o,
|
|
152
|
-
domain: n,
|
|
153
|
-
emitter: r,
|
|
154
|
-
defaultValues: t,
|
|
155
|
-
customizations: y
|
|
156
|
-
}) {
|
|
157
|
-
const [p, h] = i.useState([]), [e, f] = i.useState(), [s, l] = i.useState(), [m, d] = i.useState(), b = i.useMemo(() => !y?.layout?.find(
|
|
158
|
-
(a) => a.name === x
|
|
159
|
-
)?.hidden, [y?.layout]), C = i.useCallback(
|
|
160
|
-
(c) => {
|
|
161
|
-
const a = c.body.findIndex(
|
|
162
|
-
(g) => g.type === "form"
|
|
163
|
-
), u = c.body[a];
|
|
164
|
-
c.body[a].onFinished = (g) => {
|
|
165
|
-
const I = E(u.api.data, g, void 0, !0);
|
|
166
|
-
r.emit("submit", I);
|
|
167
|
-
}, d(c);
|
|
168
|
-
},
|
|
169
|
-
[r]
|
|
170
|
-
), S = i.useMemo(() => {
|
|
171
|
-
const c = /* @__PURE__ */ new Set();
|
|
172
|
-
return p.filter(
|
|
173
|
-
(u) => u.country_number && !c.has(u.country_number) && c.add(u.country_number)
|
|
174
|
-
).map((u) => ({
|
|
175
|
-
label: u.country_name_standard || u.country_name,
|
|
176
|
-
value: u.country_code
|
|
177
|
-
})).sort((u, g) => u.label.localeCompare(g.label));
|
|
178
|
-
}, [p]), T = i.useMemo(() => Array.from(
|
|
179
|
-
new Set(p.map((a) => a.currency_code))
|
|
180
|
-
).map((a) => ({
|
|
181
|
-
label: a,
|
|
182
|
-
value: a
|
|
183
|
-
})).filter((a) => !!a.label && a.label !== "-").sort((a, u) => a.label.localeCompare(u.label)), [p]);
|
|
184
|
-
i.useEffect(() => {
|
|
185
|
-
e?.inputRegionCode && e?.inputCurrency && e?.inputPayoutType && A(
|
|
186
|
-
{
|
|
187
|
-
inputRegionCode: e.inputRegionCode,
|
|
188
|
-
inputCurrency: e.inputCurrency,
|
|
189
|
-
inputPayoutType: e.inputPayoutType
|
|
190
|
-
},
|
|
191
|
-
o,
|
|
192
|
-
n,
|
|
193
|
-
t
|
|
194
|
-
).then(l);
|
|
195
|
-
}, [
|
|
196
|
-
o,
|
|
197
|
-
n,
|
|
198
|
-
e?.inputRegionCode,
|
|
199
|
-
e?.inputCurrency,
|
|
200
|
-
e?.inputPayoutType,
|
|
201
|
-
t
|
|
202
|
-
]), i.useEffect(() => {
|
|
203
|
-
e?.inputPaymentMethod && e?.inputRegionCode && e?.inputCurrency && B(
|
|
204
|
-
{
|
|
205
|
-
inputPaymentMethod: e.inputPaymentMethod,
|
|
206
|
-
inputRegionCode: e.inputRegionCode,
|
|
207
|
-
inputCurrency: e.inputCurrency
|
|
208
|
-
},
|
|
209
|
-
o,
|
|
210
|
-
n
|
|
211
|
-
).then((c) => c && C(c));
|
|
212
|
-
}, [
|
|
213
|
-
o,
|
|
214
|
-
n,
|
|
215
|
-
e?.inputPaymentMethod,
|
|
216
|
-
e?.inputRegionCode,
|
|
217
|
-
e?.inputCurrency,
|
|
218
|
-
C
|
|
219
|
-
]), i.useEffect(() => {
|
|
220
|
-
e?.inputCurrency || l(void 0);
|
|
221
|
-
}, [e?.inputCurrency]), i.useEffect(() => {
|
|
222
|
-
t && f({
|
|
223
|
-
inputPayoutType: t.payout_type || "B2P",
|
|
224
|
-
inputPaymentMethod: t.transfer_method,
|
|
225
|
-
inputRegionCode: t.region_code,
|
|
226
|
-
inputCurrency: t.currency
|
|
227
|
-
});
|
|
228
|
-
}, [t]);
|
|
229
|
-
const R = i.useMemo(
|
|
230
|
-
() => ({
|
|
231
|
-
type: "page",
|
|
232
|
-
visible: b,
|
|
233
|
-
body: {
|
|
234
|
-
type: "spinner",
|
|
235
|
-
show: p.length === 0,
|
|
236
|
-
overlay: !0,
|
|
237
|
-
body: [
|
|
238
|
-
{
|
|
239
|
-
type: "form",
|
|
240
|
-
title: "Bank Details",
|
|
241
|
-
submitText: "",
|
|
242
|
-
onChange: (c) => {
|
|
243
|
-
f(c);
|
|
244
|
-
},
|
|
245
|
-
body: [
|
|
246
|
-
// PART 1: 国家币种
|
|
247
|
-
{
|
|
248
|
-
label: "Bank Location",
|
|
249
|
-
type: "input-text",
|
|
250
|
-
creatable: !1,
|
|
251
|
-
name: "inputRegionCode",
|
|
252
|
-
options: S,
|
|
253
|
-
value: t?.region_code
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
label: "Bank account type",
|
|
257
|
-
type: "radios",
|
|
258
|
-
name: "inputPayoutType",
|
|
259
|
-
selectFirst: !0,
|
|
260
|
-
options: [
|
|
261
|
-
{
|
|
262
|
-
label: "Individual",
|
|
263
|
-
value: "B2P"
|
|
264
|
-
}
|
|
265
|
-
],
|
|
266
|
-
value: t?.payout_type
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
label: "Account currency",
|
|
270
|
-
type: "input-text",
|
|
271
|
-
creatable: !1,
|
|
272
|
-
name: "inputCurrency",
|
|
273
|
-
options: T,
|
|
274
|
-
value: t?.currency
|
|
275
|
-
},
|
|
276
|
-
// PART 2: 银行账号(依赖1)
|
|
277
|
-
s
|
|
278
|
-
]
|
|
279
|
-
}
|
|
280
|
-
]
|
|
281
|
-
}
|
|
282
|
-
}),
|
|
283
|
-
[
|
|
284
|
-
b,
|
|
285
|
-
p.length,
|
|
286
|
-
S,
|
|
287
|
-
t?.region_code,
|
|
288
|
-
t?.payout_type,
|
|
289
|
-
t?.currency,
|
|
290
|
-
T,
|
|
291
|
-
s
|
|
292
|
-
]
|
|
293
|
-
);
|
|
294
|
-
return i.useEffect(() => {
|
|
295
|
-
async function c() {
|
|
296
|
-
const a = await M(o, n);
|
|
297
|
-
h(a);
|
|
298
|
-
}
|
|
299
|
-
c();
|
|
300
|
-
}, [o, n]), /* @__PURE__ */ _.jsxs(_.Fragment, { children: [
|
|
301
|
-
/* @__PURE__ */ _.jsx(j, {}),
|
|
302
|
-
v(R),
|
|
303
|
-
m && v(m)
|
|
304
|
-
] });
|
|
305
|
-
}
|
|
306
|
-
export {
|
|
307
|
-
$ as default
|
|
308
|
-
};
|