@txgw/payout-components 0.4.1 → 0.4.2
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-Dw13hlCn.js → component-beneficiary-form-Bm64IOv9.js}
RENAMED
|
@@ -47,19 +47,19 @@ function S(t, n) {
|
|
|
47
47
|
);
|
|
48
48
|
m = setTimeout(async () => {
|
|
49
49
|
try {
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
50
|
+
const a = localStorage.getItem("refresh_token");
|
|
51
|
+
if (!a)
|
|
52
52
|
return;
|
|
53
53
|
const u = await N(
|
|
54
|
-
|
|
54
|
+
a,
|
|
55
55
|
n
|
|
56
56
|
);
|
|
57
57
|
u.access_token && u.refresh_token && (localStorage.setItem("access_token", u.access_token), localStorage.setItem(
|
|
58
58
|
"refresh_token",
|
|
59
59
|
u.refresh_token
|
|
60
60
|
), S(u.expires_in, n));
|
|
61
|
-
} catch (
|
|
62
|
-
console.error("[payout-sdk] Auto refresh token failed:",
|
|
61
|
+
} catch (a) {
|
|
62
|
+
console.error("[payout-sdk] Auto refresh token failed:", a), m && (clearTimeout(m), m = null);
|
|
63
63
|
}
|
|
64
64
|
}, r);
|
|
65
65
|
}
|
|
@@ -75,7 +75,7 @@ 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:
|
|
78
|
+
const { headers: a, authCode: u, domain: p, codeVerifier: f } = o;
|
|
79
79
|
if (!localStorage.getItem("access_token")) {
|
|
80
80
|
const e = await O(
|
|
81
81
|
u,
|
|
@@ -98,7 +98,7 @@ async function b(t, n, o, r = 1) {
|
|
|
98
98
|
access_token: localStorage.getItem("access_token")
|
|
99
99
|
}),
|
|
100
100
|
headers: {
|
|
101
|
-
...
|
|
101
|
+
...a,
|
|
102
102
|
"Content-Type": "application/json"
|
|
103
103
|
}
|
|
104
104
|
});
|
|
@@ -165,7 +165,7 @@ async function H(t, n, o, r) {
|
|
|
165
165
|
}
|
|
166
166
|
)).json();
|
|
167
167
|
}
|
|
168
|
-
function X({ inputPayoutType: t, inputCurrency: n }, o, r,
|
|
168
|
+
function X({ inputPayoutType: t, inputCurrency: n }, o, r, a) {
|
|
169
169
|
const u = [];
|
|
170
170
|
for (const p of Object.values(o.countries)) {
|
|
171
171
|
const f = p.payoutTypes?.[t]?.currencies;
|
|
@@ -185,15 +185,15 @@ function X({ inputPayoutType: t, inputCurrency: n }, o, r, i) {
|
|
|
185
185
|
/* @__PURE__ */ h.jsx("span", { className: "flex mt-1", children: p.description })
|
|
186
186
|
] })
|
|
187
187
|
})),
|
|
188
|
-
value:
|
|
188
|
+
value: a?.payment_method
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
async function Z({
|
|
192
192
|
inputRegionCode: t,
|
|
193
193
|
inputCurrency: n,
|
|
194
194
|
inputPaymentMethod: o
|
|
195
|
-
}, r,
|
|
196
|
-
if (!t || !n || !o || !r || !
|
|
195
|
+
}, r, a, u) {
|
|
196
|
+
if (!t || !n || !o || !r || !a || !u)
|
|
197
197
|
return;
|
|
198
198
|
const l = await (await b(
|
|
199
199
|
"/v1/payout/beneficiary/form/schema/token/query",
|
|
@@ -208,7 +208,7 @@ async function Z({
|
|
|
208
208
|
{
|
|
209
209
|
method: "POST",
|
|
210
210
|
authCode: r,
|
|
211
|
-
domain:
|
|
211
|
+
domain: a,
|
|
212
212
|
codeVerifier: u
|
|
213
213
|
}
|
|
214
214
|
)).json();
|
|
@@ -224,39 +224,39 @@ function V({
|
|
|
224
224
|
domain: n,
|
|
225
225
|
codeVerifier: o,
|
|
226
226
|
emitter: r,
|
|
227
|
-
defaultValues:
|
|
227
|
+
defaultValues: a,
|
|
228
228
|
customizations: u,
|
|
229
229
|
locale: p
|
|
230
230
|
}) {
|
|
231
231
|
const { t: f } = $("beneficiaryForm"), [l, _] = y.useState([]), [e, C] = y.useState({
|
|
232
232
|
inputPayoutType: G(
|
|
233
|
-
|
|
233
|
+
a?.beneficiary?.entity_details?.type
|
|
234
234
|
),
|
|
235
|
-
inputPaymentMethod:
|
|
236
|
-
inputRegionCode:
|
|
237
|
-
inputCurrency:
|
|
235
|
+
inputPaymentMethod: a?.payment_method,
|
|
236
|
+
inputRegionCode: a?.beneficiary?.address?.country,
|
|
237
|
+
inputCurrency: a?.receive_currency
|
|
238
238
|
}), [d, k] = y.useState(), [I, B] = y.useState(), w = y.useMemo(() => !u?.layout?.find(
|
|
239
|
-
(
|
|
239
|
+
(c) => c.name === K
|
|
240
240
|
)?.hidden, [u?.layout]), P = y.useMemo(() => {
|
|
241
241
|
const s = /* @__PURE__ */ new Set();
|
|
242
242
|
return l.filter(
|
|
243
|
-
(
|
|
244
|
-
).map((
|
|
245
|
-
label:
|
|
246
|
-
value:
|
|
247
|
-
})).sort((
|
|
243
|
+
(i) => i.country_number && !s.has(i.country_number) && s.add(i.country_number)
|
|
244
|
+
).map((i) => ({
|
|
245
|
+
label: i.country_name_standard || i.country_name,
|
|
246
|
+
value: i.country_code
|
|
247
|
+
})).sort((i, g) => i.label.localeCompare(g.label));
|
|
248
248
|
}, [l]), [v, L] = y.useState();
|
|
249
249
|
y.useEffect(() => {
|
|
250
250
|
if (!e?.inputRegionCode || !e?.inputPayoutType) return;
|
|
251
251
|
const s = e.inputRegionCode;
|
|
252
252
|
H(s, t, n, o).then(
|
|
253
|
-
(
|
|
254
|
-
k(
|
|
255
|
-
const
|
|
256
|
-
|
|
253
|
+
(c) => {
|
|
254
|
+
k(c);
|
|
255
|
+
const i = Object.keys(
|
|
256
|
+
c.countries?.[s].payoutTypes?.[e.inputPayoutType]?.currencies
|
|
257
257
|
);
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
i && i.length > 0 && L(
|
|
259
|
+
i.map((g) => ({
|
|
260
260
|
label: g,
|
|
261
261
|
value: g
|
|
262
262
|
}))
|
|
@@ -271,19 +271,19 @@ function V({
|
|
|
271
271
|
e?.inputRegionCode
|
|
272
272
|
]);
|
|
273
273
|
const x = y.useMemo(() => Array.from(
|
|
274
|
-
new Set(l.map((
|
|
275
|
-
).map((
|
|
276
|
-
label:
|
|
277
|
-
value:
|
|
278
|
-
})).filter((
|
|
274
|
+
new Set(l.map((c) => c.currency_code))
|
|
275
|
+
).map((c) => ({
|
|
276
|
+
label: c,
|
|
277
|
+
value: c
|
|
278
|
+
})).filter((c) => !!c.label && c.label !== "-").sort((c, i) => c.label.localeCompare(i.label)), [l]), T = y.useMemo(() => !e?.inputCurrency || !e?.inputPayoutType || !d ? void 0 : X(
|
|
279
279
|
{
|
|
280
280
|
inputPayoutType: e.inputPayoutType,
|
|
281
281
|
inputCurrency: e.inputCurrency
|
|
282
282
|
},
|
|
283
283
|
d,
|
|
284
284
|
f,
|
|
285
|
-
|
|
286
|
-
), [
|
|
285
|
+
a
|
|
286
|
+
), [a, e, d, f]), E = y.useMemo(() => {
|
|
287
287
|
if (!(l.length === 0 || !T || !e?.inputPaymentMethod || !e?.inputRegionCode || !e?.inputCurrency))
|
|
288
288
|
return I;
|
|
289
289
|
}, [l, e, I, T]);
|
|
@@ -299,11 +299,18 @@ function V({
|
|
|
299
299
|
o
|
|
300
300
|
).then((s) => {
|
|
301
301
|
if (!s) return;
|
|
302
|
-
const
|
|
303
|
-
(
|
|
302
|
+
const c = s.body.findIndex(
|
|
303
|
+
(i) => i.type === "form"
|
|
304
304
|
);
|
|
305
|
-
s.body[
|
|
306
|
-
return
|
|
305
|
+
s.body[c].api.url = "/api/form", s.body[c].api.requestAdaptor = function(i, g) {
|
|
306
|
+
return i?.body?.value && r.emit(
|
|
307
|
+
"submit",
|
|
308
|
+
Object.assign(
|
|
309
|
+
{},
|
|
310
|
+
i.body.value,
|
|
311
|
+
a
|
|
312
|
+
)
|
|
313
|
+
), {
|
|
307
314
|
mockResponse: {
|
|
308
315
|
status: 200,
|
|
309
316
|
data: {
|
|
@@ -341,12 +348,12 @@ function V({
|
|
|
341
348
|
title: f("title", "Bank Details"),
|
|
342
349
|
submitText: "",
|
|
343
350
|
onChange: (s) => {
|
|
344
|
-
const
|
|
351
|
+
const c = s.inputRegionCode, i = s.inputRegionCode ? s.inputCurrency : "", g = s.inputRegionCode ? s.inputPaymentMethod : "";
|
|
345
352
|
C({
|
|
346
353
|
inputPayoutType: s.inputPayoutType,
|
|
347
354
|
inputPaymentMethod: g,
|
|
348
|
-
inputRegionCode:
|
|
349
|
-
inputCurrency:
|
|
355
|
+
inputRegionCode: c,
|
|
356
|
+
inputCurrency: i
|
|
350
357
|
});
|
|
351
358
|
},
|
|
352
359
|
body: [
|
|
@@ -398,12 +405,12 @@ function V({
|
|
|
398
405
|
);
|
|
399
406
|
y.useEffect(() => {
|
|
400
407
|
async function s() {
|
|
401
|
-
const
|
|
408
|
+
const c = await U(
|
|
402
409
|
t,
|
|
403
410
|
n,
|
|
404
411
|
o
|
|
405
412
|
);
|
|
406
|
-
_(
|
|
413
|
+
_(c);
|
|
407
414
|
}
|
|
408
415
|
s();
|
|
409
416
|
}, [t, o, n]);
|
package/dist/index.js
CHANGED