@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.
@@ -47,19 +47,19 @@ function S(t, n) {
47
47
  );
48
48
  m = setTimeout(async () => {
49
49
  try {
50
- const i = localStorage.getItem("refresh_token");
51
- if (!i)
50
+ const a = localStorage.getItem("refresh_token");
51
+ if (!a)
52
52
  return;
53
53
  const u = await N(
54
- i,
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 (i) {
62
- console.error("[payout-sdk] Auto refresh token failed:", i), m && (clearTimeout(m), m = null);
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: i, authCode: u, domain: p, codeVerifier: f } = o;
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
- ...i,
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, i) {
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: i?.payment_method
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, i, u) {
196
- if (!t || !n || !o || !r || !i || !u)
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: i,
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: i,
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
- i?.beneficiary?.entity_details?.type
233
+ a?.beneficiary?.entity_details?.type
234
234
  ),
235
- inputPaymentMethod: i?.payment_method,
236
- inputRegionCode: i?.beneficiary?.address?.country,
237
- inputCurrency: i?.receive_currency
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
- (a) => a.name === K
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
- (c) => c.country_number && !s.has(c.country_number) && s.add(c.country_number)
244
- ).map((c) => ({
245
- label: c.country_name_standard || c.country_name,
246
- value: c.country_code
247
- })).sort((c, g) => c.label.localeCompare(g.label));
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
- (a) => {
254
- k(a);
255
- const c = Object.keys(
256
- a.countries?.[s].payoutTypes?.[e.inputPayoutType]?.currencies
253
+ (c) => {
254
+ k(c);
255
+ const i = Object.keys(
256
+ c.countries?.[s].payoutTypes?.[e.inputPayoutType]?.currencies
257
257
  );
258
- c && c.length > 0 && L(
259
- c.map((g) => ({
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((a) => a.currency_code))
275
- ).map((a) => ({
276
- label: a,
277
- value: a
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
+ 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
- i
286
- ), [i, e, d, f]), E = y.useMemo(() => {
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 a = s.body.findIndex(
303
- (c) => c.type === "form"
302
+ const c = s.body.findIndex(
303
+ (i) => i.type === "form"
304
304
  );
305
- s.body[a].api.url = "/api/form", s.body[a].api.requestAdaptor = function(c, g) {
306
- return c?.body?.value && r.emit("submit", c.body.value), {
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 a = s.inputRegionCode, c = s.inputRegionCode ? s.inputCurrency : "", g = s.inputRegionCode ? s.inputPaymentMethod : "";
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: a,
349
- inputCurrency: c
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 a = await U(
408
+ const c = await U(
402
409
  t,
403
410
  n,
404
411
  o
405
412
  );
406
- _(a);
413
+ _(c);
407
414
  }
408
415
  s();
409
416
  }, [t, o, n]);
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ class d {
34
34
  }
35
35
  }
36
36
  const g = {
37
- beneficiaryForm: () => import("./component-beneficiary-form-Dw13hlCn.js")
37
+ beneficiaryForm: () => import("./component-beneficiary-form-Bm64IOv9.js")
38
38
  }, w = {
39
39
  staticData: {
40
40
  en: () => import("./en-Cb5xUNU4.js")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@txgw/payout-components",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"