@cedros/pay-react 1.1.28 → 1.1.30
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 +8 -0
- package/dist/{AISettingsSection-BlIv3CzS.mjs → AISettingsSection-BMh3hAb5.mjs} +6 -4
- package/dist/{AISettingsSection-DELur7D2.js → AISettingsSection-C0zqPbd6.js} +2 -2
- package/dist/{AutosaveIndicator-Bed0-ekg.mjs → AutosaveIndicator-3ctAnz8Y.mjs} +1 -1
- package/dist/{AutosaveIndicator-Dn_qA2hK.js → AutosaveIndicator-DXRPr4P7.js} +1 -1
- package/dist/CedrosContext-5Gjveoba.mjs +2555 -0
- package/dist/CedrosContext-CCakH2SZ.js +3 -0
- package/dist/CedrosPayAdminDashboard-DaJ9JoGn.mjs +250 -0
- package/dist/CedrosPayAdminDashboard-Uvyh9p7A.js +1 -0
- package/dist/{ChatLogsSection-v4zwzCTC.mjs → ChatLogsSection-BtJixYAp.mjs} +19 -17
- package/dist/ChatLogsSection-FC3O536G.js +1 -0
- package/dist/{ComplianceSection-CemgfDrL.mjs → ComplianceSection-BMnb1p4w.mjs} +18 -15
- package/dist/ComplianceSection-BioTKm7k.js +1 -0
- package/dist/{CryptoButton-BV9owVe2.mjs → CryptoButton-Cl2kZbOP.mjs} +26 -24
- package/dist/CryptoButton-DxFCYDlJ.js +1 -0
- package/dist/{CustomersSection-D_j7OrfS.mjs → CustomersSection-dmwoBhcf.mjs} +21 -19
- package/dist/CustomersSection-z6ARxuex.js +1 -0
- package/dist/DisputesSection-BjHHQAi7.js +1 -0
- package/dist/{DisputesSection-BcAbXp3K.mjs → DisputesSection-CHyLne76.mjs} +19 -17
- package/dist/Dropdown-BRSZlhik.mjs +111 -0
- package/dist/Dropdown-j8o0OO5L.js +1 -0
- package/dist/ErrorBanner-CAgPnj62.js +1 -0
- package/dist/ErrorBanner-lZJhCmDX.mjs +22 -0
- package/dist/{FAQSection-Dn38OhB_.mjs → FAQSection-Di2xE9Sm.mjs} +8 -6
- package/dist/FAQSection-b34DMzgV.js +1 -0
- package/dist/{ImagesSection-Ctw9Icym.mjs → ImagesSection-D63PEjR6.mjs} +6 -4
- package/dist/ImagesSection-DGBA7iKY.js +1 -0
- package/dist/{InventorySection-DmhjUlRZ.mjs → InventorySection-Dp5Yu4TA.mjs} +25 -23
- package/dist/InventorySection-bVCECzX5.js +1 -0
- package/dist/LazyCedrosPayAdminDashboard-BqJDNrDI.mjs +9 -0
- package/dist/LazyCedrosPayAdminDashboard-CpfTtOBc.js +1 -0
- package/dist/{MessagingSection-B1FaGxkp.mjs → MessagingSection-BLCnCpEv.mjs} +5 -4
- package/dist/MessagingSection-DU0dYNMy.js +1 -0
- package/dist/{OrdersSection-Bj8bPdg8.mjs → OrdersSection-Bd56F3cj.mjs} +27 -24
- package/dist/OrdersSection-FOFEAgs1.js +1 -0
- package/dist/PaymentSettingsSection-52iw47Su.mjs +648 -0
- package/dist/PaymentSettingsSection-B5J56VAk.js +1 -0
- package/dist/ReturnsSection-BjpIVFfN.js +1 -0
- package/dist/{ReturnsSection-BC0L8r2e.mjs → ReturnsSection-DUVeKrCd.mjs} +11 -9
- package/dist/{SettingsSection-vdYFSNxB.js → SettingsSection-DKkHykaC.js} +1 -1
- package/dist/{SettingsSection-KYdEizq_.mjs → SettingsSection-vK9WIwXE.mjs} +1 -1
- package/dist/ShippingSection-B5lk7zpS.js +1 -0
- package/dist/{ShippingSection-BOgto6_9.mjs → ShippingSection-CZRrXrlh.mjs} +5 -3
- package/dist/{SingleCategorySettings-suJ8z9d8.mjs → SingleCategorySettings-C8xJ47_T.mjs} +143 -140
- package/dist/SingleCategorySettings-g7D-9lG1.js +3 -0
- package/dist/StatsBar-CWXw2ZT3.js +1 -0
- package/dist/StatsBar-D4cOKG2e.mjs +25 -0
- package/dist/StorefrontSection-BWnMB9k-.js +1 -0
- package/dist/{StorefrontSection-BRvIGBEJ.mjs → StorefrontSection-uXSVbEAa.mjs} +121 -119
- package/dist/{SubscriptionsSection-D60qrX9a.mjs → SubscriptionsSection-Ci_AZrWA.mjs} +11 -9
- package/dist/SubscriptionsSection-DQfXkuDv.js +1 -0
- package/dist/{TaxSection-C7-pv-Rl.mjs → TaxSection-BTukS_cU.mjs} +23 -21
- package/dist/TaxSection-cuPQISxZ.js +1 -0
- package/dist/ThemeContext-CFXyYx7A.js +1 -0
- package/dist/ThemeContext-l0bqcOGW.mjs +126 -0
- package/dist/Token22Section-CCfkDm8W.js +1 -0
- package/dist/{Token22Section-CrHLQ0EB.mjs → Token22Section-DRsPJuTq.mjs} +7 -6
- package/dist/{WalletManager-BIwH8Dw_.mjs → WalletManager-D-eoqUDy.mjs} +21 -19
- package/dist/WalletManager-DXChB9LA.js +1 -0
- package/dist/{WebhooksSection-COPW4Ec0.mjs → WebhooksSection-A8Y4ZGcj.mjs} +40 -38
- package/dist/WebhooksSection-CnEmaGH1.js +1 -0
- package/dist/admin.d.ts +2 -0
- package/dist/admin.js +1 -0
- package/dist/admin.mjs +7 -0
- package/dist/configApi-BS5UJfzm.js +1 -0
- package/dist/{configApi-6XhAJGKX.mjs → configApi-BUXZOMWK.mjs} +57 -3
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +215 -202
- package/dist/dateHelpers-BKW_lGND.js +1 -0
- package/dist/dateHelpers-yvPkofYQ.mjs +6 -0
- package/dist/fetchWithTimeout-CG0EKbhf.js +1 -0
- package/dist/fetchWithTimeout-DmMOwL0Q.mjs +195 -0
- package/dist/icons-C3yDMnKE.mjs +235 -0
- package/dist/icons-Cjgd9YVo.js +1 -0
- package/dist/index-9QF_UfSN.mjs +18668 -0
- package/dist/index-Cq9ya93W.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +74 -63
- package/dist/safeHref-DqJPLPl5.mjs +12 -0
- package/dist/safeHref-DyHIpVjY.js +1 -0
- package/dist/sectionIds-D46-_-h-.js +1 -0
- package/dist/sectionIds-YktNxmRt.mjs +124 -0
- package/dist/sections-511_XBh4.js +1 -0
- package/dist/sections-CRaMa8ZB.mjs +9 -0
- package/dist/sections-more-Cgw2qJlA.js +1 -0
- package/dist/sections-more-Ixw6mM6R.mjs +3082 -0
- package/dist/src/admin/index.d.ts +3 -3
- package/dist/src/admin/index.d.ts.map +1 -1
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/admin/types.d.ts +2 -6
- package/dist/src/admin/types.d.ts.map +1 -1
- package/dist/src/admin.d.ts +9 -0
- package/dist/src/admin.d.ts.map +1 -0
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +4 -0
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +1 -0
- package/dist/src/components/admin/PaymentReadinessChecklist.d.ts +9 -0
- package/dist/src/components/admin/PaymentReadinessChecklist.d.ts.map +1 -0
- package/dist/src/components/admin/PaymentSettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/PaymentSetupGuide.d.ts +6 -0
- package/dist/src/components/admin/PaymentSetupGuide.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/configApi.d.ts +1 -1
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +3 -50
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/index.d.ts +1 -1
- package/dist/src/components/admin/index.d.ts.map +1 -1
- package/dist/src/components/admin/types.d.ts +43 -0
- package/dist/src/components/admin/types.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts +2 -0
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts +2 -0
- package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts.map +1 -0
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/general/ErrorBoundary.d.ts +1 -1
- package/dist/src/ecommerce/components/ui/button.d.ts +1 -1
- package/dist/src/ecommerce/components/ui/sheet.d.ts +1 -1
- package/dist/src/ecommerce/config/context.d.ts +2 -0
- package/dist/src/ecommerce/config/context.d.ts.map +1 -1
- package/dist/src/ecommerce/config/types.d.ts +2 -0
- package/dist/src/ecommerce/config/types.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +2 -0
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/featureFlags.d.ts +41 -0
- package/dist/src/featureFlags.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts +1 -0
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/standalone-admin.d.ts +8 -0
- package/dist/src/standalone-admin.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +14 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +47 -1
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/validateConfig.d.ts.map +1 -1
- package/dist/standalone-admin.d.ts +2 -0
- package/dist/standalone-admin.js +1 -0
- package/dist/standalone-admin.mjs +4 -0
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +35 -33
- package/dist/styles--fxb3lCl.js +1 -0
- package/dist/{styles-D4SQkuV3.mjs → styles-DGagylUj.mjs} +53 -51
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/tokenMintValidator-DAjQld0r.mjs +98 -0
- package/dist/tokenMintValidator-DNBhoefh.js +4 -0
- package/dist/{walletPool-DE-t1wSW.mjs → walletPool-9MylB2QK.mjs} +1 -1
- package/dist/walletPool-BjTXX6Vn.js +1 -0
- package/package.json +9 -3
- package/dist/CedrosContext-C2RjHLaQ.js +0 -6
- package/dist/CedrosContext-CY6zvjvJ.mjs +0 -2801
- package/dist/ChatLogsSection-BH5tLA4T.js +0 -1
- package/dist/ComplianceSection-DP2a9-S0.js +0 -1
- package/dist/CryptoButton-DpiCnyXE.js +0 -1
- package/dist/CustomersSection-CBwy_waO.js +0 -1
- package/dist/DisputesSection-BLjIk60n.js +0 -1
- package/dist/FAQSection-wNeH0i6Q.js +0 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +0 -1
- package/dist/InventorySection-zV6lTmue.js +0 -1
- package/dist/MessagingSection-B_wdFR0j.js +0 -1
- package/dist/OrdersSection-Dw2FX-1d.js +0 -1
- package/dist/PaymentSettingsSection-BYF4D-GR.js +0 -1
- package/dist/PaymentSettingsSection-EnMxeWjv.mjs +0 -94
- package/dist/ReturnsSection-D_pJVxuG.js +0 -1
- package/dist/ShippingSection-1DRSTu49.js +0 -1
- package/dist/SingleCategorySettings-DwCnBdRf.js +0 -3
- package/dist/StorefrontSection-RumGkb3C.js +0 -1
- package/dist/SubscriptionsSection-C2aLLn7L.js +0 -1
- package/dist/TaxSection-Dt1DnM51.js +0 -1
- package/dist/Token22Section-DY3mUwTY.js +0 -1
- package/dist/WalletManager-B3UdQ5pQ.js +0 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +0 -1
- package/dist/configApi-DkduMQg1.js +0 -1
- package/dist/index-C0g-JxJk.js +0 -84
- package/dist/index-DXnuQp5x.mjs +0 -22128
- package/dist/sections-C1NpK7hk.mjs +0 -9
- package/dist/sections-DVVSZBhW.js +0 -1
- package/dist/styles-BT4bhFey.js +0 -1
- package/dist/walletPool-IS7R3MR1.js +0 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { jsxs as n, jsx as e, Fragment as
|
|
1
|
+
import { jsxs as n, jsx as e, Fragment as j } from "react/jsx-runtime";
|
|
2
2
|
import { useState as i, useCallback as L, useEffect as U } from "react";
|
|
3
|
-
import { I as
|
|
4
|
-
import {
|
|
3
|
+
import { I as $ } from "./icons-C3yDMnKE.mjs";
|
|
4
|
+
import { E as me } from "./ErrorBanner-lZJhCmDX.mjs";
|
|
5
|
+
import { S as Z } from "./StatsBar-D4cOKG2e.mjs";
|
|
6
|
+
import { g as v } from "./fetchWithTimeout-DmMOwL0Q.mjs";
|
|
7
|
+
import { f as E } from "./dateHelpers-yvPkofYQ.mjs";
|
|
5
8
|
const b = (s) => s.length > 12 ? `${s.slice(0, 6)}...${s.slice(-4)}` : s, he = (s) => {
|
|
6
9
|
switch (s) {
|
|
7
10
|
case "active":
|
|
@@ -257,7 +260,7 @@ function _e({ serverUrl: s, apiKey: h, authManager: u }) {
|
|
|
257
260
|
A && !r && !S && !p && /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No compliance record found for this user." })
|
|
258
261
|
] });
|
|
259
262
|
}
|
|
260
|
-
function
|
|
263
|
+
function Ce({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
261
264
|
const [l, S] = i("holders"), [k, p] = i(null), [g, r] = i([]), [C, A] = i(!0), [_, T] = i(""), [y, w] = i([]), [z, d] = i(!0), [a, m] = i(null), [N, F] = i(!1), [H, te] = i(""), [Y, ne] = i(""), [K, J] = i({ enabled: !0, batchSize: 100 }), [ae, ie] = i(!0), [G, V] = i(!1), [f, I] = i(null), [P, W] = i(""), [D, X] = i(!1), x = L(async (t, o) => {
|
|
262
265
|
if (c?.isAuthenticated())
|
|
263
266
|
return c.fetchWithAuth(t, o);
|
|
@@ -266,7 +269,7 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
266
269
|
const q = await fetch(`${s}${t}`, { ...o, headers: { ...R, ...o?.headers } });
|
|
267
270
|
if (!q.ok) throw new Error(`Request failed: ${q.status}`);
|
|
268
271
|
return q.json();
|
|
269
|
-
}, [s, h, c]),
|
|
272
|
+
}, [s, h, c]), B = L(async () => {
|
|
270
273
|
try {
|
|
271
274
|
const t = _ ? `&status=${_}` : "", o = await x(
|
|
272
275
|
`/admin/compliance/holders?limit=${u}&offset=0${t}`
|
|
@@ -277,7 +280,7 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
277
280
|
} finally {
|
|
278
281
|
A(!1);
|
|
279
282
|
}
|
|
280
|
-
}, [x, u, _]),
|
|
283
|
+
}, [x, u, _]), O = L(async () => {
|
|
281
284
|
try {
|
|
282
285
|
const t = await x(
|
|
283
286
|
`/admin/compliance/actions?limit=${u}&offset=0`
|
|
@@ -311,10 +314,10 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
311
314
|
}
|
|
312
315
|
};
|
|
313
316
|
U(() => {
|
|
314
|
-
j();
|
|
315
|
-
}, [j]), U(() => {
|
|
316
317
|
B();
|
|
317
318
|
}, [B]), U(() => {
|
|
319
|
+
O();
|
|
320
|
+
}, [O]), U(() => {
|
|
318
321
|
M();
|
|
319
322
|
}, [M]);
|
|
320
323
|
const re = async () => {
|
|
@@ -325,7 +328,7 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
325
328
|
await x(t, {
|
|
326
329
|
method: "POST",
|
|
327
330
|
body: JSON.stringify({ holderId: f.holder.id, reason: P })
|
|
328
|
-
}), I(null), W(""), await
|
|
331
|
+
}), I(null), W(""), await B(), await O();
|
|
329
332
|
} catch (t) {
|
|
330
333
|
v().error(`[ComplianceSection] ${f.action} failed:`, t), p(`Failed to ${f.action} holder`);
|
|
331
334
|
} finally {
|
|
@@ -353,7 +356,7 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
353
356
|
}, oe = g.length, Q = g.filter((t) => t.status === "frozen").length, le = g.filter((t) => t.status === "active").length;
|
|
354
357
|
return /* @__PURE__ */ n("div", { className: "cedros-admin__page", children: [
|
|
355
358
|
/* @__PURE__ */ e(me, { message: k, onRetry: () => {
|
|
356
|
-
|
|
359
|
+
B(), O();
|
|
357
360
|
} }),
|
|
358
361
|
/* @__PURE__ */ e(
|
|
359
362
|
Z,
|
|
@@ -377,7 +380,7 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
377
380
|
},
|
|
378
381
|
t
|
|
379
382
|
)) }),
|
|
380
|
-
l === "holders" && /* @__PURE__ */ n(
|
|
383
|
+
l === "holders" && /* @__PURE__ */ n(j, { children: [
|
|
381
384
|
/* @__PURE__ */ n("div", { className: "cedros-admin__section-header", style: { display: "flex", alignItems: "center", gap: "0.75rem" }, children: [
|
|
382
385
|
/* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Token Holders" }),
|
|
383
386
|
/* @__PURE__ */ n(
|
|
@@ -440,7 +443,7 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
440
443
|
] }, t.id)) })
|
|
441
444
|
] }) })
|
|
442
445
|
] }),
|
|
443
|
-
l === "actions" && /* @__PURE__ */ n(
|
|
446
|
+
l === "actions" && /* @__PURE__ */ n(j, { children: [
|
|
444
447
|
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Compliance Actions" }) }),
|
|
445
448
|
z ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
446
449
|
$.loading,
|
|
@@ -473,7 +476,7 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
473
476
|
] }, t.id)) })
|
|
474
477
|
] }) })
|
|
475
478
|
] }),
|
|
476
|
-
l === "reports" && /* @__PURE__ */ n(
|
|
479
|
+
l === "reports" && /* @__PURE__ */ n(j, { children: [
|
|
477
480
|
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Compliance Report" }) }),
|
|
478
481
|
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.75rem", alignItems: "flex-end", marginBottom: "1rem" }, children: [
|
|
479
482
|
/* @__PURE__ */ n("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", fontSize: "0.85rem" }, children: [
|
|
@@ -536,7 +539,7 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
536
539
|
] }) })
|
|
537
540
|
] })
|
|
538
541
|
] }),
|
|
539
|
-
l === "sweep-settings" && /* @__PURE__ */ n(
|
|
542
|
+
l === "sweep-settings" && /* @__PURE__ */ n(j, { children: [
|
|
540
543
|
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Sanctions Sweep Settings" }) }),
|
|
541
544
|
ae ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
542
545
|
$.loading,
|
|
@@ -646,5 +649,5 @@ function we({ serverUrl: s, apiKey: h, pageSize: u = 50, authManager: c }) {
|
|
|
646
649
|
] });
|
|
647
650
|
}
|
|
648
651
|
export {
|
|
649
|
-
|
|
652
|
+
Ce as ComplianceSection
|
|
650
653
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),I=require("./icons-Cjgd9YVo.js"),ce=require("./ErrorBanner-CAgPnj62.js"),V=require("./StatsBar-CWXw2ZT3.js"),_=require("./fetchWithTimeout-CG0EKbhf.js"),R=require("./dateHelpers-BKW_lGND.js"),j=a=>a.length>12?`${a.slice(0,6)}...${a.slice(-4)}`:a,de=a=>{switch(a){case"active":return"success";case"frozen":return"failed";case"thawed":return"pending";default:return"muted"}},X=a=>{switch(a){case"freeze":return"failed";case"thaw":return"success";case"sweep_freeze":return"failed";case"report_generated":return"muted";default:return"muted"}},oe=a=>{switch(a){case"verified":return"success";case"pending":return"pending";case"expired":return"failed";case"none":default:return"muted"}},le="https://explorer.solana.com/tx/",me={apiUrl:"",refreshIntervalSecs:3600,enabled:!1};function he({serverUrl:a,apiKey:m,authManager:h}){const[r,o]=n.useState(me),[y,C]=n.useState(!0),[u,g]=n.useState(!1),[i,w]=n.useState(!1),[N,p]=n.useState(null),[A,f]=n.useState(null),b=n.useCallback(async(s,l)=>{if(h?.isAuthenticated())return h.fetchWithAuth(s,l);const S={"Content-Type":"application/json"};m&&(S["X-API-Key"]=m);const T=await fetch(`${a}${s}`,{...l,headers:{...S,...l?.headers}});if(!T.ok)throw new Error(`Request failed: ${T.status}`);return T.json()},[a,m,h]);n.useEffect(()=>{(async()=>{try{const s=await b("/admin/compliance/sanctions-api");o(s)}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Failed to fetch settings:",s)}finally{C(!1)}})()},[b]);const k=async()=>{g(!0),p(null),f(null);try{await b("/admin/compliance/sanctions-api",{method:"PUT",body:JSON.stringify(r)}),f("Settings saved")}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Save failed:",s),p("Failed to save settings")}finally{g(!1)}},d=async()=>{w(!0),p(null),f(null);try{await b("/admin/compliance/sanctions-api/refresh",{method:"POST"}),f("Sanctions list refreshed")}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Refresh failed:",s),p("Failed to refresh sanctions list")}finally{w(!1)}};return y?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading sanctions API settings..."]}):e.jsxs("div",{style:{maxWidth:"500px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Dynamic Sanctions API"})}),N&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem"},children:N}),A&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--success",style:{padding:"0.5rem"},children:A}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:r.enabled,onChange:s=>o(l=>({...l,enabled:s.target.checked}))}),"Enable dynamic sanctions list"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["API URL",e.jsx("input",{type:"url",className:"cedros-admin__input",placeholder:"https://sunscreen.cedros.io",value:r.apiUrl,onChange:s=>o(l=>({...l,apiUrl:s.target.value}))})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Refresh interval (seconds, min 60)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:60,value:r.refreshIntervalSecs,onChange:s=>o(l=>({...l,refreshIntervalSecs:Number(s.target.value)})),style:{width:"160px"}})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:k,disabled:u,children:u?"Saving...":"Save Settings"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:d,disabled:i||!r.enabled||!r.apiUrl,children:i?"Refreshing...":"Force Refresh"})]})]})}function ue({serverUrl:a,apiKey:m,authManager:h}){const[r,o]=n.useState(""),[y,C]=n.useState(!1),[u,g]=n.useState(null),[i,w]=n.useState(null),[N,p]=n.useState(!1),A=n.useCallback(async(d,s)=>{if(h?.isAuthenticated())return h.fetchWithAuth(d,s);const l={"Content-Type":"application/json"};m&&(l["X-API-Key"]=m);const S=await fetch(`${a}${d}`,{...s,headers:{...l,...s?.headers}});if(!S.ok)throw new Error(`Request failed: ${S.status}`);return S.json()},[a,m,h]),f=async()=>{const d=r.trim();if(d){C(!0),g(null),w(null),p(!0);try{const s=await A(`/admin/compliance/user-status/${encodeURIComponent(d)}`);w(s)}catch(s){_.getLogger().error("[ComplianceKycTab] Lookup failed:",s),g("Failed to fetch user compliance status. Ensure cedros-login is configured.")}finally{C(!1)}}},b=d=>{d.key==="Enter"&&f()},k=d=>{switch(d){case"verified":return"Verified";case"pending":return"Pending";case"expired":return"Expired";case"none":default:return"Not Started"}};return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"KYC & Accredited Investor Status"})}),e.jsx("p",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)",marginBottom:"1rem"},children:"Look up a user's KYC verification and accredited investor status from cedros-login."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsxs("label",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["User ID",e.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"user_abc123",value:r,onChange:d=>o(d.target.value),onKeyDown:b})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:f,disabled:y||!r.trim(),children:y?"Looking up...":"Look Up"})]}),u&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem",marginBottom:"1rem"},children:u}),y&&e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Fetching compliance status..."]}),i&&!y&&e.jsxs("div",{style:{maxWidth:"500px"},children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsx("table",{className:"cedros-admin__table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"40%"},children:"User ID"}),e.jsx("td",{children:e.jsx("code",{children:i.userId})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"KYC Status"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${oe(i.kycStatus)}`,children:k(i.kycStatus)})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Accredited Investor"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${i.accreditedInvestor?"success":"muted"}`,children:i.accreditedInvestor?"Yes":"No"})})]}),i.accreditedVerifiedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Accredited Since"}),e.jsx("td",{children:R.formatDateTime(i.accreditedVerifiedAt)})]})]})})}),e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem",borderRadius:"4px",fontSize:"0.85rem",background:i.kycStatus==="verified"?"var(--cedros-admin-bg-success, #f0fdf4)":"var(--cedros-admin-bg-muted, #f5f5f5)",color:"var(--cedros-admin-text, #333)"},children:i.kycStatus==="verified"&&i.accreditedInvestor?"This user is fully verified and accredited. They can access all compliance-gated products.":i.kycStatus==="verified"?"This user has KYC verification but is not an accredited investor.":i.kycStatus==="pending"?"This user has submitted KYC documents. Verification is in progress.":i.kycStatus==="expired"?"This user's KYC verification has expired. They will need to re-verify.":"This user has not started KYC verification."})]}),N&&!i&&!y&&!u&&e.jsx("div",{className:"cedros-admin__empty",children:"No compliance record found for this user."})]})}function xe({serverUrl:a,apiKey:m,pageSize:h=50,authManager:r}){const[o,y]=n.useState("holders"),[C,u]=n.useState(null),[g,i]=n.useState([]),[w,N]=n.useState(!0),[p,A]=n.useState(""),[f,b]=n.useState([]),[k,d]=n.useState(!0),[s,l]=n.useState(null),[S,T]=n.useState(!1),[W,M]=n.useState(""),[B,Q]=n.useState(""),[O,H]=n.useState({enabled:!0,batchSize:100}),[Z,ee]=n.useState(!0),[q,Y]=n.useState(!1),[x,z]=n.useState(null),[$,D]=n.useState(""),[F,K]=n.useState(!1),v=n.useCallback(async(t,c)=>{if(r?.isAuthenticated())return r.fetchWithAuth(t,c);const L={"Content-Type":"application/json"};m&&(L["X-API-Key"]=m);const U=await fetch(`${a}${t}`,{...c,headers:{...L,...c?.headers}});if(!U.ok)throw new Error(`Request failed: ${U.status}`);return U.json()},[a,m,r]),E=n.useCallback(async()=>{try{const t=p?`&status=${p}`:"",c=await v(`/admin/compliance/holders?limit=${h}&offset=0${t}`);i(c.holders||[])}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch holders:",t),i([]),u("Failed to load token holders")}finally{N(!1)}},[v,h,p]),P=n.useCallback(async()=>{try{const t=await v(`/admin/compliance/actions?limit=${h}&offset=0`);b(t.actions||[])}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch actions:",t),b([]),u("Failed to load compliance actions")}finally{d(!1)}},[v,h]),J=n.useCallback(async()=>{try{const t=await v("/admin/compliance/sweep-settings");H(t)}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch sweep settings:",t)}finally{ee(!1)}},[v]),te=async()=>{Y(!0);try{await v("/admin/compliance/sweep-settings",{method:"PUT",body:JSON.stringify(O)})}catch(t){_.getLogger().error("[ComplianceSection] Failed to save sweep settings:",t),u("Failed to save sweep settings")}finally{Y(!1)}};n.useEffect(()=>{E()},[E]),n.useEffect(()=>{P()},[P]),n.useEffect(()=>{J()},[J]);const se=async()=>{if(!(!x||!$.trim())){K(!0);try{const t=x.action==="freeze"?"/admin/compliance/freeze":"/admin/compliance/thaw";await v(t,{method:"POST",body:JSON.stringify({holderId:x.holder.id,reason:$})}),z(null),D(""),await E(),await P()}catch(t){_.getLogger().error(`[ComplianceSection] ${x.action} failed:`,t),u(`Failed to ${x.action} holder`)}finally{K(!1)}}},ne=async()=>{T(!0);try{const t=new URLSearchParams;W&&t.set("from",new Date(W).toISOString()),B&&t.set("to",new Date(B).toISOString());const c=await v(`/admin/compliance/report?${t.toString()}`);l(c.report)}catch(t){_.getLogger().error("[ComplianceSection] Failed to generate report:",t),u("Failed to generate compliance report")}finally{T(!1)}},ae=()=>{if(!s)return;const t=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),c=URL.createObjectURL(t),L=document.createElement("a");L.href=c,L.download=`compliance-report-${new Date().toISOString().slice(0,10)}.json`,L.click(),URL.revokeObjectURL(c)},ie=g.length,G=g.filter(t=>t.status==="frozen").length,re=g.filter(t=>t.status==="active").length;return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(ce.ErrorBanner,{message:C,onRetry:()=>{E(),P()}}),e.jsx(V.StatsBar,{stats:[{label:"Total Holders",value:ie},{label:"Active",value:re,variant:"success"},{label:"Frozen",value:G,variant:G>0?"warning":"muted"},{label:"Actions Logged",value:f.length}],isLoading:w||k}),e.jsx("div",{className:"cedros-admin__tabs",style:{display:"flex",gap:"0.5rem",marginBottom:"1rem"},children:["holders","actions","reports","sweep-settings","sanctions-api","kyc"].map(t=>{const c=t==="holders"?"Token Holders":t==="actions"?"Actions Log":t==="reports"?"Reports":t==="sweep-settings"?"Sweep Settings":t==="sanctions-api"?"Sanctions API":"KYC & Accreditation";return e.jsx("button",{type:"button",className:`cedros-admin__button ${o===t?"cedros-admin__button--primary":"cedros-admin__button--ghost"}`,onClick:()=>y(t),children:c},t)})}),o==="holders"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__section-header",style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Token Holders"}),e.jsxs("select",{value:p,onChange:t=>{A(t.target.value),N(!0)},className:"cedros-admin__input",style:{width:"auto",padding:"0.25rem 0.5rem",fontSize:"0.85rem"},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"frozen",children:"Frozen"}),e.jsx("option",{value:"thawed",children:"Thawed"})]})]}),w?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading holders..."]}):g.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No token holders found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"Mint"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:g.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:e.jsx("code",{title:t.collectionId,children:j(t.collectionId)})}),e.jsx("td",{children:e.jsx("code",{title:t.mintAddress,children:j(t.mintAddress)})}),e.jsx("td",{children:t.amountMinted}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${de(t.status)}`,children:t.status})}),e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:t.status==="active"||t.status==="thawed"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger cedros-admin__button--sm",onClick:()=>{z({holder:t,action:"freeze"}),D("")},children:"Freeze"}):t.status==="frozen"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{z({holder:t,action:"thaw"}),D("")},children:"Thaw"}):null})]},t.id))})]})})]}),o==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Actions"})}),k?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading actions..."]}):f.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No compliance actions recorded."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"}),e.jsx("th",{children:"Tx Signature"})]})}),e.jsx("tbody",{children:f.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${X(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:j(t.actor)})}),e.jsx("td",{children:t.txSignature?e.jsx("a",{href:`${le}${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin__link",children:j(t.txSignature)}):"—"})]},t.id))})]})})]}),o==="reports"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Report"})}),e.jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"flex-end",marginBottom:"1rem"},children:[e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["From",e.jsx("input",{type:"date",className:"cedros-admin__input",value:W,onChange:t=>M(t.target.value)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["To",e.jsx("input",{type:"date",className:"cedros-admin__input",value:B,onChange:t=>Q(t.target.value)})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:ne,disabled:S,children:S?"Generating...":"Generate Report"})]}),s&&e.jsxs("div",{children:[e.jsx(V.StatsBar,{stats:[{label:"Total Holders",value:s.totalHolders},{label:"Frozen",value:s.totalFrozen,variant:s.totalFrozen>0?"warning":"muted"},{label:"Freezes",value:s.freezeCount},{label:"Thaws",value:s.thawCount},{label:"Sweep Freezes",value:s.sweepFreezeCount,variant:s.sweepFreezeCount>0?"warning":"muted"}],isLoading:!1}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"1rem 0 0.5rem"},children:[e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:["Generated ",R.formatDateTime(s.generatedAt)," · ",s.actionsInPeriod," actions in period"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:ae,children:"Download JSON"})]}),s.actions.length>0&&e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:s.actions.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${X(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:j(t.actor)})})]},t.id))})]})})]})]}),o==="sweep-settings"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Sanctions Sweep Settings"})}),Z?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading settings..."]}):e.jsxs("div",{style:{maxWidth:"400px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:O.enabled,onChange:t=>H(c=>({...c,enabled:t.target.checked}))}),"Enable automated sanctions sweep"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Batch size (1 – 10,000)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:1,max:1e4,value:O.batchSize,onChange:t=>H(c=>({...c,batchSize:Number(t.target.value)})),style:{width:"160px"}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:te,disabled:q,style:{alignSelf:"flex-start"},children:q?"Saving...":"Save Settings"})]})]}),o==="sanctions-api"&&e.jsx(he,{serverUrl:a,apiKey:m,authManager:r}),o==="kyc"&&e.jsx(ue,{serverUrl:a,apiKey:m,authManager:r}),x&&e.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>!F&&z(null),children:e.jsxs("div",{className:"cedros-admin__modal",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"cedros-admin__modal-header",children:[e.jsxs("h4",{className:"cedros-admin__modal-title",children:[x.action==="freeze"?"Freeze":"Thaw"," Token Account"]}),e.jsx("button",{type:"button",className:"cedros-admin__modal-close",onClick:()=>!F&&z(null),children:I.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__modal-body",children:[e.jsxs("p",{style:{marginBottom:"0.5rem",fontSize:"0.9rem"},children:["Wallet: ",e.jsx("code",{children:j(x.holder.walletAddress)})]}),e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem"},children:["Mint: ",e.jsx("code",{children:j(x.holder.mintAddress)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Reason (required)",e.jsx("textarea",{className:"cedros-admin__input",rows:3,value:$,onChange:t=>D(t.target.value),placeholder:`Reason for ${x.action}...`,maxLength:1024})]})]}),e.jsxs("div",{className:"cedros-admin__modal-footer",children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>z(null),disabled:F,children:"Cancel"}),e.jsx("button",{className:`cedros-admin__button ${x.action==="freeze"?"cedros-admin__button--danger":"cedros-admin__button--primary"}`,onClick:se,disabled:F||!$.trim(),children:F?"Processing...":x.action==="freeze"?"Freeze Account":"Thaw Account"})]})]})})]})}exports.ComplianceSection=xe;
|
|
@@ -3,8 +3,10 @@ import { useState as K, useRef as R, useCallback as P, useMemo as Y, useEffect a
|
|
|
3
3
|
import { useWallet as be } from "@solana/wallet-adapter-react";
|
|
4
4
|
import { WalletReadyState as pe } from "@solana/wallet-adapter-base";
|
|
5
5
|
import { WalletIcon as Te } from "@solana/wallet-adapter-react-ui";
|
|
6
|
-
import { T as Ie, K as Ee, O as We, U as V, q as Re, n as fe, s as _e, o as ge, p as qe, r as we, t as Z, V as Me, W as ze } from "./styles-
|
|
7
|
-
import { u as he,
|
|
6
|
+
import { T as Ie, K as Ee, O as We, U as V, q as Re, n as fe, s as _e, o as ge, p as qe, r as we, t as Z, V as Me, W as ze } from "./styles-DGagylUj.mjs";
|
|
7
|
+
import { u as he, l as ee } from "./CedrosContext-5Gjveoba.mjs";
|
|
8
|
+
import { g as n } from "./fetchWithTimeout-DmMOwL0Q.mjs";
|
|
9
|
+
import { u as De } from "./ThemeContext-l0bqcOGW.mjs";
|
|
8
10
|
function $e() {
|
|
9
11
|
const { x402Manager: g, walletManager: s } = he(), { publicKey: _, signTransaction: q } = be(), [L, d] = K({
|
|
10
12
|
status: "idle",
|
|
@@ -203,7 +205,7 @@ function $e() {
|
|
|
203
205
|
reset: W
|
|
204
206
|
};
|
|
205
207
|
}
|
|
206
|
-
function
|
|
208
|
+
function Fe({
|
|
207
209
|
resource: g,
|
|
208
210
|
items: s,
|
|
209
211
|
label: _,
|
|
@@ -245,7 +247,7 @@ function je({
|
|
|
245
247
|
fe("crypto", o, c, e), ae.current?.(o);
|
|
246
248
|
}
|
|
247
249
|
}, [W, o, y, s, c]);
|
|
248
|
-
const ce = typeof window < "u" && window.top !== window.self, [ie,
|
|
250
|
+
const ce = typeof window < "u" && window.top !== window.self, [ie, F] = K(!1), [ue, J] = K(!1), [N, S] = K(null), j = a;
|
|
249
251
|
H(() => {
|
|
250
252
|
let e = !1;
|
|
251
253
|
return e || (async () => {
|
|
@@ -268,20 +270,20 @@ function je({
|
|
|
268
270
|
let e = !0;
|
|
269
271
|
if (n().debug("[CryptoButton] Payment useEffect triggered", {
|
|
270
272
|
connected: u,
|
|
271
|
-
hasPendingPayment: !!
|
|
273
|
+
hasPendingPayment: !!N,
|
|
272
274
|
hasPublicKey: !!z,
|
|
273
|
-
pendingPaymentType:
|
|
274
|
-
}), u &&
|
|
275
|
-
_e(p.adapter.name, z.toString()), n().debug("[CryptoButton] All conditions met! Processing pending payment:",
|
|
276
|
-
const t =
|
|
277
|
-
S(null),
|
|
275
|
+
pendingPaymentType: N?.type
|
|
276
|
+
}), u && N && z && p && e) {
|
|
277
|
+
_e(p.adapter.name, z.toString()), n().debug("[CryptoButton] All conditions met! Processing pending payment:", N);
|
|
278
|
+
const t = N;
|
|
279
|
+
S(null), F(!1);
|
|
278
280
|
const m = t.type === "cart" && t.items ? V(t.items) : void 0;
|
|
279
281
|
ge("crypto", t.resource, m), t.type === "cart" && t.items ? (n().debug("[CryptoButton] Auto-processing cart payment"), le.current(t.items, t.metadata, t.couponCode)) : t.type === "single" && t.resource && (n().debug("[CryptoButton] Auto-processing single payment"), se.current(t.resource, t.couponCode, t.metadata));
|
|
280
282
|
}
|
|
281
283
|
return () => {
|
|
282
284
|
e = !1;
|
|
283
285
|
};
|
|
284
|
-
}, [u,
|
|
286
|
+
}, [u, N, z, p]);
|
|
285
287
|
const de = P(async () => {
|
|
286
288
|
n().debug("[CryptoButton] executePaymentFlow called", {
|
|
287
289
|
connected: u,
|
|
@@ -292,8 +294,8 @@ function je({
|
|
|
292
294
|
effectiveResource: c
|
|
293
295
|
});
|
|
294
296
|
const e = y && s ? V(s) : void 0;
|
|
295
|
-
if (qe("crypto", c, e), L && L("crypto"),
|
|
296
|
-
n().error("[CryptoButton] Solana dependencies missing:",
|
|
297
|
+
if (qe("crypto", c, e), L && L("crypto"), j) {
|
|
298
|
+
n().error("[CryptoButton] Solana dependencies missing:", j), fe("crypto", j, c, e), I && I(j);
|
|
297
299
|
return;
|
|
298
300
|
}
|
|
299
301
|
if (ce) {
|
|
@@ -327,7 +329,7 @@ function je({
|
|
|
327
329
|
const m = "No wallets available";
|
|
328
330
|
throw Z(m), new Error(m);
|
|
329
331
|
}
|
|
330
|
-
|
|
332
|
+
F(!0);
|
|
331
333
|
}
|
|
332
334
|
} catch (m) {
|
|
333
335
|
S(null);
|
|
@@ -335,21 +337,21 @@ function je({
|
|
|
335
337
|
n().error("[CryptoButton] Connection error:", U), Z(U, p?.adapter.name);
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
|
-
}, [u, p, w, y, s, c, ce, G, Q, E, C, b, i,
|
|
340
|
+
}, [u, p, w, y, s, c, ce, G, Q, E, C, b, i, j, L, I]), ye = Y(() => y && s ? `crypto-cart-${s.map((e) => e.resource).join("-")}` : `crypto-${c || "unknown"}`, [y, s, c]), Pe = Y(
|
|
339
341
|
() => Me(ye, de, {
|
|
340
342
|
cooldownMs: 200,
|
|
341
343
|
deduplicationWindowMs: 0
|
|
342
344
|
// MUST be 0 for crypto - each payment needs fresh transaction
|
|
343
345
|
}),
|
|
344
346
|
[ye, de]
|
|
345
|
-
), me = W === "loading", xe = q || me || X || !!
|
|
347
|
+
), me = W === "loading", xe = q || me || X || !!j, ve = me ? f("ui.processing") : O, Se = P(async () => {
|
|
346
348
|
try {
|
|
347
|
-
J(!1), u && await v(), M(null),
|
|
349
|
+
J(!1), u && await v(), M(null), F(!0);
|
|
348
350
|
} catch (e) {
|
|
349
351
|
n().error("Failed to change wallet:", e);
|
|
350
352
|
}
|
|
351
353
|
}, [u, v, M]), ke = P((e) => {
|
|
352
|
-
n().debug("[CryptoButton] Wallet clicked:", e),
|
|
354
|
+
n().debug("[CryptoButton] Wallet clicked:", e), F(!1), M(e), J(!0), n().debug("[CryptoButton] Wallet selected, useEffect will auto-connect");
|
|
353
355
|
}, [M]), Be = P(async () => {
|
|
354
356
|
try {
|
|
355
357
|
if (await v(), S(null), typeof window < "u" && window.localStorage)
|
|
@@ -391,7 +393,7 @@ function je({
|
|
|
391
393
|
padding: "1rem"
|
|
392
394
|
},
|
|
393
395
|
onClick: () => {
|
|
394
|
-
|
|
396
|
+
F(!1), S(null);
|
|
395
397
|
},
|
|
396
398
|
children: /* @__PURE__ */ A(
|
|
397
399
|
"div",
|
|
@@ -434,7 +436,7 @@ function je({
|
|
|
434
436
|
"button",
|
|
435
437
|
{
|
|
436
438
|
onClick: () => {
|
|
437
|
-
|
|
439
|
+
F(!1), S(null);
|
|
438
440
|
},
|
|
439
441
|
style: ze(r.tokens.surfaceText),
|
|
440
442
|
"aria-label": "Close modal",
|
|
@@ -531,12 +533,12 @@ function je({
|
|
|
531
533
|
!x && l && /* @__PURE__ */ h("div", { className: r.unstyled ? "" : "cedros-theme__success", children: f("ui.payment_successful") })
|
|
532
534
|
] });
|
|
533
535
|
}
|
|
534
|
-
const
|
|
536
|
+
const Ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
535
537
|
__proto__: null,
|
|
536
|
-
CryptoButton:
|
|
538
|
+
CryptoButton: Fe
|
|
537
539
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
538
540
|
export {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
+
Fe as C,
|
|
542
|
+
Ue as a,
|
|
541
543
|
$e as u
|
|
542
544
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const p=require("react/jsx-runtime"),a=require("react"),ie=require("@solana/wallet-adapter-react"),ce=require("@solana/wallet-adapter-base"),he=require("@solana/wallet-adapter-react-ui"),i=require("./styles--fxb3lCl.js"),K=require("./CedrosContext-CCakH2SZ.js"),n=require("./fetchWithTimeout-CG0EKbhf.js"),Ce=require("./ThemeContext-CFXyYx7A.js");function ue(){const{x402Manager:h,walletManager:l}=K.useCedrosContext(),{publicKey:W,signTransaction:q}=ie.useWallet(),[N,y]=a.useState({status:"idle",error:null,transactionId:null}),[R,L]=a.useState(null),[G,k]=a.useState(null),P=a.useRef(W);P.current=W;const C=a.useRef(q);C.current=q;const g=a.useRef(0),X=6e4,I=()=>{const o=g.current;return o>0&&Date.now()-o<X},S=a.useCallback(()=>{if(!W){const o="Wallet not connected";return y({status:"error",error:o,transactionId:null}),{valid:!1,error:o}}if(!q){const o="Wallet does not support signing";return y({status:"error",error:o,transactionId:null}),{valid:!1,error:o}}return{valid:!0}},[W,q]),j=a.useCallback(async o=>{try{y(d=>({...d,status:"loading"}));const c=await h.requestQuote({resource:o});if(!h.validateRequirement(c))throw new Error("Invalid requirement received from server");return L(c),y(d=>({...d,status:"idle"})),c}catch(c){const d=K.formatError(c,"Failed to fetch requirement");throw y({status:"error",error:d,transactionId:null}),c}},[h]),B=a.useCallback(async(o,c,d,x,r="regular")=>{const s=P.current,m=C.current;if(!s||!m)throw new Error("Wallet disconnected during payment flow");if(!!o.extra?.feePayer){n.getLogger().debug("[useX402Payment] Gasless flow enabled"),n.getLogger().debug("[useX402Payment] Building gasless transaction");const{transaction:b,blockhash:M}=await h.buildGaslessTransaction({resourceId:c,userWallet:s.toString(),feePayer:o.extra.feePayer,couponCode:d});n.getLogger().debug("[useX402Payment] Deserializing backend transaction");const A=l.deserializeTransaction(b);if(P.current?.toString()!==s.toString())throw new Error("Wallet changed during payment flow");n.getLogger().debug("[useX402Payment] Requesting partial signature");const E=await l.partiallySignTransaction({transaction:A,signTransaction:m,blockhash:M});n.getLogger().debug("[useX402Payment] Submitting partial transaction");const z=await h.submitGaslessTransaction({resource:c,partialTx:E,couponCode:d,metadata:x,resourceType:r,requirement:o});return z.success&&z.settlement&&k(z.settlement),z}else{const b=await l.buildTransaction({requirement:o,payerPublicKey:s});if(P.current?.toString()!==s.toString())throw new Error("Wallet changed during payment flow");const M=await l.signTransaction({transaction:b,signTransaction:m}),A=l.buildPaymentPayload({requirement:o,signedTx:M,payerPublicKey:s}),E=await h.submitPayment({resource:c,payload:A,couponCode:d,metadata:x,resourceType:r});return E.success&&E.settlement&&k(E.settlement),E}},[h,l]),w=a.useCallback(async(o,c,d)=>{if(I())return{success:!1,error:"Payment already in progress"};const x=S();if(!x.valid)return{success:!1,error:x.error};g.current=Date.now(),y({status:"loading",error:null,transactionId:null});try{n.getLogger().debug("[useX402Payment] Fetching fresh quote");const r=await h.requestQuote({resource:o,couponCode:c});n.getLogger().debug("[useX402Payment] Received quote",{amount:r.maxAmountRequired}),L(r),n.getLogger().debug("[useX402Payment] Executing payment flow");const s=await B(r,o,c,d,"regular");return s.success?y({status:"success",error:null,transactionId:s.transactionId||"payment-success"}):y({status:"error",error:s.error||"Payment failed",transactionId:null}),s}catch(r){const s=K.formatError(r,"Payment failed");return y({status:"error",error:s,transactionId:null}),{success:!1,error:s}}finally{g.current=0}},[S,h,B]),_=a.useCallback(async(o,c,d)=>{if(I())return{success:!1,error:"Payment already in progress"};const x=S();if(!x.valid)return{success:!1,error:x.error};g.current=Date.now(),y({status:"loading",error:null,transactionId:null});try{const r=i.normalizeCartItems(o),s=await h.requestCartQuote({items:r,metadata:c,couponCode:d}),m=s.cartId,u=s.quote;if(!h.validateRequirement(u))throw new Error("Invalid cart quote received from server");L(u);const b=await B(u,m,d,c,"cart");return b.success?y({status:"success",error:null,transactionId:b.transactionId||"cart-payment-success"}):y({status:"error",error:b.error||"Cart payment failed",transactionId:null}),b}catch(r){const s=K.formatError(r,"Cart payment failed");return y({status:"error",error:s,transactionId:null}),{success:!1,error:s}}finally{g.current=0}},[S,h,B]),T=a.useCallback(()=>{y({status:"idle",error:null,transactionId:null}),L(null),k(null),g.current=0},[]);return{...N,requirement:R,settlement:G,fetchQuote:j,processPayment:w,processCartPayment:_,reset:T}}function de({resource:h,items:l,label:W,disabled:q=!1,onAttempt:N,onSuccess:y,onError:R,className:L="",testPageUrl:G,hideMessages:k=!1,metadata:P,couponCode:C}){const{connected:g,connecting:X,connect:I,disconnect:S,select:j,wallets:B,wallet:w,publicKey:_}=ie.useWallet(),{status:T,error:o,transactionId:c,processPayment:d,processCartPayment:x}=ue(),r=Ce.useCedrosTheme(),{solanaError:s}=K.useCedrosContext(),{isCartMode:m,effectiveResource:u}=i.usePaymentMode(h,l),{t:b,translations:M}=i.useTranslation(),A=W||b("ui.pay_with_crypto"),E=o&&typeof o!="string"?o?.code??null:null,z=s&&typeof s!="string"?s?.code??null:null,Y=e=>{if(!e||!M)return"";const t=M.errors[e];return t?t.action?`${t.message} ${t.action}`:t.message:""},H=o?typeof o=="string"?o:Y(E):null,J=s?typeof s=="string"?s:Y(z):null,V=a.useRef(y),Z=a.useRef(R),ee=a.useRef(d),te=a.useRef(x);V.current=y,Z.current=R,ee.current=d,te.current=x;const ge=a.useMemo(()=>B.map(e=>`${e.adapter.name}-${e.readyState}`).join(","),[B]),O=a.useMemo(()=>B.filter(({readyState:e})=>e===ce.WalletReadyState.Installed||e===ce.WalletReadyState.Loadable),[ge]);a.useEffect(()=>{if(T==="success"&&c){const e=m&&l?i.getCartItemCount(l):void 0;i.emitPaymentSuccess("crypto",c,u,e),V.current?.(c)}},[T,c,m,l,u]),a.useEffect(()=>{if(T==="error"&&o){const e=m&&l?i.getCartItemCount(l):void 0;i.emitPaymentError("crypto",o,u,e),Z.current?.(o)}},[T,o,m,l,u]);const re=typeof window<"u"&&window.top!==window.self,[ne,$]=a.useState(!1),[oe,U]=a.useState(!1),[D,v]=a.useState(null),F=s;a.useEffect(()=>{let e=!1;return e||(async()=>{if(oe&&w&&!g&&!X){n.getLogger().debug("[CryptoButton] Wallet detected, attempting auto-connect:",w.adapter.name),U(!1),i.emitWalletConnect(w.adapter.name);try{await I(),e||n.getLogger().debug("[CryptoButton] Auto-connect successful")}catch(f){if(!e){n.getLogger().error("[CryptoButton] Auto-connect failed:",f);const Q=f instanceof Error?f.message:"Failed to connect wallet";i.emitWalletError(Q,w.adapter.name),v(null)}}}})(),()=>{e=!0}},[w,oe,g,X,I]),a.useEffect(()=>{let e=!0;if(n.getLogger().debug("[CryptoButton] Payment useEffect triggered",{connected:g,hasPendingPayment:!!D,hasPublicKey:!!_,pendingPaymentType:D?.type}),g&&D&&_&&w&&e){i.emitWalletConnected(w.adapter.name,_.toString()),n.getLogger().debug("[CryptoButton] All conditions met! Processing pending payment:",D);const t=D;v(null),$(!1);const f=t.type==="cart"&&t.items?i.getCartItemCount(t.items):void 0;i.emitPaymentProcessing("crypto",t.resource,f),t.type==="cart"&&t.items?(n.getLogger().debug("[CryptoButton] Auto-processing cart payment"),te.current(t.items,t.metadata,t.couponCode)):t.type==="single"&&t.resource&&(n.getLogger().debug("[CryptoButton] Auto-processing single payment"),ee.current(t.resource,t.couponCode,t.metadata))}return()=>{e=!1}},[g,D,_,w]);const ae=a.useCallback(async()=>{n.getLogger().debug("[CryptoButton] executePaymentFlow called",{connected:g,wallet:w?.adapter.name,couponCode:C,isCartMode:m,hasItems:!!l,effectiveResource:u});const e=m&&l?i.getCartItemCount(l):void 0;if(i.emitPaymentStart("crypto",u,e),N&&N("crypto"),F){n.getLogger().error("[CryptoButton] Solana dependencies missing:",F),i.emitPaymentError("crypto",F,u,e),R&&R(F);return}if(re){const t=G||window.location.href;try{if(new URL(t,window.location.origin).origin!==window.location.origin)throw n.getLogger().error("[CryptoButton] Blocked attempt to open external URL:",t),new Error("Cannot open external URLs from embedded context");window.open(t,"_blank","noopener,noreferrer")}catch(f){throw n.getLogger().error("[CryptoButton] URL validation failed:",f),f}return}if(g)i.emitPaymentProcessing("crypto",u,e),m&&l?(n.getLogger().debug("[CryptoButton] Processing cart payment with coupon:",C),await x(l,P,C)):u&&(n.getLogger().debug("[CryptoButton] Processing single payment with coupon:",C),await d(u,C,P));else{let t=!1;if(m&&l?(n.getLogger().debug("[CryptoButton] Setting pending cart payment with coupon:",C),v({type:"cart",items:l,metadata:P,couponCode:C}),t=!0):u&&(n.getLogger().debug("[CryptoButton] Setting pending single payment with coupon:",C),v({type:"single",resource:u,metadata:P,couponCode:C}),t=!0),!t){n.getLogger().error("[CryptoButton] No valid payment to process");return}try{if(w)n.getLogger().debug("[CryptoButton] Wallet already selected, connecting:",w.adapter.name),i.emitWalletConnect(w.adapter.name),await I();else{if(n.getLogger().debug("[CryptoButton] No wallet selected, showing selector. Available wallets:",O.map(f=>f.adapter.name)),O.length===0){v(null);const f="No wallets available";throw i.emitWalletError(f),new Error(f)}$(!0)}}catch(f){v(null);const Q=f instanceof Error?f.message:"Failed to connect wallet";n.getLogger().error("[CryptoButton] Connection error:",Q),i.emitWalletError(Q,w?.adapter.name)}}},[g,w,C,m,l,u,re,G,O,I,P,x,d,F,N,R]),se=a.useMemo(()=>m&&l?`crypto-cart-${l.map(e=>e.resource).join("-")}`:`crypto-${u||"unknown"}`,[m,l,u]),ye=a.useMemo(()=>i.createDedupedClickHandler(se,ae,{cooldownMs:200,deduplicationWindowMs:0}),[se,ae]),le=T==="loading",me=q||le||X||!!F,fe=le?b("ui.processing"):A,pe=a.useCallback(async()=>{try{U(!1),g&&await S(),j(null),$(!0)}catch(e){n.getLogger().error("Failed to change wallet:",e)}},[g,S,j]),we=a.useCallback(e=>{n.getLogger().debug("[CryptoButton] Wallet clicked:",e),$(!1),j(e),U(!0),n.getLogger().debug("[CryptoButton] Wallet selected, useEffect will auto-connect")},[j]),be=a.useCallback(async()=>{try{if(await S(),v(null),typeof window<"u"&&window.localStorage)try{window.localStorage.removeItem("walletName")}catch(e){e instanceof Error&&e.name==="QuotaExceededError"?n.getLogger().warn("localStorage quota exceeded when removing wallet preference"):n.getLogger().error("Failed to clear wallet preference from localStorage:",e)}}catch(e){n.getLogger().error("Failed to disconnect wallet:",e)}},[S]);return p.jsxs("div",{className:r.unstyled?L:`${r.className} cedros-theme__crypto-button ${L||""}`,style:r.unstyled?{}:r.style,children:[p.jsx("button",{onClick:ye,disabled:me,className:r.unstyled?L:"cedros-theme__button cedros-theme__crypto",type:"button",children:fe}),ne&&!k&&p.jsx("div",{className:"cedros-modal-overlay",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:r.tokens.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem"},onClick:()=>{$(!1),v(null)},children:p.jsxs("div",{className:"cedros-modal-content",style:{backgroundColor:r.tokens.modalBackground,borderRadius:"12px",padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",border:`1px solid ${r.tokens.modalBorder}`},onClick:e=>e.stopPropagation(),children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[p.jsx("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:600,color:r.tokens.surfaceText},children:b("wallet.select_wallet")}),p.jsx("button",{onClick:()=>{$(!1),v(null)},style:i.getModalCloseButtonStyles(r.tokens.surfaceText),"aria-label":"Close modal",type:"button",children:"×"})]}),p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:O.map(e=>p.jsxs("button",{onClick:()=>we(e.adapter.name),style:{width:"100%",padding:"1rem",backgroundColor:r.tokens.surfaceBackground,border:`1px solid ${r.tokens.surfaceBorder}`,borderRadius:"0.5rem",cursor:"pointer",fontSize:"1rem",textAlign:"left",color:r.tokens.surfaceText,display:"flex",alignItems:"center",gap:"1rem",transition:"all 0.2s ease"},onMouseEnter:t=>{t.currentTarget.style.backgroundColor=r.tokens.modalBackground,t.currentTarget.style.borderColor=r.tokens.surfaceText,t.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:t=>{t.currentTarget.style.backgroundColor=r.tokens.surfaceBackground,t.currentTarget.style.borderColor=r.tokens.surfaceBorder,t.currentTarget.style.transform="translateY(0)"},type:"button",children:[p.jsx(he.WalletIcon,{wallet:e,style:{width:"24px",height:"24px"}}),p.jsx("span",{style:{fontWeight:500},children:e.adapter.name})]},e.adapter.name))})]})}),g&&!k&&!ne&&p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.5rem",fontSize:"0.75rem",color:r.tokens.surfaceText,opacity:.7},children:[p.jsx("button",{onClick:pe,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:b("wallet.change")}),p.jsx("button",{onClick:be,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:b("ui.disconnect")})]}),!k&&J&&p.jsx("div",{className:r.unstyled?"":"cedros-theme__error",children:J}),!k&&H&&p.jsx("div",{className:r.unstyled?"":"cedros-theme__error",children:H}),!k&&c&&p.jsx("div",{className:r.unstyled?"":"cedros-theme__success",children:b("ui.payment_successful")})]})}const xe=Object.freeze(Object.defineProperty({__proto__:null,CryptoButton:de},Symbol.toStringTag,{value:"Module"}));exports.CryptoButton=de;exports.CryptoButton$1=xe;exports.useX402Payment=ue;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { jsxs as s, jsx as t, Fragment as $ } from "react/jsx-runtime";
|
|
2
|
-
import { useState as o, useCallback as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
2
|
+
import { useState as o, useCallback as I, useEffect as O } from "react";
|
|
3
|
+
import { I as B } from "./icons-C3yDMnKE.mjs";
|
|
4
|
+
import { E as q } from "./ErrorBanner-lZJhCmDX.mjs";
|
|
5
|
+
import { f as J } from "./dateHelpers-yvPkofYQ.mjs";
|
|
6
|
+
function G({ serverUrl: N, apiKey: p, pageSize: r = 20, authManager: f }) {
|
|
7
|
+
const [_, v] = o([]), [k, x] = o(!0), [D, m] = o(null), [i, w] = o(0), [L, b] = o(!1), [S, E] = o(!1), [d, A] = o(null), [c, j] = o(""), [a, l] = o({ email: "", name: "", phone: "" }), h = I(async (e, n) => {
|
|
8
|
+
if (f?.isAuthenticated())
|
|
9
|
+
return f.fetchWithAuth(e, n);
|
|
10
|
+
const F = { "Content-Type": "application/json" };
|
|
11
|
+
p && (F["X-API-Key"] = p);
|
|
12
|
+
const C = await fetch(`${N}${e}`, { ...n, headers: { ...F, ...n?.headers } });
|
|
11
13
|
if (!C.ok) throw new Error(`Request failed: ${C.status}`);
|
|
12
14
|
return C.json();
|
|
13
|
-
}, [N,
|
|
15
|
+
}, [N, p, f]), y = I(async () => {
|
|
14
16
|
x(!0), m(null);
|
|
15
17
|
try {
|
|
16
18
|
const e = await h(
|
|
@@ -27,9 +29,9 @@ function X({ serverUrl: N, apiKey: _, pageSize: r = 20, authManager: p }) {
|
|
|
27
29
|
y();
|
|
28
30
|
}, [y]);
|
|
29
31
|
const g = () => {
|
|
30
|
-
l({ email: "", name: "", phone: "" }),
|
|
32
|
+
l({ email: "", name: "", phone: "" }), A(null), b(!1);
|
|
31
33
|
}, P = (e) => {
|
|
32
|
-
|
|
34
|
+
A(e), l({ email: e.email, name: e.name ?? "", phone: e.phone ?? "" }), b(!0);
|
|
33
35
|
}, T = async (e) => {
|
|
34
36
|
e.preventDefault(), E(!0), m(null);
|
|
35
37
|
try {
|
|
@@ -55,10 +57,10 @@ function X({ serverUrl: N, apiKey: _, pageSize: r = 20, authManager: p }) {
|
|
|
55
57
|
} finally {
|
|
56
58
|
E(!1);
|
|
57
59
|
}
|
|
58
|
-
}, u = c.trim() ?
|
|
60
|
+
}, u = c.trim() ? _.filter((e) => {
|
|
59
61
|
const n = c.toLowerCase();
|
|
60
62
|
return e.email.toLowerCase().includes(n) || (e.name ?? "").toLowerCase().includes(n) || e.id.toLowerCase().includes(n);
|
|
61
|
-
}) :
|
|
63
|
+
}) : _, W = (e) => [e.line1, e.city, e.state, e.postalCode, e.country].filter(Boolean).join(", ");
|
|
62
64
|
return /* @__PURE__ */ s("div", { children: [
|
|
63
65
|
/* @__PURE__ */ s("div", { className: "cedros-admin__section-header", children: [
|
|
64
66
|
/* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Customers" }),
|
|
@@ -74,7 +76,7 @@ function X({ serverUrl: N, apiKey: _, pageSize: r = 20, authManager: p }) {
|
|
|
74
76
|
}
|
|
75
77
|
)
|
|
76
78
|
] }),
|
|
77
|
-
/* @__PURE__ */ t(
|
|
79
|
+
/* @__PURE__ */ t(q, { message: D }),
|
|
78
80
|
/* @__PURE__ */ t("div", { style: { marginBottom: "1rem", maxWidth: "400px" }, children: /* @__PURE__ */ t(
|
|
79
81
|
"input",
|
|
80
82
|
{
|
|
@@ -141,8 +143,8 @@ function X({ serverUrl: N, apiKey: _, pageSize: r = 20, authManager: p }) {
|
|
|
141
143
|
/* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button cedros-admin__button--ghost", onClick: g, children: "Cancel" })
|
|
142
144
|
] })
|
|
143
145
|
] }),
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
k ? /* @__PURE__ */ s("div", { className: "cedros-admin__loading", children: [
|
|
147
|
+
B.loading,
|
|
146
148
|
" Loading customers..."
|
|
147
149
|
] }) : u.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: c ? "No matching customers." : "No customers found." }) : /* @__PURE__ */ s($, { children: [
|
|
148
150
|
/* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ s("table", { className: "cedros-admin__table", children: [
|
|
@@ -193,7 +195,7 @@ function X({ serverUrl: N, apiKey: _, pageSize: r = 20, authManager: p }) {
|
|
|
193
195
|
{
|
|
194
196
|
type: "button",
|
|
195
197
|
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
196
|
-
disabled:
|
|
198
|
+
disabled: _.length < r,
|
|
197
199
|
onClick: () => w(i + r),
|
|
198
200
|
children: "Next"
|
|
199
201
|
}
|
|
@@ -203,5 +205,5 @@ function X({ serverUrl: N, apiKey: _, pageSize: r = 20, authManager: p }) {
|
|
|
203
205
|
] });
|
|
204
206
|
}
|
|
205
207
|
export {
|
|
206
|
-
|
|
208
|
+
G as CustomersSection
|
|
207
209
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),P=require("./icons-Cjgd9YVo.js"),T=require("./ErrorBanner-CAgPnj62.js"),O=require("./dateHelpers-BKW_lGND.js");function W({serverUrl:y,apiKey:h,pageSize:r=20,authManager:x}){const[_,g]=n.useState([]),[k,C]=n.useState(!0),[q,l]=n.useState(null),[o,N]=n.useState(0),[A,p]=n.useState(!1),[v,S]=n.useState(!1),[i,w]=n.useState(null),[c,F]=n.useState(""),[a,d]=n.useState({email:"",name:"",phone:""}),m=n.useCallback(async(t,s)=>{if(x?.isAuthenticated())return x.fetchWithAuth(t,s);const E={"Content-Type":"application/json"};h&&(E["X-API-Key"]=h);const b=await fetch(`${y}${t}`,{...s,headers:{...E,...s?.headers}});if(!b.ok)throw new Error(`Request failed: ${b.status}`);return b.json()},[y,h,x]),f=n.useCallback(async()=>{C(!0),l(null);try{const t=await m(`/admin/customers?limit=${r}&offset=${o}`);g(t.customers??[])}catch{l("Failed to load customers"),g([])}finally{C(!1)}},[m,r,o]);n.useEffect(()=>{f()},[f]);const j=()=>{d({email:"",name:"",phone:""}),w(null),p(!1)},D=t=>{w(t),d({email:t.email,name:t.name??"",phone:t.phone??""}),p(!0)},I=async t=>{t.preventDefault(),S(!0),l(null);try{i?await m(`/admin/customers/${encodeURIComponent(i.id)}`,{method:"PUT",body:JSON.stringify({email:a.email,name:a.name||null,phone:a.phone||null,addresses:i.addresses})}):await m("/admin/customers",{method:"POST",body:JSON.stringify({email:a.email,name:a.name||null,phone:a.phone||null,addresses:[]})}),j(),f()}catch(s){l(s instanceof Error?s.message:"Failed to save customer")}finally{S(!1)}},u=c.trim()?_.filter(t=>{const s=c.toLowerCase();return t.email.toLowerCase().includes(s)||(t.name??"").toLowerCase().includes(s)||t.id.toLowerCase().includes(s)}):_,L=t=>[t.line1,t.city,t.state,t.postalCode,t.country].filter(Boolean).join(", ");return e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Customers"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{j(),p(!0)},children:"+ Add Customer"})]}),e.jsx(T.ErrorBanner,{message:q}),e.jsx("div",{style:{marginBottom:"1rem",maxWidth:"400px"},children:e.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"Search by email, name, or ID...",value:c,onChange:t=>F(t.target.value),style:{fontSize:"0.85rem"}})}),A&&e.jsxs("form",{onSubmit:I,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:i?"Edit Customer":"New Customer"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Email *"}),e.jsx("input",{type:"email",className:"cedros-admin__input",value:a.email,onChange:t=>d(s=>({...s,email:t.target.value})),required:!0,placeholder:"customer@example.com"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.name,onChange:t=>d(s=>({...s,name:t.target.value})),placeholder:"Jane Doe"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Phone"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.phone,onChange:t=>d(s=>({...s,phone:t.target.value})),placeholder:"+1 555 123 4567"})]})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:v,children:v?"Saving...":i?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:j,children:"Cancel"})]})]}),k?e.jsxs("div",{className:"cedros-admin__loading",children:[P.Icons.loading," Loading customers..."]}):u.length===0?e.jsx("div",{className:"cedros-admin__empty",children:c?"No matching customers.":"No customers found."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Email"}),e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Phone"}),e.jsx("th",{children:"Address"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:u.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.email}),e.jsx("td",{children:t.name??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:t.phone??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.addresses.length>0?L(t.addresses[0]):"—"}),e.jsx("td",{children:O.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>D(t),children:"Edit"})})]},t.id))})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"0.75rem",fontSize:"0.85rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:o===0,onClick:()=>N(Math.max(0,o-r)),children:"Previous"}),e.jsxs("span",{children:["Showing ",u.length," customer",u.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:_.length<r,onClick:()=>N(o+r),children:"Next"})]})]})]})}exports.CustomersSection=W;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),k=require("./icons-Cjgd9YVo.js"),$=require("./ErrorBanner-CAgPnj62.js"),g=require("./dateHelpers-BKW_lGND.js"),I=d=>{switch(d){case"won":return"success";case"lost":return"failed";case"needs_response":case"warning_needs_response":return"pending";default:return"muted"}},C=(d,i)=>`${i.toUpperCase()} ${(d/100).toFixed(2)}`;function F({serverUrl:d,apiKey:i,pageSize:a=20,authManager:x}){const[r,y]=s.useState([]),[W,b]=s.useState(!0),[D,l]=s.useState(null),[c,j]=s.useState(0),[o,U]=s.useState("all"),[h,p]=s.useState(null),[u,v]=s.useState(""),[S,N]=s.useState(!1),m=s.useCallback(async(t,n)=>{if(x?.isAuthenticated())return x.fetchWithAuth(t,n);const w={"Content-Type":"application/json"};i&&(w["X-API-Key"]=i);const f=await fetch(`${d}${t}`,{...n,headers:{...w,...n?.headers}});if(!f.ok)throw new Error(`Request failed: ${f.status}`);return f.json()},[d,i,x]),_=s.useCallback(async()=>{b(!0),l(null);try{const t=new URLSearchParams;t.set("limit",String(a)),t.set("offset",String(c)),o!=="all"&&t.set("status",o);const n=await m(`/admin/disputes?${t.toString()}`);y(n.disputes??[])}catch{l("Failed to load disputes"),y([])}finally{b(!1)}},[m,a,c,o]);s.useEffect(()=>{_()},[_]);const A=async t=>{try{const n=await m(`/admin/disputes/${encodeURIComponent(t)}`);p(n),v(n.status)}catch{l("Failed to load dispute details")}},R=async()=>{if(!(!h||!u.trim())){N(!0);try{const t=await m(`/admin/disputes/${encodeURIComponent(h.id)}/status`,{method:"PUT",body:JSON.stringify({status:u})});p(t),_()}catch{l("Failed to update dispute status")}finally{N(!1)}}};if(h){const t=h;return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>p(null),style:{marginBottom:"1rem"},children:"← Back to disputes"}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Dispute ",e.jsx("code",{style:{fontSize:"0.8rem"},children:t.id.slice(0,12)})]})}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px"},children:e.jsx("table",{className:"cedros-admin__table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"35%"},children:"Status"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Amount"}),e.jsx("td",{children:C(t.amount,t.currency)})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Source"}),e.jsx("td",{children:t.source})]}),t.reason&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Reason"}),e.jsx("td",{children:t.reason})]}),t.orderId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Order ID"}),e.jsx("td",{children:e.jsx("code",{children:t.orderId})})]}),t.chargeId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Charge ID"}),e.jsx("td",{children:e.jsx("code",{children:t.chargeId})})]}),t.paymentIntentId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Payment Intent"}),e.jsx("td",{children:e.jsx("code",{children:t.paymentIntentId})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Created"}),e.jsx("td",{children:g.formatDateTime(t.createdAt)})]}),t.statusUpdatedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Status Updated"}),e.jsx("td",{children:g.formatDateTime(t.statusUpdatedAt)})]})]})})}),e.jsxs("div",{style:{marginTop:"1rem",display:"flex",gap:"0.5rem",alignItems:"flex-end",maxWidth:"400px"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Update Status"}),e.jsxs("select",{className:"cedros-admin__input",value:u,onChange:n=>v(n.target.value),children:[e.jsx("option",{value:"needs_response",children:"Needs Response"}),e.jsx("option",{value:"under_review",children:"Under Review"}),e.jsx("option",{value:"won",children:"Won"}),e.jsx("option",{value:"lost",children:"Lost"}),e.jsx("option",{value:"warning_closed",children:"Warning Closed"})]})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:R,disabled:S||u===t.status,children:S?"Updating...":"Update"})]})]})}return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Disputes & Chargebacks"})}),e.jsx($.ErrorBanner,{message:D}),e.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:e.jsxs("select",{className:"cedros-admin__input",value:o,onChange:t=>{U(t.target.value),j(0)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"needs_response",children:"Needs Response"}),e.jsx("option",{value:"under_review",children:"Under Review"}),e.jsx("option",{value:"won",children:"Won"}),e.jsx("option",{value:"lost",children:"Lost"})]})}),W?e.jsxs("div",{className:"cedros-admin__loading",children:[k.Icons.loading," Loading disputes..."]}):r.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No disputes found."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"ID"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:r.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{style:{fontSize:"0.75rem"},children:t.id.slice(0,12)})}),e.jsx("td",{children:C(t.amount,t.currency)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})}),e.jsx("td",{children:t.reason??"—"}),e.jsx("td",{children:t.source}),e.jsx("td",{children:g.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>A(t.id),children:"View"})})]},t.id))})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"0.75rem",fontSize:"0.85rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:c===0,onClick:()=>j(Math.max(0,c-a)),children:"Previous"}),e.jsxs("span",{children:["Showing ",r.length," dispute",r.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r.length<a,onClick:()=>j(c+a),children:"Next"})]})]})]})}exports.DisputesSection=F;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsxs as n, jsx as e, Fragment as E } from "react/jsx-runtime";
|
|
2
2
|
import { useState as d, useCallback as x, useEffect as L } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { I as j } from "./icons-C3yDMnKE.mjs";
|
|
4
|
+
import { E as B } from "./ErrorBanner-lZJhCmDX.mjs";
|
|
5
|
+
import { f as v } from "./dateHelpers-yvPkofYQ.mjs";
|
|
4
6
|
const U = (i) => {
|
|
5
7
|
switch (i) {
|
|
6
8
|
case "won":
|
|
@@ -13,21 +15,21 @@ const U = (i) => {
|
|
|
13
15
|
default:
|
|
14
16
|
return "muted";
|
|
15
17
|
}
|
|
16
|
-
}, A = (i,
|
|
17
|
-
function
|
|
18
|
-
const [c, N] = d([]), [D, w] = d(!0), [
|
|
18
|
+
}, A = (i, r) => `${r.toUpperCase()} ${(i / 100).toFixed(2)}`;
|
|
19
|
+
function V({ serverUrl: i, apiKey: r, pageSize: a = 20, authManager: _ }) {
|
|
20
|
+
const [c, N] = d([]), [D, w] = d(!0), [R, o] = d(null), [l, f] = d(0), [h, $] = d("all"), [u, g] = d(null), [m, I] = d(""), [S, C] = d(!1), p = x(async (t, s) => {
|
|
19
21
|
if (_?.isAuthenticated())
|
|
20
22
|
return _.fetchWithAuth(t, s);
|
|
21
23
|
const W = { "Content-Type": "application/json" };
|
|
22
|
-
|
|
24
|
+
r && (W["X-API-Key"] = r);
|
|
23
25
|
const b = await fetch(`${i}${t}`, { ...s, headers: { ...W, ...s?.headers } });
|
|
24
26
|
if (!b.ok) throw new Error(`Request failed: ${b.status}`);
|
|
25
27
|
return b.json();
|
|
26
|
-
}, [i,
|
|
28
|
+
}, [i, r, _]), y = x(async () => {
|
|
27
29
|
w(!0), o(null);
|
|
28
30
|
try {
|
|
29
31
|
const t = new URLSearchParams();
|
|
30
|
-
t.set("limit", String(
|
|
32
|
+
t.set("limit", String(a)), t.set("offset", String(l)), h !== "all" && t.set("status", h);
|
|
31
33
|
const s = await p(`/admin/disputes?${t.toString()}`);
|
|
32
34
|
N(s.disputes ?? []);
|
|
33
35
|
} catch {
|
|
@@ -35,11 +37,11 @@ function q({ serverUrl: i, apiKey: a, pageSize: r = 20, authManager: _ }) {
|
|
|
35
37
|
} finally {
|
|
36
38
|
w(!1);
|
|
37
39
|
}
|
|
38
|
-
}, [p,
|
|
40
|
+
}, [p, a, l, h]);
|
|
39
41
|
L(() => {
|
|
40
42
|
y();
|
|
41
43
|
}, [y]);
|
|
42
|
-
const
|
|
44
|
+
const k = async (t) => {
|
|
43
45
|
try {
|
|
44
46
|
const s = await p(`/admin/disputes/${encodeURIComponent(t)}`);
|
|
45
47
|
g(s), I(s.status);
|
|
@@ -143,14 +145,14 @@ function q({ serverUrl: i, apiKey: a, pageSize: r = 20, authManager: _ }) {
|
|
|
143
145
|
}
|
|
144
146
|
return /* @__PURE__ */ n("div", { children: [
|
|
145
147
|
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Disputes & Chargebacks" }) }),
|
|
146
|
-
/* @__PURE__ */ e(
|
|
148
|
+
/* @__PURE__ */ e(B, { message: R }),
|
|
147
149
|
/* @__PURE__ */ e("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "1rem", alignItems: "center" }, children: /* @__PURE__ */ n(
|
|
148
150
|
"select",
|
|
149
151
|
{
|
|
150
152
|
className: "cedros-admin__input",
|
|
151
153
|
value: h,
|
|
152
154
|
onChange: (t) => {
|
|
153
|
-
|
|
155
|
+
$(t.target.value), f(0);
|
|
154
156
|
},
|
|
155
157
|
style: { width: "auto", fontSize: "0.85rem" },
|
|
156
158
|
children: [
|
|
@@ -163,7 +165,7 @@ function q({ serverUrl: i, apiKey: a, pageSize: r = 20, authManager: _ }) {
|
|
|
163
165
|
}
|
|
164
166
|
) }),
|
|
165
167
|
D ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
166
|
-
|
|
168
|
+
j.loading,
|
|
167
169
|
" Loading disputes..."
|
|
168
170
|
] }) : c.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No disputes found." }) : /* @__PURE__ */ n(E, { children: [
|
|
169
171
|
/* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
@@ -188,7 +190,7 @@ function q({ serverUrl: i, apiKey: a, pageSize: r = 20, authManager: _ }) {
|
|
|
188
190
|
{
|
|
189
191
|
type: "button",
|
|
190
192
|
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
191
|
-
onClick: () =>
|
|
193
|
+
onClick: () => k(t.id),
|
|
192
194
|
children: "View"
|
|
193
195
|
}
|
|
194
196
|
) })
|
|
@@ -201,7 +203,7 @@ function q({ serverUrl: i, apiKey: a, pageSize: r = 20, authManager: _ }) {
|
|
|
201
203
|
type: "button",
|
|
202
204
|
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
203
205
|
disabled: l === 0,
|
|
204
|
-
onClick: () => f(Math.max(0, l -
|
|
206
|
+
onClick: () => f(Math.max(0, l - a)),
|
|
205
207
|
children: "Previous"
|
|
206
208
|
}
|
|
207
209
|
),
|
|
@@ -216,8 +218,8 @@ function q({ serverUrl: i, apiKey: a, pageSize: r = 20, authManager: _ }) {
|
|
|
216
218
|
{
|
|
217
219
|
type: "button",
|
|
218
220
|
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
219
|
-
disabled: c.length <
|
|
220
|
-
onClick: () => f(l +
|
|
221
|
+
disabled: c.length < a,
|
|
222
|
+
onClick: () => f(l + a),
|
|
221
223
|
children: "Next"
|
|
222
224
|
}
|
|
223
225
|
)
|
|
@@ -226,5 +228,5 @@ function q({ serverUrl: i, apiKey: a, pageSize: r = 20, authManager: _ }) {
|
|
|
226
228
|
] });
|
|
227
229
|
}
|
|
228
230
|
export {
|
|
229
|
-
|
|
231
|
+
V as DisputesSection
|
|
230
232
|
};
|