@txgw/payout-components 0.3.2 → 0.4.1
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/dist/{component-beneficiary-form-iyOi2OA3.js → component-beneficiary-form-Dw13hlCn.js}
RENAMED
|
@@ -75,12 +75,12 @@ function R(t, n) {
|
|
|
75
75
|
async function b(t, n, o, r = 1) {
|
|
76
76
|
if (r < 0)
|
|
77
77
|
throw new Error("[payout-sdk] fetchWithAuth retries exceeded");
|
|
78
|
-
const { headers: i, authCode: u, domain: p, codeVerifier:
|
|
78
|
+
const { headers: i, authCode: u, domain: p, codeVerifier: f } = o;
|
|
79
79
|
if (!localStorage.getItem("access_token")) {
|
|
80
80
|
const e = await O(
|
|
81
81
|
u,
|
|
82
82
|
p,
|
|
83
|
-
|
|
83
|
+
f
|
|
84
84
|
);
|
|
85
85
|
if (!e.access_token || !e.refresh_token)
|
|
86
86
|
throw j(), new Error(
|
|
@@ -123,7 +123,7 @@ async function b(t, n, o, r = 1) {
|
|
|
123
123
|
const d = await O(
|
|
124
124
|
u,
|
|
125
125
|
p,
|
|
126
|
-
|
|
126
|
+
f
|
|
127
127
|
);
|
|
128
128
|
if (!d.access_token || !d.refresh_token)
|
|
129
129
|
throw new Error(
|
|
@@ -168,10 +168,10 @@ async function H(t, n, o, r) {
|
|
|
168
168
|
function X({ inputPayoutType: t, inputCurrency: n }, o, r, i) {
|
|
169
169
|
const u = [];
|
|
170
170
|
for (const p of Object.values(o.countries)) {
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
for (const [
|
|
174
|
-
|
|
171
|
+
const f = p.payoutTypes?.[t]?.currencies;
|
|
172
|
+
if (f)
|
|
173
|
+
for (const [l, _] of Object.entries(f))
|
|
174
|
+
l === n && u.push(_);
|
|
175
175
|
}
|
|
176
176
|
if (u.length !== 0)
|
|
177
177
|
return {
|
|
@@ -195,7 +195,7 @@ async function Z({
|
|
|
195
195
|
}, r, i, u) {
|
|
196
196
|
if (!t || !n || !o || !r || !i || !u)
|
|
197
197
|
return;
|
|
198
|
-
const
|
|
198
|
+
const l = await (await b(
|
|
199
199
|
"/v1/payout/beneficiary/form/schema/token/query",
|
|
200
200
|
{
|
|
201
201
|
payment_method: o,
|
|
@@ -213,10 +213,13 @@ async function Z({
|
|
|
213
213
|
}
|
|
214
214
|
)).json();
|
|
215
215
|
return JSON.parse(
|
|
216
|
-
|
|
216
|
+
l.beneficiary_schema.amis_page.replace(/Area Code/g, "AREA_CODE")
|
|
217
217
|
);
|
|
218
218
|
}
|
|
219
|
-
function G({
|
|
219
|
+
function G(t) {
|
|
220
|
+
return "B2P";
|
|
221
|
+
}
|
|
222
|
+
function V({
|
|
220
223
|
authCode: t,
|
|
221
224
|
domain: n,
|
|
222
225
|
codeVerifier: o,
|
|
@@ -225,22 +228,24 @@ function G({
|
|
|
225
228
|
customizations: u,
|
|
226
229
|
locale: p
|
|
227
230
|
}) {
|
|
228
|
-
const { t:
|
|
229
|
-
inputPayoutType:
|
|
231
|
+
const { t: f } = $("beneficiaryForm"), [l, _] = y.useState([]), [e, C] = y.useState({
|
|
232
|
+
inputPayoutType: G(
|
|
233
|
+
i?.beneficiary?.entity_details?.type
|
|
234
|
+
),
|
|
230
235
|
inputPaymentMethod: i?.payment_method,
|
|
231
|
-
inputRegionCode: i?.
|
|
232
|
-
inputCurrency: i?.
|
|
236
|
+
inputRegionCode: i?.beneficiary?.address?.country,
|
|
237
|
+
inputCurrency: i?.receive_currency
|
|
233
238
|
}), [d, k] = y.useState(), [I, B] = y.useState(), w = y.useMemo(() => !u?.layout?.find(
|
|
234
239
|
(a) => a.name === K
|
|
235
240
|
)?.hidden, [u?.layout]), P = y.useMemo(() => {
|
|
236
241
|
const s = /* @__PURE__ */ new Set();
|
|
237
|
-
return
|
|
242
|
+
return l.filter(
|
|
238
243
|
(c) => c.country_number && !s.has(c.country_number) && s.add(c.country_number)
|
|
239
244
|
).map((c) => ({
|
|
240
245
|
label: c.country_name_standard || c.country_name,
|
|
241
246
|
value: c.country_code
|
|
242
247
|
})).sort((c, g) => c.label.localeCompare(g.label));
|
|
243
|
-
}, [
|
|
248
|
+
}, [l]), [v, L] = y.useState();
|
|
244
249
|
y.useEffect(() => {
|
|
245
250
|
if (!e?.inputRegionCode || !e?.inputPayoutType) return;
|
|
246
251
|
const s = e.inputRegionCode;
|
|
@@ -266,22 +271,22 @@ function G({
|
|
|
266
271
|
e?.inputRegionCode
|
|
267
272
|
]);
|
|
268
273
|
const x = y.useMemo(() => Array.from(
|
|
269
|
-
new Set(
|
|
274
|
+
new Set(l.map((a) => a.currency_code))
|
|
270
275
|
).map((a) => ({
|
|
271
276
|
label: a,
|
|
272
277
|
value: a
|
|
273
|
-
})).filter((a) => !!a.label && a.label !== "-").sort((a, c) => a.label.localeCompare(c.label)), [
|
|
278
|
+
})).filter((a) => !!a.label && a.label !== "-").sort((a, c) => a.label.localeCompare(c.label)), [l]), T = y.useMemo(() => !e?.inputCurrency || !e?.inputPayoutType || !d ? void 0 : X(
|
|
274
279
|
{
|
|
275
280
|
inputPayoutType: e.inputPayoutType,
|
|
276
281
|
inputCurrency: e.inputCurrency
|
|
277
282
|
},
|
|
278
283
|
d,
|
|
279
|
-
|
|
284
|
+
f,
|
|
280
285
|
i
|
|
281
|
-
), [i, e, d,
|
|
282
|
-
if (!(
|
|
286
|
+
), [i, e, d, f]), E = y.useMemo(() => {
|
|
287
|
+
if (!(l.length === 0 || !T || !e?.inputPaymentMethod || !e?.inputRegionCode || !e?.inputCurrency))
|
|
283
288
|
return I;
|
|
284
|
-
}, [
|
|
289
|
+
}, [l, e, I, T]);
|
|
285
290
|
y.useEffect(() => {
|
|
286
291
|
Z(
|
|
287
292
|
{
|
|
@@ -312,7 +317,7 @@ function G({
|
|
|
312
317
|
}, B(s);
|
|
313
318
|
});
|
|
314
319
|
}, [
|
|
315
|
-
|
|
320
|
+
l,
|
|
316
321
|
T,
|
|
317
322
|
t,
|
|
318
323
|
n,
|
|
@@ -328,12 +333,12 @@ function G({
|
|
|
328
333
|
visible: w,
|
|
329
334
|
body: {
|
|
330
335
|
type: "spinner",
|
|
331
|
-
show:
|
|
336
|
+
show: l.length === 0,
|
|
332
337
|
overlay: !0,
|
|
333
338
|
body: [
|
|
334
339
|
{
|
|
335
340
|
type: "form",
|
|
336
|
-
title:
|
|
341
|
+
title: f("title", "Bank Details"),
|
|
337
342
|
submitText: "",
|
|
338
343
|
onChange: (s) => {
|
|
339
344
|
const a = s.inputRegionCode, c = s.inputRegionCode ? s.inputCurrency : "", g = s.inputRegionCode ? s.inputPaymentMethod : "";
|
|
@@ -346,7 +351,7 @@ function G({
|
|
|
346
351
|
},
|
|
347
352
|
body: [
|
|
348
353
|
{
|
|
349
|
-
label:
|
|
354
|
+
label: f("regionInputLabel", "Bank Location"),
|
|
350
355
|
type: "input-text",
|
|
351
356
|
creatable: !1,
|
|
352
357
|
name: "inputRegionCode",
|
|
@@ -354,7 +359,7 @@ function G({
|
|
|
354
359
|
value: e?.inputRegionCode
|
|
355
360
|
},
|
|
356
361
|
{
|
|
357
|
-
label:
|
|
362
|
+
label: f("payoutTypeInputLabel", "Bank account type"),
|
|
358
363
|
type: "radios",
|
|
359
364
|
name: "inputPayoutType",
|
|
360
365
|
selectFirst: !0,
|
|
@@ -367,7 +372,7 @@ function G({
|
|
|
367
372
|
value: e?.inputPayoutType
|
|
368
373
|
},
|
|
369
374
|
{
|
|
370
|
-
label:
|
|
375
|
+
label: f("currencyInputLabel", "Account currency"),
|
|
371
376
|
type: "input-text",
|
|
372
377
|
creatable: !1,
|
|
373
378
|
name: "inputCurrency",
|
|
@@ -381,13 +386,13 @@ function G({
|
|
|
381
386
|
}
|
|
382
387
|
}),
|
|
383
388
|
[
|
|
384
|
-
|
|
389
|
+
l.length,
|
|
385
390
|
e,
|
|
386
391
|
x,
|
|
387
392
|
v,
|
|
388
393
|
P,
|
|
389
394
|
w,
|
|
390
|
-
|
|
395
|
+
f,
|
|
391
396
|
T
|
|
392
397
|
]
|
|
393
398
|
);
|
|
@@ -430,10 +435,10 @@ function G({
|
|
|
430
435
|
)
|
|
431
436
|
] });
|
|
432
437
|
}
|
|
433
|
-
function
|
|
438
|
+
function ne(t) {
|
|
434
439
|
const { mi18n: n } = t;
|
|
435
|
-
return /* @__PURE__ */ h.jsx(q, { mi18n: n, fallback: "Loading...", children: /* @__PURE__ */ h.jsx(
|
|
440
|
+
return /* @__PURE__ */ h.jsx(q, { mi18n: n, fallback: "Loading...", children: /* @__PURE__ */ h.jsx(V, { ...t }) });
|
|
436
441
|
}
|
|
437
442
|
export {
|
|
438
|
-
|
|
443
|
+
ne as default
|
|
439
444
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -20,14 +20,37 @@ declare interface BeneficiaryFormCustomizations {
|
|
|
20
20
|
layout?: LayoutSection[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
declare
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
declare type BeneficiaryFormFinalValues = {
|
|
24
|
+
beneficiary: {
|
|
25
|
+
address?: {
|
|
26
|
+
country?: string;
|
|
27
|
+
street_address?: string;
|
|
28
|
+
};
|
|
29
|
+
bank_account?: {
|
|
30
|
+
account_number?: string;
|
|
31
|
+
account_routing_type1?: string;
|
|
32
|
+
account_routing_value1?: string;
|
|
33
|
+
bank_country_code: string;
|
|
34
|
+
bank_name?: string;
|
|
35
|
+
swift_code?: string;
|
|
36
|
+
};
|
|
37
|
+
wallet_account?: {
|
|
38
|
+
account_id?: string;
|
|
39
|
+
sub_account_id?: string;
|
|
40
|
+
wallet_type?: string;
|
|
41
|
+
country_code?: string;
|
|
42
|
+
account_routing_type1?: string;
|
|
43
|
+
account_routing_value1?: string;
|
|
44
|
+
};
|
|
45
|
+
entity_details?: {
|
|
46
|
+
mobile_number?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
type?: EntityDetailType;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
27
51
|
payment_method?: string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
declare type BeneficiaryFormFinalValues = Record<string, unknown>;
|
|
52
|
+
receive_currency?: string;
|
|
53
|
+
};
|
|
31
54
|
|
|
32
55
|
declare type BeneficiaryFormOptions<T extends keyof typeof ElementsMap> = Omit<BeneficiaryFormProps, keyof BaseProps<T>>;
|
|
33
56
|
|
|
@@ -49,6 +72,8 @@ declare const ElementsMap: {
|
|
|
49
72
|
beneficiaryForm: () => Promise<componentsBeneficiaryForm>;
|
|
50
73
|
};
|
|
51
74
|
|
|
75
|
+
declare type EntityDetailType = "ENTITY_TYPE_PERSONAL";
|
|
76
|
+
|
|
52
77
|
declare type Events<T extends keyof typeof ElementsMap> = ElementEventsMap[T];
|
|
53
78
|
|
|
54
79
|
declare type EventsData<T extends keyof typeof ElementsMap> = Events<T>[keyof Events<T>];
|
|
@@ -70,10 +95,8 @@ declare interface LayoutSection {
|
|
|
70
95
|
|
|
71
96
|
declare type Locale = "en";
|
|
72
97
|
|
|
73
|
-
declare type PayoutType = "B2P";
|
|
74
|
-
|
|
75
98
|
declare interface Props extends BaseProps<"beneficiaryForm"> {
|
|
76
|
-
defaultValues?:
|
|
99
|
+
defaultValues?: Partial<BeneficiaryFormFinalValues>;
|
|
77
100
|
customizations?: BeneficiaryFormCustomizations;
|
|
78
101
|
}
|
|
79
102
|
|
package/dist/index.js
CHANGED