@cedros/pay-react 1.1.28 → 1.1.29
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/{AISettingsSection-DELur7D2.js → AISettingsSection-B7qrycfY.js} +2 -2
- package/dist/{AISettingsSection-BlIv3CzS.mjs → AISettingsSection-DtAgMsDw.mjs} +6 -4
- package/dist/{AutosaveIndicator-Bed0-ekg.mjs → AutosaveIndicator-BEvABoKU.mjs} +1 -1
- package/dist/AutosaveIndicator-DiyeAg93.js +1 -0
- package/dist/CedrosContext-5Gjveoba.mjs +2555 -0
- package/dist/CedrosContext-CCakH2SZ.js +3 -0
- package/dist/CedrosPayAdminDashboard-CAwEvn66.js +1 -0
- package/dist/CedrosPayAdminDashboard-CBuvNAtB.mjs +250 -0
- package/dist/{ChatLogsSection-v4zwzCTC.mjs → ChatLogsSection-Ber5o8hF.mjs} +19 -17
- package/dist/ChatLogsSection-DLxMMi9I.js +1 -0
- package/dist/ComplianceSection-Buu0zTiL.js +1 -0
- package/dist/{ComplianceSection-CemgfDrL.mjs → ComplianceSection-ZCr0wsvw.mjs} +18 -15
- package/dist/{CryptoButton-BV9owVe2.mjs → CryptoButton-Cl2kZbOP.mjs} +26 -24
- package/dist/CryptoButton-DxFCYDlJ.js +1 -0
- package/dist/CustomersSection-BywmMLur.js +1 -0
- package/dist/{CustomersSection-D_j7OrfS.mjs → CustomersSection-D9UknSKC.mjs} +21 -19
- package/dist/{DisputesSection-BcAbXp3K.mjs → DisputesSection-C_eySK-W.mjs} +19 -17
- package/dist/DisputesSection-DwkHGv2a.js +1 -0
- package/dist/Dropdown-B90Zabxr.mjs +111 -0
- package/dist/Dropdown-CtY91emj.js +1 -0
- package/dist/ErrorBanner-CZXsHi3H.mjs +22 -0
- package/dist/ErrorBanner-Cx2dUhps.js +1 -0
- package/dist/{FAQSection-Dn38OhB_.mjs → FAQSection-Bv_Hdt8B.mjs} +8 -6
- package/dist/FAQSection-DlPLnIJD.js +1 -0
- package/dist/ImagesSection-B4Jzet79.js +1 -0
- package/dist/{ImagesSection-Ctw9Icym.mjs → ImagesSection-DpdXQ6qu.mjs} +6 -4
- package/dist/InventorySection-BgRdpn1l.js +1 -0
- package/dist/{InventorySection-DmhjUlRZ.mjs → InventorySection-DZMu9DMw.mjs} +25 -23
- package/dist/MessagingSection-CxV-pf-f.js +1 -0
- package/dist/{MessagingSection-B1FaGxkp.mjs → MessagingSection-D_cOBfFt.mjs} +5 -4
- package/dist/OrdersSection-BbAX79Ff.js +1 -0
- package/dist/{OrdersSection-Bj8bPdg8.mjs → OrdersSection-wfPavit9.mjs} +27 -24
- package/dist/PaymentSettingsSection-BdBDgaRg.js +1 -0
- package/dist/PaymentSettingsSection-DunzBo9n.mjs +648 -0
- package/dist/ReturnsSection-7k4LZ8yp.js +1 -0
- package/dist/{ReturnsSection-BC0L8r2e.mjs → ReturnsSection-B4FL7bUv.mjs} +11 -9
- package/dist/{SettingsSection-vdYFSNxB.js → SettingsSection-Cz2Yjdhr.js} +1 -1
- package/dist/{SettingsSection-KYdEizq_.mjs → SettingsSection-DoeNDbqd.mjs} +1 -1
- package/dist/{ShippingSection-BOgto6_9.mjs → ShippingSection-BlVsYC6B.mjs} +5 -3
- package/dist/ShippingSection-C-HI8rOb.js +1 -0
- package/dist/{SingleCategorySettings-suJ8z9d8.mjs → SingleCategorySettings-B406nnF-.mjs} +143 -140
- package/dist/SingleCategorySettings-BqC2UXt3.js +3 -0
- package/dist/StatsBar-D4v-I_Dj.mjs +25 -0
- package/dist/StatsBar-m6GSRNxs.js +1 -0
- package/dist/StorefrontSection-Axvh_KeS.js +1 -0
- package/dist/{StorefrontSection-BRvIGBEJ.mjs → StorefrontSection-BK_rhrAi.mjs} +121 -119
- package/dist/{SubscriptionsSection-D60qrX9a.mjs → SubscriptionsSection-D8V9RBv-.mjs} +11 -9
- package/dist/SubscriptionsSection-EeULMWIB.js +1 -0
- package/dist/{TaxSection-C7-pv-Rl.mjs → TaxSection-Cj6TXL6x.mjs} +23 -21
- package/dist/TaxSection-CzHPhaHl.js +1 -0
- package/dist/ThemeContext-CFXyYx7A.js +1 -0
- package/dist/ThemeContext-l0bqcOGW.mjs +126 -0
- package/dist/Token22Section-DqRKVG_G.js +1 -0
- package/dist/{Token22Section-CrHLQ0EB.mjs → Token22Section-DtYAcT54.mjs} +7 -6
- package/dist/{WalletManager-BIwH8Dw_.mjs → WalletManager-D-eoqUDy.mjs} +21 -19
- package/dist/WalletManager-DXChB9LA.js +1 -0
- package/dist/WebhooksSection-D--iPZuM.js +1 -0
- package/dist/{WebhooksSection-COPW4Ec0.mjs → WebhooksSection-DBAIxtBy.mjs} +40 -38
- package/dist/admin.d.ts +2 -0
- package/dist/admin.js +1 -0
- package/dist/admin.mjs +8 -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 +214 -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/index-9QF_UfSN.mjs +18668 -0
- package/dist/index-Cq9ya93W.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +74 -64
- package/dist/safeHref-DqJPLPl5.mjs +12 -0
- package/dist/safeHref-DyHIpVjY.js +1 -0
- package/dist/sectionIds-B_tFiNvF.js +1 -0
- package/dist/sectionIds-DBavltrL.mjs +359 -0
- package/dist/sections-BHph7CYj.mjs +9 -0
- package/dist/sections-C2zEJr5G.js +1 -0
- package/dist/sections-more-C1VNVwkp.js +1 -0
- package/dist/sections-more-CMFgfU4d.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/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/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 +3 -3
- package/dist/AutosaveIndicator-Dn_qA2hK.js +0 -1
- 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
|
@@ -0,0 +1,3082 @@
|
|
|
1
|
+
import { jsxs as t, jsx as e, Fragment as me } from "react/jsx-runtime";
|
|
2
|
+
import { useState as S, useCallback as B, useMemo as H, useEffect as Y, Suspense as ke, lazy as Se } from "react";
|
|
3
|
+
import { I as L } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as re } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
5
|
+
import { S as pe } from "./StatsBar-D4v-I_Dj.mjs";
|
|
6
|
+
import { a as Ne, F as Q } from "./Dropdown-B90Zabxr.mjs";
|
|
7
|
+
import { f as he } from "./dateHelpers-yvPkofYQ.mjs";
|
|
8
|
+
import { g as se } from "./fetchWithTimeout-DmMOwL0Q.mjs";
|
|
9
|
+
function Ae({
|
|
10
|
+
serverUrl: p,
|
|
11
|
+
productId: r,
|
|
12
|
+
apiKey: v,
|
|
13
|
+
authManager: u
|
|
14
|
+
}) {
|
|
15
|
+
const [g, T] = S(null), [A, $] = S(!1), [_, U] = S(!1), [w, C] = S(null), I = B(async () => {
|
|
16
|
+
if (r) {
|
|
17
|
+
$(!0), C(null);
|
|
18
|
+
try {
|
|
19
|
+
let c;
|
|
20
|
+
if (u?.isAuthenticated())
|
|
21
|
+
c = await u.fetchWithAuth(
|
|
22
|
+
`/admin/products/${r}/variations`
|
|
23
|
+
);
|
|
24
|
+
else {
|
|
25
|
+
const s = { "Content-Type": "application/json" };
|
|
26
|
+
v && (s["X-API-Key"] = v);
|
|
27
|
+
const l = await fetch(`${p}/admin/products/${r}/variations`, {
|
|
28
|
+
headers: s
|
|
29
|
+
});
|
|
30
|
+
if (!l.ok)
|
|
31
|
+
throw new Error(`Failed to fetch variations: ${l.status}`);
|
|
32
|
+
c = await l.json();
|
|
33
|
+
}
|
|
34
|
+
c.variationConfig || (c.variationConfig = { variationTypes: [] }), c.variants || (c.variants = []), T(c);
|
|
35
|
+
} catch (c) {
|
|
36
|
+
const s = c instanceof Error ? c.message : "Failed to fetch variations";
|
|
37
|
+
C(s), T({
|
|
38
|
+
productId: r,
|
|
39
|
+
variationConfig: { variationTypes: [] },
|
|
40
|
+
variants: []
|
|
41
|
+
});
|
|
42
|
+
} finally {
|
|
43
|
+
$(!1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, [p, r, v, u]), F = B(
|
|
47
|
+
async (c) => {
|
|
48
|
+
if (!r) return null;
|
|
49
|
+
U(!0), C(null);
|
|
50
|
+
try {
|
|
51
|
+
let s;
|
|
52
|
+
if (u?.isAuthenticated())
|
|
53
|
+
s = await u.fetchWithAuth(
|
|
54
|
+
`/admin/products/${r}/variations`,
|
|
55
|
+
{
|
|
56
|
+
method: "PUT",
|
|
57
|
+
body: JSON.stringify(c)
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
else {
|
|
61
|
+
const l = { "Content-Type": "application/json" };
|
|
62
|
+
v && (l["X-API-Key"] = v);
|
|
63
|
+
const k = await fetch(`${p}/admin/products/${r}/variations`, {
|
|
64
|
+
method: "PUT",
|
|
65
|
+
headers: l,
|
|
66
|
+
body: JSON.stringify(c)
|
|
67
|
+
});
|
|
68
|
+
if (!k.ok)
|
|
69
|
+
throw new Error(`Failed to save variations: ${k.status}`);
|
|
70
|
+
s = await k.json();
|
|
71
|
+
}
|
|
72
|
+
return T({
|
|
73
|
+
productId: r,
|
|
74
|
+
variationConfig: s.variationConfig,
|
|
75
|
+
variants: s.variants
|
|
76
|
+
}), { variantsCreated: s.variantsCreated };
|
|
77
|
+
} catch (s) {
|
|
78
|
+
const l = s instanceof Error ? s.message : "Failed to save variations";
|
|
79
|
+
return C(l), null;
|
|
80
|
+
} finally {
|
|
81
|
+
U(!1);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
[p, r, v, u]
|
|
85
|
+
), f = B(
|
|
86
|
+
async (c) => {
|
|
87
|
+
if (!r || c.length === 0) return !1;
|
|
88
|
+
U(!0), C(null);
|
|
89
|
+
try {
|
|
90
|
+
if (u?.isAuthenticated())
|
|
91
|
+
await u.fetchWithAuth(
|
|
92
|
+
`/admin/products/${r}/variants/inventory`,
|
|
93
|
+
{
|
|
94
|
+
method: "PUT",
|
|
95
|
+
body: JSON.stringify({ updates: c })
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
else {
|
|
99
|
+
const s = { "Content-Type": "application/json" };
|
|
100
|
+
v && (s["X-API-Key"] = v);
|
|
101
|
+
const l = await fetch(`${p}/admin/products/${r}/variants/inventory`, {
|
|
102
|
+
method: "PUT",
|
|
103
|
+
headers: s,
|
|
104
|
+
body: JSON.stringify({ updates: c })
|
|
105
|
+
});
|
|
106
|
+
if (!l.ok)
|
|
107
|
+
throw new Error(`Failed to update inventory: ${l.status}`);
|
|
108
|
+
}
|
|
109
|
+
if (g) {
|
|
110
|
+
const s = new Map(c.map((l) => [l.variantId, l]));
|
|
111
|
+
T({
|
|
112
|
+
...g,
|
|
113
|
+
variants: g.variants.map((l) => {
|
|
114
|
+
const k = s.get(l.id);
|
|
115
|
+
return k ? {
|
|
116
|
+
...l,
|
|
117
|
+
inventoryQuantity: k.inventoryQuantity,
|
|
118
|
+
inventoryStatus: k.inventoryStatus ?? l.inventoryStatus
|
|
119
|
+
} : l;
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return !0;
|
|
124
|
+
} catch (s) {
|
|
125
|
+
const l = s instanceof Error ? s.message : "Failed to update inventory";
|
|
126
|
+
return C(l), !1;
|
|
127
|
+
} finally {
|
|
128
|
+
U(!1);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
[p, r, v, u, g]
|
|
132
|
+
);
|
|
133
|
+
return {
|
|
134
|
+
data: g,
|
|
135
|
+
isLoading: A,
|
|
136
|
+
error: w,
|
|
137
|
+
fetch: I,
|
|
138
|
+
save: F,
|
|
139
|
+
bulkUpdateInventory: f,
|
|
140
|
+
isSaving: _
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function be() {
|
|
144
|
+
return `var_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
145
|
+
}
|
|
146
|
+
function we({
|
|
147
|
+
value: p,
|
|
148
|
+
onChange: r,
|
|
149
|
+
maxTypes: v = 5,
|
|
150
|
+
maxValuesPerType: u = 20,
|
|
151
|
+
disabled: g = !1
|
|
152
|
+
}) {
|
|
153
|
+
const [T, A] = S(null), [$, _] = S(""), [U, w] = S({}), C = p.variationTypes, I = B(() => {
|
|
154
|
+
if (!$.trim() || C.length >= v) return;
|
|
155
|
+
const y = {
|
|
156
|
+
id: be(),
|
|
157
|
+
name: $.trim(),
|
|
158
|
+
displayOrder: C.length,
|
|
159
|
+
values: []
|
|
160
|
+
};
|
|
161
|
+
r({
|
|
162
|
+
variationTypes: [...C, y]
|
|
163
|
+
}), _(""), A(y.id);
|
|
164
|
+
}, [$, C, v, r]), F = B(
|
|
165
|
+
(y) => {
|
|
166
|
+
r({
|
|
167
|
+
variationTypes: C.filter((D) => D.id !== y).map((D, N) => ({ ...D, displayOrder: N }))
|
|
168
|
+
}), T === y && A(null);
|
|
169
|
+
},
|
|
170
|
+
[C, r, T]
|
|
171
|
+
), f = B(
|
|
172
|
+
(y, D) => {
|
|
173
|
+
r({
|
|
174
|
+
variationTypes: C.map(
|
|
175
|
+
(N) => N.id === y ? { ...N, name: D } : N
|
|
176
|
+
)
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
[C, r]
|
|
180
|
+
), c = B(
|
|
181
|
+
(y, D) => {
|
|
182
|
+
const N = C.findIndex((x) => x.id === y);
|
|
183
|
+
if (N === -1 || D === "up" && N === 0 || D === "down" && N === C.length - 1) return;
|
|
184
|
+
const i = [...C], h = D === "up" ? N - 1 : N + 1;
|
|
185
|
+
[i[N], i[h]] = [i[h], i[N]], r({
|
|
186
|
+
variationTypes: i.map((x, d) => ({ ...x, displayOrder: d }))
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
[C, r]
|
|
190
|
+
), s = B(
|
|
191
|
+
(y) => {
|
|
192
|
+
const D = (U[y] || "").trim();
|
|
193
|
+
if (!D) return;
|
|
194
|
+
const N = C.find((h) => h.id === y);
|
|
195
|
+
if (!N || N.values.length >= u) return;
|
|
196
|
+
const i = {
|
|
197
|
+
id: be(),
|
|
198
|
+
label: D
|
|
199
|
+
};
|
|
200
|
+
r({
|
|
201
|
+
variationTypes: C.map(
|
|
202
|
+
(h) => h.id === y ? { ...h, values: [...h.values, i] } : h
|
|
203
|
+
)
|
|
204
|
+
}), w((h) => ({ ...h, [y]: "" }));
|
|
205
|
+
},
|
|
206
|
+
[C, U, u, r]
|
|
207
|
+
), l = B(
|
|
208
|
+
(y, D) => {
|
|
209
|
+
r({
|
|
210
|
+
variationTypes: C.map(
|
|
211
|
+
(N) => N.id === y ? { ...N, values: N.values.filter((i) => i.id !== D) } : N
|
|
212
|
+
)
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
[C, r]
|
|
216
|
+
), k = B(
|
|
217
|
+
(y, D, N) => {
|
|
218
|
+
r({
|
|
219
|
+
variationTypes: C.map(
|
|
220
|
+
(i) => i.id === y ? {
|
|
221
|
+
...i,
|
|
222
|
+
values: i.values.map(
|
|
223
|
+
(h) => h.id === D ? { ...h, label: N } : h
|
|
224
|
+
)
|
|
225
|
+
} : i
|
|
226
|
+
)
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
[C, r]
|
|
230
|
+
);
|
|
231
|
+
return /* @__PURE__ */ t("div", { className: "cedros-admin__variation-editor", children: [
|
|
232
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variation-editor-header", children: [
|
|
233
|
+
/* @__PURE__ */ e("h4", { className: "cedros-admin__field-label", style: { marginBottom: 0 }, children: "Variation Types" }),
|
|
234
|
+
/* @__PURE__ */ t("span", { style: { fontSize: 12, opacity: 0.7 }, children: [
|
|
235
|
+
C.length,
|
|
236
|
+
"/",
|
|
237
|
+
v,
|
|
238
|
+
" types"
|
|
239
|
+
] })
|
|
240
|
+
] }),
|
|
241
|
+
C.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__variation-empty", children: 'No variation types defined. Add types like "Size" or "Color" to create product variants.' }) : /* @__PURE__ */ e("div", { className: "cedros-admin__variation-type-list", children: C.map((y, D) => /* @__PURE__ */ t("div", { className: "cedros-admin__variation-type-item", children: [
|
|
242
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variation-type-header", children: [
|
|
243
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variation-type-controls", children: [
|
|
244
|
+
/* @__PURE__ */ e(
|
|
245
|
+
"button",
|
|
246
|
+
{
|
|
247
|
+
type: "button",
|
|
248
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",
|
|
249
|
+
onClick: () => c(y.id, "up"),
|
|
250
|
+
disabled: g || D === 0,
|
|
251
|
+
title: "Move up",
|
|
252
|
+
children: L.arrowUp
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
/* @__PURE__ */ e(
|
|
256
|
+
"button",
|
|
257
|
+
{
|
|
258
|
+
type: "button",
|
|
259
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",
|
|
260
|
+
onClick: () => c(y.id, "down"),
|
|
261
|
+
disabled: g || D === C.length - 1,
|
|
262
|
+
title: "Move down",
|
|
263
|
+
children: L.arrowDown
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
] }),
|
|
267
|
+
/* @__PURE__ */ e(
|
|
268
|
+
"input",
|
|
269
|
+
{
|
|
270
|
+
type: "text",
|
|
271
|
+
className: "cedros-admin__input cedros-admin__variation-type-name",
|
|
272
|
+
value: y.name,
|
|
273
|
+
onChange: (N) => f(y.id, N.target.value),
|
|
274
|
+
disabled: g,
|
|
275
|
+
placeholder: "Type name"
|
|
276
|
+
}
|
|
277
|
+
),
|
|
278
|
+
/* @__PURE__ */ t("span", { className: "cedros-admin__variation-value-count", children: [
|
|
279
|
+
y.values.length,
|
|
280
|
+
" values"
|
|
281
|
+
] }),
|
|
282
|
+
/* @__PURE__ */ e(
|
|
283
|
+
"button",
|
|
284
|
+
{
|
|
285
|
+
type: "button",
|
|
286
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
287
|
+
onClick: () => A(
|
|
288
|
+
T === y.id ? null : y.id
|
|
289
|
+
),
|
|
290
|
+
children: T === y.id ? "Collapse" : "Edit values"
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
/* @__PURE__ */ e(
|
|
294
|
+
"button",
|
|
295
|
+
{
|
|
296
|
+
type: "button",
|
|
297
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--danger",
|
|
298
|
+
onClick: () => F(y.id),
|
|
299
|
+
disabled: g,
|
|
300
|
+
title: "Remove type",
|
|
301
|
+
children: L.delete
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
] }),
|
|
305
|
+
T === y.id && /* @__PURE__ */ t("div", { className: "cedros-admin__variation-values", children: [
|
|
306
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variation-values-header", children: [
|
|
307
|
+
/* @__PURE__ */ t("span", { style: { fontSize: 12, fontWeight: 600 }, children: [
|
|
308
|
+
'Values for "',
|
|
309
|
+
y.name,
|
|
310
|
+
'"'
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ t("span", { style: { fontSize: 11, opacity: 0.7 }, children: [
|
|
313
|
+
y.values.length,
|
|
314
|
+
"/",
|
|
315
|
+
u
|
|
316
|
+
] })
|
|
317
|
+
] }),
|
|
318
|
+
y.values.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__variation-empty", style: { padding: "8px 0" }, children: 'No values yet. Add values like "Small", "Medium", "Large".' }) : /* @__PURE__ */ e("div", { className: "cedros-admin__variation-value-list", children: y.values.map((N) => /* @__PURE__ */ t("div", { className: "cedros-admin__variation-value-item", children: [
|
|
319
|
+
/* @__PURE__ */ e(
|
|
320
|
+
"input",
|
|
321
|
+
{
|
|
322
|
+
type: "text",
|
|
323
|
+
className: "cedros-admin__input cedros-admin__input--sm",
|
|
324
|
+
value: N.label,
|
|
325
|
+
onChange: (i) => k(y.id, N.id, i.target.value),
|
|
326
|
+
disabled: g
|
|
327
|
+
}
|
|
328
|
+
),
|
|
329
|
+
/* @__PURE__ */ e(
|
|
330
|
+
"button",
|
|
331
|
+
{
|
|
332
|
+
type: "button",
|
|
333
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",
|
|
334
|
+
onClick: () => l(y.id, N.id),
|
|
335
|
+
disabled: g,
|
|
336
|
+
title: "Remove value",
|
|
337
|
+
children: L.close
|
|
338
|
+
}
|
|
339
|
+
)
|
|
340
|
+
] }, N.id)) }),
|
|
341
|
+
y.values.length < u && /* @__PURE__ */ t("div", { className: "cedros-admin__variation-add-value", children: [
|
|
342
|
+
/* @__PURE__ */ e(
|
|
343
|
+
"input",
|
|
344
|
+
{
|
|
345
|
+
type: "text",
|
|
346
|
+
className: "cedros-admin__input cedros-admin__input--sm",
|
|
347
|
+
value: U[y.id] || "",
|
|
348
|
+
onChange: (N) => w((i) => ({
|
|
349
|
+
...i,
|
|
350
|
+
[y.id]: N.target.value
|
|
351
|
+
})),
|
|
352
|
+
placeholder: "Add value...",
|
|
353
|
+
disabled: g,
|
|
354
|
+
onKeyDown: (N) => {
|
|
355
|
+
N.key === "Enter" && (N.preventDefault(), s(y.id));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
),
|
|
359
|
+
/* @__PURE__ */ e(
|
|
360
|
+
"button",
|
|
361
|
+
{
|
|
362
|
+
type: "button",
|
|
363
|
+
className: "cedros-admin__button cedros-admin__button--secondary cedros-admin__button--sm",
|
|
364
|
+
onClick: () => s(y.id),
|
|
365
|
+
disabled: g || !U[y.id]?.trim(),
|
|
366
|
+
children: "Add"
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] })
|
|
370
|
+
] })
|
|
371
|
+
] }, y.id)) }),
|
|
372
|
+
C.length < v && /* @__PURE__ */ t("div", { className: "cedros-admin__variation-add-type", children: [
|
|
373
|
+
/* @__PURE__ */ e(
|
|
374
|
+
"input",
|
|
375
|
+
{
|
|
376
|
+
type: "text",
|
|
377
|
+
className: "cedros-admin__input",
|
|
378
|
+
value: $,
|
|
379
|
+
onChange: (y) => _(y.target.value),
|
|
380
|
+
placeholder: "New variation type (e.g., Size, Color)",
|
|
381
|
+
disabled: g,
|
|
382
|
+
onKeyDown: (y) => {
|
|
383
|
+
y.key === "Enter" && (y.preventDefault(), I());
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
),
|
|
387
|
+
/* @__PURE__ */ e(
|
|
388
|
+
"button",
|
|
389
|
+
{
|
|
390
|
+
type: "button",
|
|
391
|
+
className: "cedros-admin__button cedros-admin__button--secondary",
|
|
392
|
+
onClick: I,
|
|
393
|
+
disabled: g || !$.trim(),
|
|
394
|
+
children: "Add Type"
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
] })
|
|
398
|
+
] });
|
|
399
|
+
}
|
|
400
|
+
function ve() {
|
|
401
|
+
return `variant_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
402
|
+
}
|
|
403
|
+
function Ie(p) {
|
|
404
|
+
if (p.length === 0) return [];
|
|
405
|
+
const r = [...p].sort((u, g) => u.displayOrder - g.displayOrder), v = (u, g) => {
|
|
406
|
+
if (u >= r.length) {
|
|
407
|
+
const $ = g.valueIds.sort().join("|"), _ = Object.values(g.options).join(" / ");
|
|
408
|
+
return [
|
|
409
|
+
{
|
|
410
|
+
key: $,
|
|
411
|
+
title: _,
|
|
412
|
+
optionValueIds: [...g.valueIds],
|
|
413
|
+
options: { ...g.options }
|
|
414
|
+
}
|
|
415
|
+
];
|
|
416
|
+
}
|
|
417
|
+
const T = r[u], A = [];
|
|
418
|
+
for (const $ of T.values)
|
|
419
|
+
A.push(
|
|
420
|
+
...v(u + 1, {
|
|
421
|
+
valueIds: [...g.valueIds, $.id],
|
|
422
|
+
options: { ...g.options, [T.name]: $.label }
|
|
423
|
+
})
|
|
424
|
+
);
|
|
425
|
+
return A;
|
|
426
|
+
};
|
|
427
|
+
return v(0, { valueIds: [], options: {} });
|
|
428
|
+
}
|
|
429
|
+
function Pe(p) {
|
|
430
|
+
return p.optionValueIds?.length ? [...p.optionValueIds].sort().join("|") : Object.entries(p.options).sort(([r], [v]) => r.localeCompare(v)).map(([r, v]) => `${r}:${v}`).join("|");
|
|
431
|
+
}
|
|
432
|
+
function Te({
|
|
433
|
+
variationConfig: p,
|
|
434
|
+
variants: r,
|
|
435
|
+
onChange: v,
|
|
436
|
+
defaultPrice: u = 0,
|
|
437
|
+
currencySymbol: g = "$",
|
|
438
|
+
maxVariants: T = 100,
|
|
439
|
+
disabled: A = !1
|
|
440
|
+
}) {
|
|
441
|
+
const $ = H(
|
|
442
|
+
() => Ie(p.variationTypes),
|
|
443
|
+
[p.variationTypes]
|
|
444
|
+
), _ = H(() => {
|
|
445
|
+
const c = /* @__PURE__ */ new Map();
|
|
446
|
+
for (const s of r)
|
|
447
|
+
c.set(Pe(s), s);
|
|
448
|
+
return c;
|
|
449
|
+
}, [r]), { existingRows: U, possibleRows: w } = H(() => {
|
|
450
|
+
const c = [], s = [];
|
|
451
|
+
for (const l of $) {
|
|
452
|
+
const k = _.get(l.key);
|
|
453
|
+
k ? c.push({ combo: l, variant: k }) : s.push(l);
|
|
454
|
+
}
|
|
455
|
+
return { existingRows: c, possibleRows: s };
|
|
456
|
+
}, [$, _]), C = B(
|
|
457
|
+
(c, s) => {
|
|
458
|
+
v(
|
|
459
|
+
r.map((l) => l.id === c ? { ...l, ...s } : l)
|
|
460
|
+
);
|
|
461
|
+
},
|
|
462
|
+
[r, v]
|
|
463
|
+
), I = B(
|
|
464
|
+
(c) => {
|
|
465
|
+
v(r.filter((s) => s.id !== c));
|
|
466
|
+
},
|
|
467
|
+
[r, v]
|
|
468
|
+
), F = B(
|
|
469
|
+
(c) => {
|
|
470
|
+
if (r.length >= T) return;
|
|
471
|
+
const s = {
|
|
472
|
+
id: ve(),
|
|
473
|
+
title: c.title,
|
|
474
|
+
options: c.options,
|
|
475
|
+
optionValueIds: c.optionValueIds,
|
|
476
|
+
price: u,
|
|
477
|
+
inventoryQuantity: 0,
|
|
478
|
+
inventoryStatus: "in_stock",
|
|
479
|
+
autoGenerated: !1
|
|
480
|
+
};
|
|
481
|
+
v([...r, s]);
|
|
482
|
+
},
|
|
483
|
+
[r, v, T, u]
|
|
484
|
+
), f = B(() => {
|
|
485
|
+
const c = T - r.length, l = w.slice(0, c).map((k) => ({
|
|
486
|
+
id: ve(),
|
|
487
|
+
title: k.title,
|
|
488
|
+
options: k.options,
|
|
489
|
+
optionValueIds: k.optionValueIds,
|
|
490
|
+
price: u,
|
|
491
|
+
inventoryQuantity: 0,
|
|
492
|
+
inventoryStatus: "in_stock",
|
|
493
|
+
autoGenerated: !0
|
|
494
|
+
}));
|
|
495
|
+
v([...r, ...l]);
|
|
496
|
+
}, [r, v, w, T, u]);
|
|
497
|
+
return p.variationTypes.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__variant-grid-empty", children: "Add variation types above to create product variants." }) : $.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__variant-grid-empty", children: "Add values to your variation types to create product variants." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__variant-grid", children: [
|
|
498
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variant-grid-header", children: [
|
|
499
|
+
/* @__PURE__ */ e("h4", { className: "cedros-admin__field-label", style: { marginBottom: 0 }, children: "Variants" }),
|
|
500
|
+
/* @__PURE__ */ t("span", { style: { fontSize: 12, opacity: 0.7 }, children: [
|
|
501
|
+
r.length,
|
|
502
|
+
"/",
|
|
503
|
+
T,
|
|
504
|
+
" variants (",
|
|
505
|
+
$.length,
|
|
506
|
+
" ",
|
|
507
|
+
"possible)"
|
|
508
|
+
] })
|
|
509
|
+
] }),
|
|
510
|
+
w.length > 0 && r.length < T && /* @__PURE__ */ t("div", { className: "cedros-admin__variant-grid-actions", children: [
|
|
511
|
+
/* @__PURE__ */ t(
|
|
512
|
+
"button",
|
|
513
|
+
{
|
|
514
|
+
type: "button",
|
|
515
|
+
className: "cedros-admin__button cedros-admin__button--secondary",
|
|
516
|
+
onClick: f,
|
|
517
|
+
disabled: A,
|
|
518
|
+
children: [
|
|
519
|
+
"Generate All (",
|
|
520
|
+
Math.min(w.length, T - r.length),
|
|
521
|
+
")"
|
|
522
|
+
]
|
|
523
|
+
}
|
|
524
|
+
),
|
|
525
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 11, opacity: 0.7 }, children: "Creates variants with default price and 0 inventory" })
|
|
526
|
+
] }),
|
|
527
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ t("table", { className: "cedros-admin__table cedros-admin__variant-table", children: [
|
|
528
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
|
|
529
|
+
/* @__PURE__ */ e("th", { children: "Variant" }),
|
|
530
|
+
/* @__PURE__ */ e("th", { style: { width: 100 }, children: "Price" }),
|
|
531
|
+
/* @__PURE__ */ e("th", { style: { width: 80 }, children: "Qty" }),
|
|
532
|
+
/* @__PURE__ */ e("th", { style: { width: 100 }, children: "SKU" }),
|
|
533
|
+
/* @__PURE__ */ e("th", { style: { width: 100 }, children: "Status" }),
|
|
534
|
+
/* @__PURE__ */ e("th", { style: { width: 80 }, children: "Actions" })
|
|
535
|
+
] }) }),
|
|
536
|
+
/* @__PURE__ */ t("tbody", { children: [
|
|
537
|
+
U.map(({ combo: c, variant: s }) => /* @__PURE__ */ t("tr", { children: [
|
|
538
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
539
|
+
/* @__PURE__ */ e("span", { style: { fontWeight: 600 }, children: c.title }),
|
|
540
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 11, opacity: 0.6 }, children: Object.entries(c.options).map(([l, k]) => `${l}: ${k}`).join(", ") })
|
|
541
|
+
] }) }),
|
|
542
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ t("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
|
|
543
|
+
/* @__PURE__ */ e("span", { children: g }),
|
|
544
|
+
/* @__PURE__ */ e(
|
|
545
|
+
"input",
|
|
546
|
+
{
|
|
547
|
+
type: "number",
|
|
548
|
+
className: "cedros-admin__input cedros-admin__input--sm",
|
|
549
|
+
value: s.price ?? "",
|
|
550
|
+
onChange: (l) => C(s.id, {
|
|
551
|
+
price: l.target.value === "" ? void 0 : parseFloat(l.target.value) || 0
|
|
552
|
+
}),
|
|
553
|
+
disabled: A,
|
|
554
|
+
min: "0",
|
|
555
|
+
step: "0.01",
|
|
556
|
+
style: { width: 70 }
|
|
557
|
+
}
|
|
558
|
+
)
|
|
559
|
+
] }) }),
|
|
560
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
|
|
561
|
+
"input",
|
|
562
|
+
{
|
|
563
|
+
type: "number",
|
|
564
|
+
className: "cedros-admin__input cedros-admin__input--sm",
|
|
565
|
+
value: s.inventoryQuantity ?? "",
|
|
566
|
+
onChange: (l) => C(s.id, {
|
|
567
|
+
inventoryQuantity: l.target.value === "" ? void 0 : parseInt(l.target.value) || 0
|
|
568
|
+
}),
|
|
569
|
+
disabled: A,
|
|
570
|
+
min: "0",
|
|
571
|
+
style: { width: 60 }
|
|
572
|
+
}
|
|
573
|
+
) }),
|
|
574
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
|
|
575
|
+
"input",
|
|
576
|
+
{
|
|
577
|
+
type: "text",
|
|
578
|
+
className: "cedros-admin__input cedros-admin__input--sm",
|
|
579
|
+
value: s.sku ?? "",
|
|
580
|
+
onChange: (l) => C(s.id, {
|
|
581
|
+
sku: l.target.value || void 0
|
|
582
|
+
}),
|
|
583
|
+
disabled: A,
|
|
584
|
+
placeholder: "SKU",
|
|
585
|
+
style: { width: 80 }
|
|
586
|
+
}
|
|
587
|
+
) }),
|
|
588
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
|
|
589
|
+
Ne,
|
|
590
|
+
{
|
|
591
|
+
value: s.inventoryStatus ?? "in_stock",
|
|
592
|
+
onChange: (l) => C(s.id, {
|
|
593
|
+
inventoryStatus: l
|
|
594
|
+
}),
|
|
595
|
+
options: [
|
|
596
|
+
{ value: "in_stock", label: "In stock" },
|
|
597
|
+
{ value: "low", label: "Low" },
|
|
598
|
+
{ value: "out_of_stock", label: "Out of stock" },
|
|
599
|
+
{ value: "backorder", label: "Backorder" }
|
|
600
|
+
],
|
|
601
|
+
disabled: A
|
|
602
|
+
}
|
|
603
|
+
) }),
|
|
604
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
|
|
605
|
+
"button",
|
|
606
|
+
{
|
|
607
|
+
type: "button",
|
|
608
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",
|
|
609
|
+
onClick: () => I(s.id),
|
|
610
|
+
disabled: A,
|
|
611
|
+
title: "Remove variant",
|
|
612
|
+
children: L.trash
|
|
613
|
+
}
|
|
614
|
+
) })
|
|
615
|
+
] }, s.id)),
|
|
616
|
+
w.length > 0 && r.length < T && /* @__PURE__ */ t(me, { children: [
|
|
617
|
+
/* @__PURE__ */ e("tr", { className: "cedros-admin__variant-separator", children: /* @__PURE__ */ e("td", { colSpan: 6, children: /* @__PURE__ */ t("span", { style: { fontSize: 11, opacity: 0.6 }, children: [
|
|
618
|
+
"Uncreated combinations (",
|
|
619
|
+
w.length,
|
|
620
|
+
")"
|
|
621
|
+
] }) }) }),
|
|
622
|
+
w.slice(0, 10).map((c) => /* @__PURE__ */ t("tr", { className: "cedros-admin__variant-possible", children: [
|
|
623
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { style: { opacity: 0.6 }, children: c.title }) }),
|
|
624
|
+
/* @__PURE__ */ e("td", { colSpan: 4, style: { opacity: 0.5 }, children: "Not created" }),
|
|
625
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
|
|
626
|
+
"button",
|
|
627
|
+
{
|
|
628
|
+
type: "button",
|
|
629
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",
|
|
630
|
+
onClick: () => F(c),
|
|
631
|
+
disabled: A,
|
|
632
|
+
title: "Create variant",
|
|
633
|
+
children: L.plus
|
|
634
|
+
}
|
|
635
|
+
) })
|
|
636
|
+
] }, c.key)),
|
|
637
|
+
w.length > 10 && /* @__PURE__ */ e("tr", { className: "cedros-admin__variant-more", children: /* @__PURE__ */ t("td", { colSpan: 6, style: { textAlign: "center", opacity: 0.6 }, children: [
|
|
638
|
+
"+",
|
|
639
|
+
w.length - 10,
|
|
640
|
+
" more combinations"
|
|
641
|
+
] }) })
|
|
642
|
+
] })
|
|
643
|
+
] })
|
|
644
|
+
] }) })
|
|
645
|
+
] });
|
|
646
|
+
}
|
|
647
|
+
function xe({
|
|
648
|
+
serverUrl: p,
|
|
649
|
+
productId: r,
|
|
650
|
+
productTitle: v,
|
|
651
|
+
defaultPrice: u = 0,
|
|
652
|
+
currencySymbol: g = "$",
|
|
653
|
+
apiKey: T,
|
|
654
|
+
authManager: A,
|
|
655
|
+
onClose: $
|
|
656
|
+
}) {
|
|
657
|
+
const {
|
|
658
|
+
data: _,
|
|
659
|
+
isLoading: U,
|
|
660
|
+
error: w,
|
|
661
|
+
fetch: C,
|
|
662
|
+
save: I,
|
|
663
|
+
isSaving: F
|
|
664
|
+
} = Ae({ serverUrl: p, productId: r, apiKey: T, authManager: A }), [f, c] = S({ variationTypes: [] }), [s, l] = S([]), [k, y] = S(!1), [D, N] = S(!1);
|
|
665
|
+
Y(() => {
|
|
666
|
+
C();
|
|
667
|
+
}, [C]), Y(() => {
|
|
668
|
+
_ && (c(_.variationConfig), l(_.variants), y(!1));
|
|
669
|
+
}, [_]);
|
|
670
|
+
const i = B((d) => {
|
|
671
|
+
c(d), y(!0), N(!1);
|
|
672
|
+
}, []), h = B((d) => {
|
|
673
|
+
l(d), y(!0), N(!1);
|
|
674
|
+
}, []), x = B(async () => {
|
|
675
|
+
const d = new Set((_?.variants ?? []).map((V) => V.id)), m = s.filter((V) => !d.has(V.id)), z = s.filter((V) => d.has(V.id)), E = (_?.variants ?? []).filter((V) => !s.some((ee) => ee.id === V.id)).map((V) => V.id);
|
|
676
|
+
await I({
|
|
677
|
+
variationConfig: f,
|
|
678
|
+
createVariants: m.map((V) => ({
|
|
679
|
+
optionValueIds: V.optionValueIds ?? [],
|
|
680
|
+
inventoryQuantity: V.inventoryQuantity,
|
|
681
|
+
sku: V.sku,
|
|
682
|
+
price: V.price
|
|
683
|
+
})),
|
|
684
|
+
updateVariants: z.map((V) => ({
|
|
685
|
+
id: V.id,
|
|
686
|
+
inventoryQuantity: V.inventoryQuantity,
|
|
687
|
+
sku: V.sku,
|
|
688
|
+
price: V.price,
|
|
689
|
+
inventoryStatus: V.inventoryStatus
|
|
690
|
+
})),
|
|
691
|
+
deleteVariantIds: E.length > 0 ? E : void 0
|
|
692
|
+
}) && (y(!1), N(!0), setTimeout(() => N(!1), 3e3));
|
|
693
|
+
}, [f, s, _?.variants, I]);
|
|
694
|
+
return U ? /* @__PURE__ */ t("div", { className: "cedros-admin__variations-editor", children: [
|
|
695
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variations-editor-header", children: [
|
|
696
|
+
/* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: v ? `Variations: ${v}` : "Product Variations" }),
|
|
697
|
+
$ && /* @__PURE__ */ e(
|
|
698
|
+
"button",
|
|
699
|
+
{
|
|
700
|
+
type: "button",
|
|
701
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
702
|
+
onClick: $,
|
|
703
|
+
children: L.close
|
|
704
|
+
}
|
|
705
|
+
)
|
|
706
|
+
] }),
|
|
707
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
|
|
708
|
+
L.loading,
|
|
709
|
+
" Loading variations..."
|
|
710
|
+
] })
|
|
711
|
+
] }) : /* @__PURE__ */ t("div", { className: "cedros-admin__variations-editor", children: [
|
|
712
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variations-editor-header", children: [
|
|
713
|
+
/* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: v ? `Variations: ${v}` : "Product Variations" }),
|
|
714
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variations-editor-actions", children: [
|
|
715
|
+
D && /* @__PURE__ */ t("span", { className: "cedros-admin__success-text", children: [
|
|
716
|
+
L.check,
|
|
717
|
+
" Saved"
|
|
718
|
+
] }),
|
|
719
|
+
k && /* @__PURE__ */ e("span", { className: "cedros-admin__unsaved-text", children: "Unsaved changes" }),
|
|
720
|
+
/* @__PURE__ */ e(
|
|
721
|
+
"button",
|
|
722
|
+
{
|
|
723
|
+
type: "button",
|
|
724
|
+
className: "cedros-admin__button cedros-admin__button--primary",
|
|
725
|
+
onClick: x,
|
|
726
|
+
disabled: F || !k,
|
|
727
|
+
children: F ? "Saving..." : "Save Changes"
|
|
728
|
+
}
|
|
729
|
+
),
|
|
730
|
+
$ && /* @__PURE__ */ e(
|
|
731
|
+
"button",
|
|
732
|
+
{
|
|
733
|
+
type: "button",
|
|
734
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
735
|
+
onClick: $,
|
|
736
|
+
children: L.close
|
|
737
|
+
}
|
|
738
|
+
)
|
|
739
|
+
] })
|
|
740
|
+
] }),
|
|
741
|
+
w && /* @__PURE__ */ e("div", { className: "cedros-admin__error-banner", children: w }),
|
|
742
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__variations-editor-content", children: [
|
|
743
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__variations-editor-section", children: /* @__PURE__ */ e(
|
|
744
|
+
we,
|
|
745
|
+
{
|
|
746
|
+
value: f,
|
|
747
|
+
onChange: i,
|
|
748
|
+
disabled: F
|
|
749
|
+
}
|
|
750
|
+
) }),
|
|
751
|
+
f.variationTypes.length > 0 && /* @__PURE__ */ e("div", { className: "cedros-admin__variations-editor-section", children: /* @__PURE__ */ e(
|
|
752
|
+
Te,
|
|
753
|
+
{
|
|
754
|
+
variationConfig: f,
|
|
755
|
+
variants: s,
|
|
756
|
+
onChange: h,
|
|
757
|
+
defaultPrice: u,
|
|
758
|
+
currencySymbol: g,
|
|
759
|
+
disabled: F
|
|
760
|
+
}
|
|
761
|
+
) })
|
|
762
|
+
] })
|
|
763
|
+
] });
|
|
764
|
+
}
|
|
765
|
+
const Ce = {
|
|
766
|
+
requireSanctionsClear: !0,
|
|
767
|
+
requireKyc: !1,
|
|
768
|
+
requireAccreditedInvestor: !1,
|
|
769
|
+
tokenGates: []
|
|
770
|
+
};
|
|
771
|
+
function Re({ value: p, onChange: r }) {
|
|
772
|
+
const [v, u] = S(p !== null), [g, T] = S(""), [A, $] = S("fungible_token"), [_, U] = S(1), w = p ?? Ce, C = () => {
|
|
773
|
+
p ? (r(null), u(!1)) : (r({ ...Ce }), u(!0));
|
|
774
|
+
}, I = (c) => {
|
|
775
|
+
r({ ...w, ...c });
|
|
776
|
+
}, F = () => {
|
|
777
|
+
if (!g.trim()) return;
|
|
778
|
+
const c = {
|
|
779
|
+
address: g.trim(),
|
|
780
|
+
gateType: A,
|
|
781
|
+
minAmount: _
|
|
782
|
+
}, s = [...w.tokenGates ?? [], c];
|
|
783
|
+
I({ tokenGates: s }), T(""), U(1);
|
|
784
|
+
}, f = (c) => {
|
|
785
|
+
const s = (w.tokenGates ?? []).filter((l, k) => k !== c);
|
|
786
|
+
I({ tokenGates: s.length > 0 ? s : [] });
|
|
787
|
+
};
|
|
788
|
+
return /* @__PURE__ */ t("div", { style: { border: "1px solid var(--cedros-admin-border, #e0e0e0)", borderRadius: "4px", padding: "0.75rem", marginTop: "0.5rem" }, children: [
|
|
789
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", fontSize: "0.9rem", fontWeight: 600, cursor: "pointer" }, children: [
|
|
790
|
+
/* @__PURE__ */ e("input", { type: "checkbox", checked: p !== null, onChange: C }),
|
|
791
|
+
"Enable compliance gates"
|
|
792
|
+
] }),
|
|
793
|
+
p !== null && v && /* @__PURE__ */ t("div", { style: { marginTop: "0.75rem", display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
794
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", fontSize: "0.85rem" }, children: [
|
|
795
|
+
/* @__PURE__ */ e(
|
|
796
|
+
"input",
|
|
797
|
+
{
|
|
798
|
+
type: "checkbox",
|
|
799
|
+
checked: w.requireSanctionsClear,
|
|
800
|
+
onChange: (c) => I({ requireSanctionsClear: c.target.checked })
|
|
801
|
+
}
|
|
802
|
+
),
|
|
803
|
+
"Require sanctions clearance"
|
|
804
|
+
] }),
|
|
805
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", fontSize: "0.85rem" }, children: [
|
|
806
|
+
/* @__PURE__ */ e(
|
|
807
|
+
"input",
|
|
808
|
+
{
|
|
809
|
+
type: "checkbox",
|
|
810
|
+
checked: w.requireKyc,
|
|
811
|
+
onChange: (c) => I({ requireKyc: c.target.checked })
|
|
812
|
+
}
|
|
813
|
+
),
|
|
814
|
+
"Require KYC verification"
|
|
815
|
+
] }),
|
|
816
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", fontSize: "0.85rem" }, children: [
|
|
817
|
+
/* @__PURE__ */ e(
|
|
818
|
+
"input",
|
|
819
|
+
{
|
|
820
|
+
type: "checkbox",
|
|
821
|
+
checked: w.requireAccreditedInvestor,
|
|
822
|
+
onChange: (c) => I({ requireAccreditedInvestor: c.target.checked })
|
|
823
|
+
}
|
|
824
|
+
),
|
|
825
|
+
"Require accredited investor status"
|
|
826
|
+
] }),
|
|
827
|
+
/* @__PURE__ */ t("div", { style: { marginTop: "0.5rem" }, children: [
|
|
828
|
+
/* @__PURE__ */ e("span", { style: { fontSize: "0.85rem", fontWeight: 600 }, children: "Token Gates" }),
|
|
829
|
+
(w.tokenGates ?? []).length > 0 && /* @__PURE__ */ e("div", { style: { marginTop: "0.25rem" }, children: (w.tokenGates ?? []).map((c, s) => /* @__PURE__ */ t("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem", fontSize: "0.8rem", padding: "0.25rem 0" }, children: [
|
|
830
|
+
/* @__PURE__ */ t("code", { style: { fontSize: "0.75rem" }, children: [
|
|
831
|
+
c.address.slice(0, 8),
|
|
832
|
+
"..."
|
|
833
|
+
] }),
|
|
834
|
+
/* @__PURE__ */ e("span", { className: "cedros-admin__badge cedros-admin__badge--muted", children: c.gateType === "fungible_token" ? "Fungible" : "NFT" }),
|
|
835
|
+
/* @__PURE__ */ t("span", { children: [
|
|
836
|
+
"min: ",
|
|
837
|
+
c.minAmount
|
|
838
|
+
] }),
|
|
839
|
+
/* @__PURE__ */ e(
|
|
840
|
+
"button",
|
|
841
|
+
{
|
|
842
|
+
type: "button",
|
|
843
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
844
|
+
onClick: () => f(s),
|
|
845
|
+
style: { padding: "0 0.25rem" },
|
|
846
|
+
children: "×"
|
|
847
|
+
}
|
|
848
|
+
)
|
|
849
|
+
] }, s)) }),
|
|
850
|
+
/* @__PURE__ */ t("div", { style: { display: "flex", gap: "0.5rem", alignItems: "flex-end", marginTop: "0.25rem", flexWrap: "wrap" }, children: [
|
|
851
|
+
/* @__PURE__ */ e(
|
|
852
|
+
"input",
|
|
853
|
+
{
|
|
854
|
+
type: "text",
|
|
855
|
+
className: "cedros-admin__input",
|
|
856
|
+
placeholder: "Mint or collection address",
|
|
857
|
+
value: g,
|
|
858
|
+
onChange: (c) => T(c.target.value),
|
|
859
|
+
style: { flex: 1, minWidth: "200px", fontSize: "0.8rem" }
|
|
860
|
+
}
|
|
861
|
+
),
|
|
862
|
+
/* @__PURE__ */ t(
|
|
863
|
+
"select",
|
|
864
|
+
{
|
|
865
|
+
className: "cedros-admin__input",
|
|
866
|
+
value: A,
|
|
867
|
+
onChange: (c) => $(c.target.value),
|
|
868
|
+
style: { width: "auto", fontSize: "0.8rem" },
|
|
869
|
+
children: [
|
|
870
|
+
/* @__PURE__ */ e("option", { value: "fungible_token", children: "Fungible" }),
|
|
871
|
+
/* @__PURE__ */ e("option", { value: "nft_collection", children: "NFT" })
|
|
872
|
+
]
|
|
873
|
+
}
|
|
874
|
+
),
|
|
875
|
+
/* @__PURE__ */ e(
|
|
876
|
+
"input",
|
|
877
|
+
{
|
|
878
|
+
type: "number",
|
|
879
|
+
className: "cedros-admin__input",
|
|
880
|
+
min: 1,
|
|
881
|
+
value: _,
|
|
882
|
+
onChange: (c) => U(Number(c.target.value)),
|
|
883
|
+
style: { width: "80px", fontSize: "0.8rem" }
|
|
884
|
+
}
|
|
885
|
+
),
|
|
886
|
+
/* @__PURE__ */ e(
|
|
887
|
+
"button",
|
|
888
|
+
{
|
|
889
|
+
type: "button",
|
|
890
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
891
|
+
onClick: F,
|
|
892
|
+
disabled: !g.trim(),
|
|
893
|
+
children: "Add Gate"
|
|
894
|
+
}
|
|
895
|
+
)
|
|
896
|
+
] })
|
|
897
|
+
] })
|
|
898
|
+
] })
|
|
899
|
+
] });
|
|
900
|
+
}
|
|
901
|
+
function $e({
|
|
902
|
+
serverUrl: p,
|
|
903
|
+
productId: r,
|
|
904
|
+
productTitle: v,
|
|
905
|
+
apiKey: u,
|
|
906
|
+
authManager: g,
|
|
907
|
+
onClose: T
|
|
908
|
+
}) {
|
|
909
|
+
const [A, $] = S(null), [_, U] = S(!0), [w, C] = S(null), I = B(async () => {
|
|
910
|
+
U(!0), C(null);
|
|
911
|
+
try {
|
|
912
|
+
const F = `/paywall/v1/products/${encodeURIComponent(r)}/nft-metadata`;
|
|
913
|
+
let f;
|
|
914
|
+
if (g?.isAuthenticated())
|
|
915
|
+
f = await g.fetchWithAuth(F);
|
|
916
|
+
else {
|
|
917
|
+
const c = { "Content-Type": "application/json" };
|
|
918
|
+
u && (c["X-API-Key"] = u);
|
|
919
|
+
const s = await fetch(`${p}${F}`, { headers: c });
|
|
920
|
+
if (!s.ok) throw new Error(`Request failed: ${s.status}`);
|
|
921
|
+
f = await s.json();
|
|
922
|
+
}
|
|
923
|
+
$(f);
|
|
924
|
+
} catch {
|
|
925
|
+
C("Failed to load NFT metadata. Ensure this product exists and the server is running.");
|
|
926
|
+
} finally {
|
|
927
|
+
U(!1);
|
|
928
|
+
}
|
|
929
|
+
}, [p, r, u, g]);
|
|
930
|
+
return Y(() => {
|
|
931
|
+
I();
|
|
932
|
+
}, [I]), /* @__PURE__ */ t("div", { children: [
|
|
933
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", style: { marginBottom: "1rem" }, children: [
|
|
934
|
+
/* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", style: { fontSize: "1rem" }, children: [
|
|
935
|
+
"NFT Metadata — ",
|
|
936
|
+
v
|
|
937
|
+
] }),
|
|
938
|
+
/* @__PURE__ */ t(
|
|
939
|
+
"button",
|
|
940
|
+
{
|
|
941
|
+
type: "button",
|
|
942
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
943
|
+
onClick: T,
|
|
944
|
+
children: [
|
|
945
|
+
L.close,
|
|
946
|
+
" Close"
|
|
947
|
+
]
|
|
948
|
+
}
|
|
949
|
+
)
|
|
950
|
+
] }),
|
|
951
|
+
/* @__PURE__ */ e(re, { message: w, onRetry: I }),
|
|
952
|
+
_ ? /* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
|
|
953
|
+
L.loading,
|
|
954
|
+
" Loading metadata..."
|
|
955
|
+
] }) : A ? /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
956
|
+
/* @__PURE__ */ t("div", { style: {
|
|
957
|
+
display: "flex",
|
|
958
|
+
gap: "1rem",
|
|
959
|
+
padding: "1rem",
|
|
960
|
+
border: "1px solid var(--cedros-admin-border, #e0e0e0)",
|
|
961
|
+
borderRadius: "8px"
|
|
962
|
+
}, children: [
|
|
963
|
+
A.image && /* @__PURE__ */ e(
|
|
964
|
+
"img",
|
|
965
|
+
{
|
|
966
|
+
src: A.image,
|
|
967
|
+
alt: A.name,
|
|
968
|
+
style: { width: 120, height: 120, borderRadius: 8, objectFit: "cover", flexShrink: 0 }
|
|
969
|
+
}
|
|
970
|
+
),
|
|
971
|
+
/* @__PURE__ */ t("div", { style: { flex: 1 }, children: [
|
|
972
|
+
/* @__PURE__ */ e("h4", { style: { margin: "0 0 0.25rem", fontSize: "1rem", fontWeight: 600 }, children: A.name }),
|
|
973
|
+
/* @__PURE__ */ e("p", { style: { margin: "0 0 0.5rem", fontSize: "0.85rem", color: "var(--cedros-admin-text-muted, #888)" }, children: A.description }),
|
|
974
|
+
A.external_url && /* @__PURE__ */ t("p", { style: { margin: "0 0 0.5rem", fontSize: "0.8rem" }, children: [
|
|
975
|
+
/* @__PURE__ */ e("strong", { children: "URL:" }),
|
|
976
|
+
" ",
|
|
977
|
+
/* @__PURE__ */ e("code", { children: A.external_url })
|
|
978
|
+
] }),
|
|
979
|
+
A.attributes.length > 0 && /* @__PURE__ */ e("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.5rem" }, children: A.attributes.map((F) => /* @__PURE__ */ t(
|
|
980
|
+
"div",
|
|
981
|
+
{
|
|
982
|
+
style: {
|
|
983
|
+
padding: "0.25rem 0.5rem",
|
|
984
|
+
border: "1px solid var(--cedros-admin-border, #e0e0e0)",
|
|
985
|
+
borderRadius: "4px",
|
|
986
|
+
fontSize: "0.8rem"
|
|
987
|
+
},
|
|
988
|
+
children: [
|
|
989
|
+
/* @__PURE__ */ t("span", { style: { color: "var(--cedros-admin-text-muted, #888)" }, children: [
|
|
990
|
+
F.trait_type,
|
|
991
|
+
":"
|
|
992
|
+
] }),
|
|
993
|
+
" ",
|
|
994
|
+
/* @__PURE__ */ e("strong", { children: F.value })
|
|
995
|
+
]
|
|
996
|
+
},
|
|
997
|
+
F.trait_type
|
|
998
|
+
)) })
|
|
999
|
+
] })
|
|
1000
|
+
] }),
|
|
1001
|
+
/* @__PURE__ */ t("div", { children: [
|
|
1002
|
+
/* @__PURE__ */ e("h4", { style: { margin: "0 0 0.5rem", fontSize: "0.85rem", fontWeight: 600 }, children: "Raw JSON (stored on-chain URI)" }),
|
|
1003
|
+
/* @__PURE__ */ e("pre", { style: {
|
|
1004
|
+
background: "var(--cedros-admin-bg-muted, #f5f5f5)",
|
|
1005
|
+
border: "1px solid var(--cedros-admin-border, #e0e0e0)",
|
|
1006
|
+
borderRadius: "4px",
|
|
1007
|
+
padding: "0.75rem",
|
|
1008
|
+
fontSize: "0.8rem",
|
|
1009
|
+
overflow: "auto",
|
|
1010
|
+
maxHeight: "300px"
|
|
1011
|
+
}, children: JSON.stringify(A, null, 2) })
|
|
1012
|
+
] })
|
|
1013
|
+
] }) : null
|
|
1014
|
+
] });
|
|
1015
|
+
}
|
|
1016
|
+
function qe({ serverUrl: p, apiKey: r, pageSize: v = 20, authManager: u }) {
|
|
1017
|
+
const [g, T] = S([]), [A, $] = S(!0), [_, U] = S(!1), [w, C] = S(!1), [I, F] = S(null), [f, c] = S(null), [s, l] = S(null), [k, y] = S(null), [D, N] = S(null), [i, h] = S({
|
|
1018
|
+
id: "",
|
|
1019
|
+
title: "",
|
|
1020
|
+
slug: "",
|
|
1021
|
+
imageUrl: "",
|
|
1022
|
+
description: "",
|
|
1023
|
+
productType: "one_time",
|
|
1024
|
+
priceUsd: "",
|
|
1025
|
+
fiatCurrency: "usd",
|
|
1026
|
+
cryptoToken: "USDC",
|
|
1027
|
+
inventoryStatus: "in_stock",
|
|
1028
|
+
compareAtUsd: "",
|
|
1029
|
+
tagsCsv: "",
|
|
1030
|
+
categoryIdsCsv: "",
|
|
1031
|
+
checkoutEmail: "required",
|
|
1032
|
+
checkoutName: "optional",
|
|
1033
|
+
checkoutPhone: "none",
|
|
1034
|
+
checkoutShippingAddress: !1,
|
|
1035
|
+
checkoutBillingAddress: !1,
|
|
1036
|
+
fulfillmentType: "shipping",
|
|
1037
|
+
storePolicyFulfillment: "physical_goods",
|
|
1038
|
+
storeManagedKind: "none",
|
|
1039
|
+
appleProductId: "",
|
|
1040
|
+
googleProductId: "",
|
|
1041
|
+
googlePackageName: "",
|
|
1042
|
+
googleBasePlanId: "",
|
|
1043
|
+
googleOfferId: "",
|
|
1044
|
+
fulfillmentNotes: "",
|
|
1045
|
+
shippingCountriesCsv: "",
|
|
1046
|
+
inventoryQuantity: "",
|
|
1047
|
+
giftCardConfig: null,
|
|
1048
|
+
tokenizedAssetConfig: null,
|
|
1049
|
+
complianceRequirements: null
|
|
1050
|
+
}), x = (n) => {
|
|
1051
|
+
const a = n.tagsCsv.split(",").map((Z) => Z.trim()).filter(Boolean), R = n.categoryIdsCsv.split(",").map((Z) => Z.trim()).filter(Boolean), X = {
|
|
1052
|
+
email: n.checkoutEmail,
|
|
1053
|
+
name: n.checkoutName,
|
|
1054
|
+
phone: n.checkoutPhone,
|
|
1055
|
+
shippingAddress: n.checkoutShippingAddress,
|
|
1056
|
+
billingAddress: n.checkoutBillingAddress
|
|
1057
|
+
}, j = n.fulfillmentType === "shipping" ? "physical" : "digital", q = {
|
|
1058
|
+
title: n.title,
|
|
1059
|
+
slug: n.slug || n.id,
|
|
1060
|
+
shipping_profile: j,
|
|
1061
|
+
inventory_status: n.inventoryStatus,
|
|
1062
|
+
checkout_requirements: JSON.stringify(X),
|
|
1063
|
+
fulfillment_type: n.fulfillmentType,
|
|
1064
|
+
store_policy_fulfillment_type: n.storePolicyFulfillment
|
|
1065
|
+
};
|
|
1066
|
+
n.imageUrl && (q.image_url = n.imageUrl);
|
|
1067
|
+
const J = n.compareAtUsd ? Math.round(Number(n.compareAtUsd) * 100) : 0;
|
|
1068
|
+
J && (q.compare_at_amount_cents = String(J)), a.length && (q.tags = JSON.stringify(a)), R.length && (q.category_ids = JSON.stringify(R)), n.fulfillmentNotes && (q.fulfillment_notes = n.fulfillmentNotes);
|
|
1069
|
+
const O = n.shippingCountriesCsv.split(",").map((Z) => Z.trim().toUpperCase()).filter(Boolean);
|
|
1070
|
+
return O.length && (q.shippingCountries = O.join(","), q.shipping_countries = O.join(",")), q;
|
|
1071
|
+
}, [d, m] = S([]), z = (n) => n.title || n.metadata?.title || n.description || n.id, E = (n) => n.imageUrl || n.images?.[0]?.url || n.metadata?.image_url, M = (n) => {
|
|
1072
|
+
const a = n.metadata?.store_policy_fulfillment_type;
|
|
1073
|
+
if (a === "digital_in_app" || a === "physical_goods" || a === "real_world_service" || a === "reader_content" || a === "other")
|
|
1074
|
+
return a;
|
|
1075
|
+
switch (n.fulfillment?.type) {
|
|
1076
|
+
case "shipping":
|
|
1077
|
+
return "physical_goods";
|
|
1078
|
+
case "service":
|
|
1079
|
+
return "real_world_service";
|
|
1080
|
+
case "digital_download":
|
|
1081
|
+
return "digital_in_app";
|
|
1082
|
+
default:
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
}, V = (n) => {
|
|
1086
|
+
switch (n) {
|
|
1087
|
+
case "digital_in_app":
|
|
1088
|
+
return "Digital in-app";
|
|
1089
|
+
case "physical_goods":
|
|
1090
|
+
return "Physical goods";
|
|
1091
|
+
case "real_world_service":
|
|
1092
|
+
return "Real-world service";
|
|
1093
|
+
case "reader_content":
|
|
1094
|
+
return "Reader content";
|
|
1095
|
+
case "other":
|
|
1096
|
+
return "Other";
|
|
1097
|
+
default:
|
|
1098
|
+
return "Not set";
|
|
1099
|
+
}
|
|
1100
|
+
}, ee = (n) => {
|
|
1101
|
+
switch (n) {
|
|
1102
|
+
case "consumable":
|
|
1103
|
+
return "Consumable";
|
|
1104
|
+
case "non_consumable":
|
|
1105
|
+
return "Non-consumable";
|
|
1106
|
+
case "auto_renewable_subscription":
|
|
1107
|
+
return "Auto-renewing subscription";
|
|
1108
|
+
default:
|
|
1109
|
+
return "External billing only";
|
|
1110
|
+
}
|
|
1111
|
+
}, ge = (n) => {
|
|
1112
|
+
if (n.storeManagedKind === "none")
|
|
1113
|
+
return;
|
|
1114
|
+
const a = n.appleProductId.trim(), R = n.googleProductId.trim(), X = n.googlePackageName.trim(), j = n.googleBasePlanId.trim(), q = n.googleOfferId.trim();
|
|
1115
|
+
if (!(!a && !R))
|
|
1116
|
+
return {
|
|
1117
|
+
kind: n.storeManagedKind,
|
|
1118
|
+
apple: a ? {
|
|
1119
|
+
productId: a
|
|
1120
|
+
} : void 0,
|
|
1121
|
+
google: R ? {
|
|
1122
|
+
productId: R,
|
|
1123
|
+
packageName: X || void 0,
|
|
1124
|
+
basePlanId: j || void 0,
|
|
1125
|
+
offerId: q || void 0
|
|
1126
|
+
} : void 0
|
|
1127
|
+
};
|
|
1128
|
+
}, de = (n) => {
|
|
1129
|
+
const a = [], R = M(n);
|
|
1130
|
+
return R && a.push(V(R)), n.storeBilling?.kind && a.push(ee(n.storeBilling.kind)), n.storeBilling?.apple?.productId && a.push(`Apple ${n.storeBilling.apple.productId}`), n.storeBilling?.google?.productId && a.push(`Google ${n.storeBilling.google.productId}`), a.join(" • ");
|
|
1131
|
+
}, ie = B(async () => {
|
|
1132
|
+
try {
|
|
1133
|
+
N(null);
|
|
1134
|
+
let n;
|
|
1135
|
+
if (u?.isAuthenticated())
|
|
1136
|
+
n = await u.fetchWithAuth(`/admin/products?limit=${v}`);
|
|
1137
|
+
else {
|
|
1138
|
+
const a = { "Content-Type": "application/json" };
|
|
1139
|
+
r && (a["X-API-Key"] = r);
|
|
1140
|
+
const R = await fetch(`${p}/admin/products?limit=${v}`, { headers: a });
|
|
1141
|
+
if (!R.ok) throw new Error(`Failed to fetch products: ${R.status}`);
|
|
1142
|
+
n = await R.json();
|
|
1143
|
+
}
|
|
1144
|
+
T(n.products || []);
|
|
1145
|
+
} catch {
|
|
1146
|
+
T([]), N("Failed to load products");
|
|
1147
|
+
} finally {
|
|
1148
|
+
$(!1);
|
|
1149
|
+
}
|
|
1150
|
+
}, [p, r, v, u]);
|
|
1151
|
+
Y(() => {
|
|
1152
|
+
ie(), (async () => {
|
|
1153
|
+
try {
|
|
1154
|
+
let n;
|
|
1155
|
+
if (u?.isAuthenticated())
|
|
1156
|
+
n = await u.fetchWithAuth("/admin/collections");
|
|
1157
|
+
else {
|
|
1158
|
+
const a = { "Content-Type": "application/json" };
|
|
1159
|
+
r && (a["X-API-Key"] = r);
|
|
1160
|
+
const R = await fetch(`${p}/admin/collections`, { headers: a });
|
|
1161
|
+
if (!R.ok) return;
|
|
1162
|
+
n = await R.json();
|
|
1163
|
+
}
|
|
1164
|
+
m((n.collections || []).filter((a) => a.tokenizationConfig).map((a) => ({ id: a.id, name: a.name })));
|
|
1165
|
+
} catch {
|
|
1166
|
+
}
|
|
1167
|
+
})();
|
|
1168
|
+
}, [ie, p, r, u]);
|
|
1169
|
+
const _e = async (n) => {
|
|
1170
|
+
if (n.preventDefault(), !(!i.id || !i.description)) {
|
|
1171
|
+
if (F(null), i.fulfillmentType === "shipping" && i.checkoutShippingAddress && !i.shippingCountriesCsv.split(",").map((R) => R.trim()).filter(Boolean).length) {
|
|
1172
|
+
F("Shipping countries are required when collecting shipping address. Example: US,CA");
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
if (i.storeManagedKind !== "none" && !i.appleProductId.trim() && !i.googleProductId.trim()) {
|
|
1176
|
+
F("Add at least one Apple or Google store product ID for store-managed products.");
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
if (i.googleBasePlanId.trim() && !i.googleProductId.trim()) {
|
|
1180
|
+
F("Google base plan ID requires a Google product ID.");
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
if (i.storeManagedKind === "auto_renewable_subscription" && i.googleProductId.trim() && !i.googleBasePlanId.trim()) {
|
|
1184
|
+
F("Google Play subscriptions require a base plan ID.");
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
C(!0);
|
|
1188
|
+
try {
|
|
1189
|
+
const { productType: a } = i, R = i.inventoryQuantity === "" ? void 0 : Number.isFinite(Number(i.inventoryQuantity)) ? Number(i.inventoryQuantity) : void 0, X = Number(i.priceUsd) || 0, j = Math.round(X * 100), q = Math.round(X * 1e6), J = i.tagsCsv.split(",").map((b) => b.trim()).filter(Boolean), O = i.categoryIdsCsv.split(",").map((b) => b.trim()).filter(Boolean), Z = {
|
|
1190
|
+
email: i.checkoutEmail,
|
|
1191
|
+
name: i.checkoutName,
|
|
1192
|
+
phone: i.checkoutPhone,
|
|
1193
|
+
shippingAddress: i.checkoutShippingAddress,
|
|
1194
|
+
billingAddress: i.checkoutBillingAddress
|
|
1195
|
+
}, le = ge(i), ue = i.compareAtUsd === "" ? void 0 : Math.round(Number(i.compareAtUsd) * 100), o = {
|
|
1196
|
+
id: i.id,
|
|
1197
|
+
title: i.title || void 0,
|
|
1198
|
+
slug: i.slug || void 0,
|
|
1199
|
+
description: i.description,
|
|
1200
|
+
tags: J,
|
|
1201
|
+
categoryIds: O,
|
|
1202
|
+
images: i.imageUrl ? [{ url: i.imageUrl, alt: i.title || i.id }] : [],
|
|
1203
|
+
shippingProfile: i.fulfillmentType === "shipping" ? "physical" : "digital",
|
|
1204
|
+
checkoutRequirements: Z,
|
|
1205
|
+
fulfillment: {
|
|
1206
|
+
type: i.fulfillmentType,
|
|
1207
|
+
notes: i.fulfillmentNotes || void 0
|
|
1208
|
+
},
|
|
1209
|
+
fiatAmountCents: j,
|
|
1210
|
+
fiatCurrency: i.fiatCurrency,
|
|
1211
|
+
compareAtFiatAmountCents: ue,
|
|
1212
|
+
compareAtFiatCurrency: ue ? i.fiatCurrency : void 0,
|
|
1213
|
+
cryptoAtomicAmount: q,
|
|
1214
|
+
cryptoToken: i.cryptoToken,
|
|
1215
|
+
inventoryStatus: i.fulfillmentType === "shipping" ? i.inventoryStatus : void 0,
|
|
1216
|
+
...R !== void 0 ? { inventoryQuantity: R } : {},
|
|
1217
|
+
...le ? { storeBilling: le } : {},
|
|
1218
|
+
metadata: {
|
|
1219
|
+
...a ? { product_type: a } : {},
|
|
1220
|
+
...x(i)
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
if (a === "gift_card" && i.giftCardConfig && (o.giftCardConfig = i.giftCardConfig), a === "tokenized_asset" && i.tokenizedAssetConfig && (o.tokenizedAssetConfig = i.tokenizedAssetConfig), i.complianceRequirements && (o.complianceRequirements = i.complianceRequirements), u?.isAuthenticated())
|
|
1224
|
+
await u.fetchWithAuth("/admin/products", {
|
|
1225
|
+
method: "POST",
|
|
1226
|
+
body: JSON.stringify(o)
|
|
1227
|
+
});
|
|
1228
|
+
else {
|
|
1229
|
+
const b = { "Content-Type": "application/json" };
|
|
1230
|
+
r && (b["X-API-Key"] = r);
|
|
1231
|
+
const P = await fetch(`${p}/admin/products`, {
|
|
1232
|
+
method: "POST",
|
|
1233
|
+
headers: b,
|
|
1234
|
+
body: JSON.stringify(o)
|
|
1235
|
+
});
|
|
1236
|
+
if (!P.ok) throw new Error(`Failed to create product: ${P.status}`);
|
|
1237
|
+
}
|
|
1238
|
+
h({
|
|
1239
|
+
id: "",
|
|
1240
|
+
title: "",
|
|
1241
|
+
slug: "",
|
|
1242
|
+
imageUrl: "",
|
|
1243
|
+
description: "",
|
|
1244
|
+
productType: "one_time",
|
|
1245
|
+
priceUsd: "",
|
|
1246
|
+
fiatCurrency: "usd",
|
|
1247
|
+
cryptoToken: "USDC",
|
|
1248
|
+
inventoryStatus: "in_stock",
|
|
1249
|
+
compareAtUsd: "",
|
|
1250
|
+
tagsCsv: "",
|
|
1251
|
+
categoryIdsCsv: "",
|
|
1252
|
+
checkoutEmail: "required",
|
|
1253
|
+
checkoutName: "optional",
|
|
1254
|
+
checkoutPhone: "none",
|
|
1255
|
+
checkoutShippingAddress: !1,
|
|
1256
|
+
checkoutBillingAddress: !1,
|
|
1257
|
+
fulfillmentType: "shipping",
|
|
1258
|
+
storePolicyFulfillment: "physical_goods",
|
|
1259
|
+
storeManagedKind: "none",
|
|
1260
|
+
appleProductId: "",
|
|
1261
|
+
googleProductId: "",
|
|
1262
|
+
googlePackageName: "",
|
|
1263
|
+
googleBasePlanId: "",
|
|
1264
|
+
googleOfferId: "",
|
|
1265
|
+
fulfillmentNotes: "",
|
|
1266
|
+
shippingCountriesCsv: "",
|
|
1267
|
+
inventoryQuantity: "",
|
|
1268
|
+
giftCardConfig: null,
|
|
1269
|
+
tokenizedAssetConfig: null,
|
|
1270
|
+
complianceRequirements: null
|
|
1271
|
+
}), U(!1), ie();
|
|
1272
|
+
} catch (a) {
|
|
1273
|
+
F(a instanceof Error ? a.message : "Failed to create product");
|
|
1274
|
+
} finally {
|
|
1275
|
+
C(!1);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}, fe = (n) => `$${(n / 100).toFixed(2)}`, oe = (n) => {
|
|
1279
|
+
switch (n) {
|
|
1280
|
+
case "subscription":
|
|
1281
|
+
return "Subscription";
|
|
1282
|
+
case "pay_per_access":
|
|
1283
|
+
return "Pay per access";
|
|
1284
|
+
case "one_time":
|
|
1285
|
+
return "One-time purchase";
|
|
1286
|
+
case "gift_card":
|
|
1287
|
+
return "Gift card";
|
|
1288
|
+
default:
|
|
1289
|
+
return "One-time purchase";
|
|
1290
|
+
}
|
|
1291
|
+
}, ce = i.storePolicyFulfillment === "digital_in_app" || i.storePolicyFulfillment === "reader_content" || i.storePolicyFulfillment === "other" || i.productType === "subscription" || i.storeManagedKind !== "none", ae = H(() => {
|
|
1292
|
+
const n = g.filter((R) => R.active).length, a = g.reduce((R, X) => {
|
|
1293
|
+
const j = X.variations?.length ?? 0;
|
|
1294
|
+
return R + (j > 0 ? j : 1);
|
|
1295
|
+
}, 0);
|
|
1296
|
+
return { activeCount: n, totalSkus: a };
|
|
1297
|
+
}, [g]), te = (n) => {
|
|
1298
|
+
y((a) => !a || a.key !== n ? { key: n, direction: "asc" } : { key: n, direction: a.direction === "asc" ? "desc" : "asc" });
|
|
1299
|
+
}, ne = (n) => !k || k.key !== n ? /* @__PURE__ */ e("span", { className: "cedros-admin__sort-icon cedros-admin__sort-icon--idle", children: L.chevronUp }) : /* @__PURE__ */ e("span", { className: "cedros-admin__sort-icon", children: k.direction === "asc" ? L.chevronUp : L.chevronDown }), ye = H(() => {
|
|
1300
|
+
if (!k) return g;
|
|
1301
|
+
const n = k.direction === "asc" ? 1 : -1, a = (R) => {
|
|
1302
|
+
switch (k.key) {
|
|
1303
|
+
case "product":
|
|
1304
|
+
return z(R);
|
|
1305
|
+
case "type":
|
|
1306
|
+
return oe(R.metadata?.product_type);
|
|
1307
|
+
case "price":
|
|
1308
|
+
return R.fiatAmountCents ?? 0;
|
|
1309
|
+
case "status":
|
|
1310
|
+
return R.active ? 1 : 0;
|
|
1311
|
+
case "id":
|
|
1312
|
+
default:
|
|
1313
|
+
return R.id;
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
return [...g].sort((R, X) => {
|
|
1317
|
+
const j = a(R), q = a(X);
|
|
1318
|
+
return typeof j == "number" && typeof q == "number" ? (j - q) * n : String(j).localeCompare(String(q), void 0, { sensitivity: "base" }) * n;
|
|
1319
|
+
});
|
|
1320
|
+
}, [g, k]);
|
|
1321
|
+
return /* @__PURE__ */ t("div", { className: "cedros-admin__page", children: [
|
|
1322
|
+
/* @__PURE__ */ e(re, { message: D, onRetry: ie }),
|
|
1323
|
+
/* @__PURE__ */ e(
|
|
1324
|
+
pe,
|
|
1325
|
+
{
|
|
1326
|
+
stats: [
|
|
1327
|
+
{ label: "Total Products", value: g.length },
|
|
1328
|
+
{ label: "Active", value: ae.activeCount, variant: ae.activeCount > 0 ? "success" : "muted" },
|
|
1329
|
+
{ label: "Total SKUs", value: ae.totalSkus }
|
|
1330
|
+
],
|
|
1331
|
+
isLoading: A
|
|
1332
|
+
}
|
|
1333
|
+
),
|
|
1334
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: [
|
|
1335
|
+
/* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Paywall Products" }),
|
|
1336
|
+
/* @__PURE__ */ t(
|
|
1337
|
+
"button",
|
|
1338
|
+
{
|
|
1339
|
+
className: "cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",
|
|
1340
|
+
onClick: () => {
|
|
1341
|
+
F(null), U(!_);
|
|
1342
|
+
},
|
|
1343
|
+
children: [
|
|
1344
|
+
_ ? L.close : L.plus,
|
|
1345
|
+
_ ? "Cancel" : "Add Product"
|
|
1346
|
+
]
|
|
1347
|
+
}
|
|
1348
|
+
)
|
|
1349
|
+
] }),
|
|
1350
|
+
_ && /* @__PURE__ */ t("form", { onSubmit: _e, className: "cedros-admin__add-form", children: [
|
|
1351
|
+
I && /* @__PURE__ */ e("div", { style: { marginBottom: "0.75rem", color: "#B42318", fontWeight: 600 }, children: I }),
|
|
1352
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1353
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1354
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Product ID" }),
|
|
1355
|
+
/* @__PURE__ */ e(
|
|
1356
|
+
"input",
|
|
1357
|
+
{
|
|
1358
|
+
type: "text",
|
|
1359
|
+
className: "cedros-admin__input",
|
|
1360
|
+
value: i.id,
|
|
1361
|
+
onChange: (n) => h((a) => ({ ...a, id: n.target.value })),
|
|
1362
|
+
placeholder: "e.g., premium-article",
|
|
1363
|
+
required: !0
|
|
1364
|
+
}
|
|
1365
|
+
)
|
|
1366
|
+
] }),
|
|
1367
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1368
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Product name" }),
|
|
1369
|
+
/* @__PURE__ */ e(
|
|
1370
|
+
"input",
|
|
1371
|
+
{
|
|
1372
|
+
type: "text",
|
|
1373
|
+
className: "cedros-admin__input",
|
|
1374
|
+
value: i.title,
|
|
1375
|
+
onChange: (n) => h((a) => ({ ...a, title: n.target.value })),
|
|
1376
|
+
placeholder: "e.g., Cedros Hoodie"
|
|
1377
|
+
}
|
|
1378
|
+
)
|
|
1379
|
+
] })
|
|
1380
|
+
] }),
|
|
1381
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1382
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1383
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Slug" }),
|
|
1384
|
+
/* @__PURE__ */ e(
|
|
1385
|
+
"input",
|
|
1386
|
+
{
|
|
1387
|
+
type: "text",
|
|
1388
|
+
className: "cedros-admin__input",
|
|
1389
|
+
value: i.slug,
|
|
1390
|
+
onChange: (n) => h((a) => ({ ...a, slug: n.target.value })),
|
|
1391
|
+
placeholder: "e.g., cedros-hoodie (defaults to ID)"
|
|
1392
|
+
}
|
|
1393
|
+
)
|
|
1394
|
+
] }),
|
|
1395
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1396
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Primary image URL" }),
|
|
1397
|
+
/* @__PURE__ */ e(
|
|
1398
|
+
"input",
|
|
1399
|
+
{
|
|
1400
|
+
type: "url",
|
|
1401
|
+
className: "cedros-admin__input",
|
|
1402
|
+
value: i.imageUrl,
|
|
1403
|
+
onChange: (n) => h((a) => ({ ...a, imageUrl: n.target.value })),
|
|
1404
|
+
placeholder: "https://..."
|
|
1405
|
+
}
|
|
1406
|
+
)
|
|
1407
|
+
] })
|
|
1408
|
+
] }),
|
|
1409
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__form-row", children: /* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1410
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Short description" }),
|
|
1411
|
+
/* @__PURE__ */ e(
|
|
1412
|
+
"input",
|
|
1413
|
+
{
|
|
1414
|
+
type: "text",
|
|
1415
|
+
className: "cedros-admin__input",
|
|
1416
|
+
value: i.description,
|
|
1417
|
+
onChange: (n) => h((a) => ({ ...a, description: n.target.value })),
|
|
1418
|
+
placeholder: "e.g., Midweight fleece with relaxed fit",
|
|
1419
|
+
required: !0
|
|
1420
|
+
}
|
|
1421
|
+
)
|
|
1422
|
+
] }) }),
|
|
1423
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1424
|
+
/* @__PURE__ */ e(
|
|
1425
|
+
Q,
|
|
1426
|
+
{
|
|
1427
|
+
value: i.productType,
|
|
1428
|
+
onChange: (n) => h((a) => ({
|
|
1429
|
+
...a,
|
|
1430
|
+
productType: n,
|
|
1431
|
+
storeManagedKind: n === "subscription" ? "auto_renewable_subscription" : a.storeManagedKind === "auto_renewable_subscription" ? "non_consumable" : a.storeManagedKind,
|
|
1432
|
+
giftCardConfig: n === "gift_card" ? a.giftCardConfig ?? { faceValueCents: 0, currency: "usd", secondaryMarket: !1, expiresInDays: null } : null,
|
|
1433
|
+
tokenizedAssetConfig: n === "tokenized_asset" ? a.tokenizedAssetConfig ?? { assetClassCollectionId: "", backingValueCents: 0, backingCurrency: "usd", assetIdentifier: "", tokensPerUnit: 1, custodyProofUrl: null } : null
|
|
1434
|
+
})),
|
|
1435
|
+
options: [
|
|
1436
|
+
{ value: "one_time", label: "One-time purchase" },
|
|
1437
|
+
{ value: "pay_per_access", label: "Pay per access" },
|
|
1438
|
+
{ value: "subscription", label: "Subscription" },
|
|
1439
|
+
{ value: "gift_card", label: "Gift card" },
|
|
1440
|
+
{ value: "tokenized_asset", label: "Tokenized asset" }
|
|
1441
|
+
],
|
|
1442
|
+
label: "Product Type"
|
|
1443
|
+
}
|
|
1444
|
+
),
|
|
1445
|
+
/* @__PURE__ */ e(
|
|
1446
|
+
Q,
|
|
1447
|
+
{
|
|
1448
|
+
value: i.fulfillmentType,
|
|
1449
|
+
onChange: (n) => {
|
|
1450
|
+
const a = n;
|
|
1451
|
+
h((R) => ({
|
|
1452
|
+
...R,
|
|
1453
|
+
fulfillmentType: a,
|
|
1454
|
+
storePolicyFulfillment: a === "shipping" ? "physical_goods" : a === "service" ? "real_world_service" : "digital_in_app",
|
|
1455
|
+
storeManagedKind: a === "shipping" || a === "service" ? "none" : R.productType === "subscription" ? "auto_renewable_subscription" : R.storeManagedKind === "none" ? "non_consumable" : R.storeManagedKind,
|
|
1456
|
+
checkoutShippingAddress: a === "shipping" ? R.checkoutShippingAddress : !1
|
|
1457
|
+
}));
|
|
1458
|
+
},
|
|
1459
|
+
options: [
|
|
1460
|
+
{ value: "shipping", label: "Physical (shipped)" },
|
|
1461
|
+
{ value: "digital_download", label: "Digital download" },
|
|
1462
|
+
{ value: "service", label: "Service" }
|
|
1463
|
+
],
|
|
1464
|
+
label: "Fulfillment"
|
|
1465
|
+
}
|
|
1466
|
+
)
|
|
1467
|
+
] }),
|
|
1468
|
+
/* @__PURE__ */ t(
|
|
1469
|
+
"div",
|
|
1470
|
+
{
|
|
1471
|
+
style: {
|
|
1472
|
+
padding: "0.9rem 1rem",
|
|
1473
|
+
borderRadius: "0.75rem",
|
|
1474
|
+
border: "1px solid var(--cedros-admin-border, #e5e7eb)",
|
|
1475
|
+
background: "var(--cedros-admin-surface, #ffffff)",
|
|
1476
|
+
marginBottom: "1rem"
|
|
1477
|
+
},
|
|
1478
|
+
children: [
|
|
1479
|
+
/* @__PURE__ */ e("div", { style: { fontWeight: 700, marginBottom: "0.35rem" }, children: "Store policy and app billing" }),
|
|
1480
|
+
/* @__PURE__ */ e("div", { style: { fontSize: "0.9rem", lineHeight: 1.6, opacity: 0.8 }, children: "This controls how Cedros routes payments across the web, Apple App Store, and Google Play. For digital app functionality, choose the explicit store policy classification here instead of relying on generic product type labels." })
|
|
1481
|
+
]
|
|
1482
|
+
}
|
|
1483
|
+
),
|
|
1484
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1485
|
+
/* @__PURE__ */ e(
|
|
1486
|
+
Q,
|
|
1487
|
+
{
|
|
1488
|
+
value: i.storePolicyFulfillment,
|
|
1489
|
+
onChange: (n) => h((a) => ({
|
|
1490
|
+
...a,
|
|
1491
|
+
storePolicyFulfillment: n,
|
|
1492
|
+
storeManagedKind: n === "physical_goods" || n === "real_world_service" ? "none" : a.storeManagedKind
|
|
1493
|
+
})),
|
|
1494
|
+
options: [
|
|
1495
|
+
{ value: "digital_in_app", label: "Digital in-app" },
|
|
1496
|
+
{ value: "physical_goods", label: "Physical goods" },
|
|
1497
|
+
{ value: "real_world_service", label: "Real-world service" },
|
|
1498
|
+
{ value: "reader_content", label: "Reader content" },
|
|
1499
|
+
{ value: "other", label: "Other / review manually" }
|
|
1500
|
+
],
|
|
1501
|
+
label: "Store policy classification"
|
|
1502
|
+
}
|
|
1503
|
+
),
|
|
1504
|
+
/* @__PURE__ */ e(
|
|
1505
|
+
Q,
|
|
1506
|
+
{
|
|
1507
|
+
value: i.storeManagedKind,
|
|
1508
|
+
onChange: (n) => h((a) => ({
|
|
1509
|
+
...a,
|
|
1510
|
+
storeManagedKind: n
|
|
1511
|
+
})),
|
|
1512
|
+
options: [
|
|
1513
|
+
{ value: "none", label: "External billing only" },
|
|
1514
|
+
{ value: "consumable", label: "Consumable" },
|
|
1515
|
+
{ value: "non_consumable", label: "Non-consumable" },
|
|
1516
|
+
{ value: "auto_renewable_subscription", label: "Auto-renewing subscription" }
|
|
1517
|
+
],
|
|
1518
|
+
label: "Store-managed product kind"
|
|
1519
|
+
}
|
|
1520
|
+
)
|
|
1521
|
+
] }),
|
|
1522
|
+
ce && /* @__PURE__ */ t(me, { children: [
|
|
1523
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1524
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1525
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Apple product ID" }),
|
|
1526
|
+
/* @__PURE__ */ e(
|
|
1527
|
+
"input",
|
|
1528
|
+
{
|
|
1529
|
+
type: "text",
|
|
1530
|
+
className: "cedros-admin__input",
|
|
1531
|
+
value: i.appleProductId,
|
|
1532
|
+
onChange: (n) => h((a) => ({ ...a, appleProductId: n.target.value })),
|
|
1533
|
+
placeholder: "e.g., com.cedros.pro.monthly"
|
|
1534
|
+
}
|
|
1535
|
+
),
|
|
1536
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "Create the matching product in App Store Connect and paste the product ID here." })
|
|
1537
|
+
] }),
|
|
1538
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1539
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Google product ID" }),
|
|
1540
|
+
/* @__PURE__ */ e(
|
|
1541
|
+
"input",
|
|
1542
|
+
{
|
|
1543
|
+
type: "text",
|
|
1544
|
+
className: "cedros-admin__input",
|
|
1545
|
+
value: i.googleProductId,
|
|
1546
|
+
onChange: (n) => h((a) => ({ ...a, googleProductId: n.target.value })),
|
|
1547
|
+
placeholder: "e.g., pro_monthly"
|
|
1548
|
+
}
|
|
1549
|
+
),
|
|
1550
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "Create the matching one-time product or subscription in Google Play Console." })
|
|
1551
|
+
] })
|
|
1552
|
+
] }),
|
|
1553
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1554
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1555
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Google package name" }),
|
|
1556
|
+
/* @__PURE__ */ e(
|
|
1557
|
+
"input",
|
|
1558
|
+
{
|
|
1559
|
+
type: "text",
|
|
1560
|
+
className: "cedros-admin__input",
|
|
1561
|
+
value: i.googlePackageName,
|
|
1562
|
+
onChange: (n) => h((a) => ({ ...a, googlePackageName: n.target.value })),
|
|
1563
|
+
placeholder: "e.g., com.cedros.app"
|
|
1564
|
+
}
|
|
1565
|
+
)
|
|
1566
|
+
] }),
|
|
1567
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1568
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Google base plan ID" }),
|
|
1569
|
+
/* @__PURE__ */ e(
|
|
1570
|
+
"input",
|
|
1571
|
+
{
|
|
1572
|
+
type: "text",
|
|
1573
|
+
className: "cedros-admin__input",
|
|
1574
|
+
value: i.googleBasePlanId,
|
|
1575
|
+
onChange: (n) => h((a) => ({ ...a, googleBasePlanId: n.target.value })),
|
|
1576
|
+
placeholder: "Required for Google subscriptions"
|
|
1577
|
+
}
|
|
1578
|
+
)
|
|
1579
|
+
] }),
|
|
1580
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1581
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Google offer ID" }),
|
|
1582
|
+
/* @__PURE__ */ e(
|
|
1583
|
+
"input",
|
|
1584
|
+
{
|
|
1585
|
+
type: "text",
|
|
1586
|
+
className: "cedros-admin__input",
|
|
1587
|
+
value: i.googleOfferId,
|
|
1588
|
+
onChange: (n) => h((a) => ({ ...a, googleOfferId: n.target.value })),
|
|
1589
|
+
placeholder: "Optional"
|
|
1590
|
+
}
|
|
1591
|
+
)
|
|
1592
|
+
] })
|
|
1593
|
+
] })
|
|
1594
|
+
] }),
|
|
1595
|
+
i.productType === "gift_card" && /* @__PURE__ */ t(me, { children: [
|
|
1596
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1597
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1598
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Gift card face value (USD cents)" }),
|
|
1599
|
+
/* @__PURE__ */ e(
|
|
1600
|
+
"input",
|
|
1601
|
+
{
|
|
1602
|
+
type: "number",
|
|
1603
|
+
className: "cedros-admin__input",
|
|
1604
|
+
value: i.giftCardConfig?.faceValueCents ?? "",
|
|
1605
|
+
onChange: (n) => h((a) => ({
|
|
1606
|
+
...a,
|
|
1607
|
+
giftCardConfig: {
|
|
1608
|
+
faceValueCents: parseInt(n.target.value) || 0,
|
|
1609
|
+
currency: a.giftCardConfig?.currency ?? "usd",
|
|
1610
|
+
secondaryMarket: a.giftCardConfig?.secondaryMarket ?? !1,
|
|
1611
|
+
expiresInDays: a.giftCardConfig?.expiresInDays ?? null
|
|
1612
|
+
}
|
|
1613
|
+
})),
|
|
1614
|
+
placeholder: "e.g., 5000 for $50.00",
|
|
1615
|
+
min: "1",
|
|
1616
|
+
required: !0
|
|
1617
|
+
}
|
|
1618
|
+
),
|
|
1619
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "Face value in cents (e.g. 5000 = $50.00). Must be greater than 0." })
|
|
1620
|
+
] }),
|
|
1621
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1622
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Gift card currency" }),
|
|
1623
|
+
/* @__PURE__ */ e(
|
|
1624
|
+
"input",
|
|
1625
|
+
{
|
|
1626
|
+
type: "text",
|
|
1627
|
+
className: "cedros-admin__input",
|
|
1628
|
+
value: i.giftCardConfig?.currency ?? "",
|
|
1629
|
+
onChange: (n) => h((a) => ({
|
|
1630
|
+
...a,
|
|
1631
|
+
giftCardConfig: {
|
|
1632
|
+
faceValueCents: a.giftCardConfig?.faceValueCents ?? 0,
|
|
1633
|
+
currency: n.target.value.toLowerCase().slice(0, 3),
|
|
1634
|
+
secondaryMarket: a.giftCardConfig?.secondaryMarket ?? !1,
|
|
1635
|
+
expiresInDays: a.giftCardConfig?.expiresInDays ?? null
|
|
1636
|
+
}
|
|
1637
|
+
})),
|
|
1638
|
+
placeholder: "usd",
|
|
1639
|
+
maxLength: 3,
|
|
1640
|
+
required: !0
|
|
1641
|
+
}
|
|
1642
|
+
),
|
|
1643
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "ISO 4217 3-letter currency code (e.g. usd, eur, gbp)." })
|
|
1644
|
+
] })
|
|
1645
|
+
] }),
|
|
1646
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1647
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1648
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Expiration (days)" }),
|
|
1649
|
+
/* @__PURE__ */ e(
|
|
1650
|
+
"input",
|
|
1651
|
+
{
|
|
1652
|
+
type: "number",
|
|
1653
|
+
className: "cedros-admin__input",
|
|
1654
|
+
value: i.giftCardConfig?.expiresInDays ?? "",
|
|
1655
|
+
onChange: (n) => h((a) => ({
|
|
1656
|
+
...a,
|
|
1657
|
+
giftCardConfig: {
|
|
1658
|
+
faceValueCents: a.giftCardConfig?.faceValueCents ?? 0,
|
|
1659
|
+
currency: a.giftCardConfig?.currency ?? "usd",
|
|
1660
|
+
secondaryMarket: a.giftCardConfig?.secondaryMarket ?? !1,
|
|
1661
|
+
expiresInDays: n.target.value === "" ? null : parseInt(n.target.value) || 0
|
|
1662
|
+
}
|
|
1663
|
+
})),
|
|
1664
|
+
placeholder: "Leave blank for no expiry",
|
|
1665
|
+
min: "0"
|
|
1666
|
+
}
|
|
1667
|
+
),
|
|
1668
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "Number of days until gift card expires. Leave blank for no expiry." })
|
|
1669
|
+
] }),
|
|
1670
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1671
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Secondary market (Token-22)" }),
|
|
1672
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", marginTop: 8 }, children: [
|
|
1673
|
+
/* @__PURE__ */ e(
|
|
1674
|
+
"input",
|
|
1675
|
+
{
|
|
1676
|
+
type: "checkbox",
|
|
1677
|
+
checked: i.giftCardConfig?.secondaryMarket ?? !1,
|
|
1678
|
+
onChange: (n) => h((a) => ({
|
|
1679
|
+
...a,
|
|
1680
|
+
giftCardConfig: {
|
|
1681
|
+
faceValueCents: a.giftCardConfig?.faceValueCents ?? 0,
|
|
1682
|
+
currency: a.giftCardConfig?.currency ?? "usd",
|
|
1683
|
+
secondaryMarket: n.target.checked,
|
|
1684
|
+
expiresInDays: a.giftCardConfig?.expiresInDays ?? null
|
|
1685
|
+
}
|
|
1686
|
+
}))
|
|
1687
|
+
}
|
|
1688
|
+
),
|
|
1689
|
+
"Enable Token-22 secondary market trading"
|
|
1690
|
+
] }),
|
|
1691
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "Mints store credit tokens to recipient's embedded wallet for peer-to-peer trading with transfer fees." })
|
|
1692
|
+
] })
|
|
1693
|
+
] })
|
|
1694
|
+
] }),
|
|
1695
|
+
i.productType === "tokenized_asset" && /* @__PURE__ */ t(me, { children: [
|
|
1696
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1697
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1698
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Asset class collection" }),
|
|
1699
|
+
d.length > 0 ? /* @__PURE__ */ t(
|
|
1700
|
+
"select",
|
|
1701
|
+
{
|
|
1702
|
+
className: "cedros-admin__input",
|
|
1703
|
+
value: i.tokenizedAssetConfig?.assetClassCollectionId ?? "",
|
|
1704
|
+
onChange: (n) => h((a) => ({
|
|
1705
|
+
...a,
|
|
1706
|
+
tokenizedAssetConfig: { ...a.tokenizedAssetConfig, assetClassCollectionId: n.target.value }
|
|
1707
|
+
})),
|
|
1708
|
+
required: !0,
|
|
1709
|
+
children: [
|
|
1710
|
+
/* @__PURE__ */ e("option", { value: "", children: "Select asset class..." }),
|
|
1711
|
+
d.map((n) => /* @__PURE__ */ e("option", { value: n.id, children: n.name }, n.id))
|
|
1712
|
+
]
|
|
1713
|
+
}
|
|
1714
|
+
) : /* @__PURE__ */ e(
|
|
1715
|
+
"input",
|
|
1716
|
+
{
|
|
1717
|
+
type: "text",
|
|
1718
|
+
className: "cedros-admin__input",
|
|
1719
|
+
value: i.tokenizedAssetConfig?.assetClassCollectionId ?? "",
|
|
1720
|
+
onChange: (n) => h((a) => ({
|
|
1721
|
+
...a,
|
|
1722
|
+
tokenizedAssetConfig: { ...a.tokenizedAssetConfig, assetClassCollectionId: n.target.value }
|
|
1723
|
+
})),
|
|
1724
|
+
placeholder: "Collection ID of the asset class",
|
|
1725
|
+
required: !0
|
|
1726
|
+
}
|
|
1727
|
+
)
|
|
1728
|
+
] }),
|
|
1729
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1730
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Backing value (cents)" }),
|
|
1731
|
+
/* @__PURE__ */ e(
|
|
1732
|
+
"input",
|
|
1733
|
+
{
|
|
1734
|
+
type: "number",
|
|
1735
|
+
className: "cedros-admin__input",
|
|
1736
|
+
value: i.tokenizedAssetConfig?.backingValueCents ?? 0,
|
|
1737
|
+
onChange: (n) => h((a) => ({
|
|
1738
|
+
...a,
|
|
1739
|
+
tokenizedAssetConfig: { ...a.tokenizedAssetConfig, backingValueCents: Number(n.target.value) }
|
|
1740
|
+
})),
|
|
1741
|
+
min: 0
|
|
1742
|
+
}
|
|
1743
|
+
)
|
|
1744
|
+
] })
|
|
1745
|
+
] }),
|
|
1746
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1747
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1748
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Backing currency" }),
|
|
1749
|
+
/* @__PURE__ */ e(
|
|
1750
|
+
"input",
|
|
1751
|
+
{
|
|
1752
|
+
type: "text",
|
|
1753
|
+
className: "cedros-admin__input",
|
|
1754
|
+
value: i.tokenizedAssetConfig?.backingCurrency ?? "usd",
|
|
1755
|
+
onChange: (n) => h((a) => ({
|
|
1756
|
+
...a,
|
|
1757
|
+
tokenizedAssetConfig: { ...a.tokenizedAssetConfig, backingCurrency: n.target.value }
|
|
1758
|
+
})),
|
|
1759
|
+
placeholder: "usd",
|
|
1760
|
+
maxLength: 3
|
|
1761
|
+
}
|
|
1762
|
+
)
|
|
1763
|
+
] }),
|
|
1764
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1765
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Asset identifier" }),
|
|
1766
|
+
/* @__PURE__ */ e(
|
|
1767
|
+
"input",
|
|
1768
|
+
{
|
|
1769
|
+
type: "text",
|
|
1770
|
+
className: "cedros-admin__input",
|
|
1771
|
+
value: i.tokenizedAssetConfig?.assetIdentifier ?? "",
|
|
1772
|
+
onChange: (n) => h((a) => ({
|
|
1773
|
+
...a,
|
|
1774
|
+
tokenizedAssetConfig: { ...a.tokenizedAssetConfig, assetIdentifier: n.target.value }
|
|
1775
|
+
})),
|
|
1776
|
+
placeholder: "e.g., ISIN, lot number"
|
|
1777
|
+
}
|
|
1778
|
+
)
|
|
1779
|
+
] })
|
|
1780
|
+
] }),
|
|
1781
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1782
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1783
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Tokens per unit" }),
|
|
1784
|
+
/* @__PURE__ */ e(
|
|
1785
|
+
"input",
|
|
1786
|
+
{
|
|
1787
|
+
type: "number",
|
|
1788
|
+
className: "cedros-admin__input",
|
|
1789
|
+
value: i.tokenizedAssetConfig?.tokensPerUnit ?? 1,
|
|
1790
|
+
onChange: (n) => h((a) => ({
|
|
1791
|
+
...a,
|
|
1792
|
+
tokenizedAssetConfig: { ...a.tokenizedAssetConfig, tokensPerUnit: Number(n.target.value) }
|
|
1793
|
+
})),
|
|
1794
|
+
min: 1
|
|
1795
|
+
}
|
|
1796
|
+
)
|
|
1797
|
+
] }),
|
|
1798
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1799
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Custody proof URL" }),
|
|
1800
|
+
/* @__PURE__ */ e(
|
|
1801
|
+
"input",
|
|
1802
|
+
{
|
|
1803
|
+
type: "text",
|
|
1804
|
+
className: "cedros-admin__input",
|
|
1805
|
+
value: i.tokenizedAssetConfig?.custodyProofUrl ?? "",
|
|
1806
|
+
onChange: (n) => h((a) => ({
|
|
1807
|
+
...a,
|
|
1808
|
+
tokenizedAssetConfig: { ...a.tokenizedAssetConfig, custodyProofUrl: n.target.value || null }
|
|
1809
|
+
})),
|
|
1810
|
+
placeholder: "https://..."
|
|
1811
|
+
}
|
|
1812
|
+
)
|
|
1813
|
+
] })
|
|
1814
|
+
] })
|
|
1815
|
+
] }),
|
|
1816
|
+
i.fulfillmentType === "shipping" && /* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1817
|
+
/* @__PURE__ */ e(
|
|
1818
|
+
Q,
|
|
1819
|
+
{
|
|
1820
|
+
value: i.inventoryStatus,
|
|
1821
|
+
onChange: (n) => h((a) => ({
|
|
1822
|
+
...a,
|
|
1823
|
+
inventoryStatus: n
|
|
1824
|
+
})),
|
|
1825
|
+
options: [
|
|
1826
|
+
{ value: "in_stock", label: "In stock" },
|
|
1827
|
+
{ value: "low", label: "Low" },
|
|
1828
|
+
{ value: "out_of_stock", label: "Out of stock" },
|
|
1829
|
+
{ value: "backorder", label: "Backorder" }
|
|
1830
|
+
],
|
|
1831
|
+
label: "Inventory status"
|
|
1832
|
+
}
|
|
1833
|
+
),
|
|
1834
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1835
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Inventory quantity (tracked)" }),
|
|
1836
|
+
/* @__PURE__ */ e(
|
|
1837
|
+
"input",
|
|
1838
|
+
{
|
|
1839
|
+
type: "number",
|
|
1840
|
+
className: "cedros-admin__input",
|
|
1841
|
+
value: i.inventoryQuantity,
|
|
1842
|
+
onChange: (n) => h((a) => ({
|
|
1843
|
+
...a,
|
|
1844
|
+
inventoryQuantity: n.target.value === "" ? "" : parseInt(n.target.value) || 0
|
|
1845
|
+
})),
|
|
1846
|
+
placeholder: "Leave blank for untracked",
|
|
1847
|
+
min: "0"
|
|
1848
|
+
}
|
|
1849
|
+
)
|
|
1850
|
+
] }),
|
|
1851
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1852
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Compare-at price (USD)" }),
|
|
1853
|
+
/* @__PURE__ */ e(
|
|
1854
|
+
"input",
|
|
1855
|
+
{
|
|
1856
|
+
type: "number",
|
|
1857
|
+
className: "cedros-admin__input",
|
|
1858
|
+
value: i.compareAtUsd === "" ? "" : i.compareAtUsd,
|
|
1859
|
+
onChange: (n) => h((a) => ({ ...a, compareAtUsd: n.target.value === "" ? "" : parseFloat(n.target.value) || 0 })),
|
|
1860
|
+
placeholder: "e.g., 78.00",
|
|
1861
|
+
min: "0",
|
|
1862
|
+
step: "0.01"
|
|
1863
|
+
}
|
|
1864
|
+
)
|
|
1865
|
+
] })
|
|
1866
|
+
] }),
|
|
1867
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__form-row", children: /* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1868
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Price (USD)" }),
|
|
1869
|
+
/* @__PURE__ */ e(
|
|
1870
|
+
"input",
|
|
1871
|
+
{
|
|
1872
|
+
type: "number",
|
|
1873
|
+
className: "cedros-admin__input",
|
|
1874
|
+
value: i.priceUsd === "" ? "" : i.priceUsd,
|
|
1875
|
+
onChange: (n) => h((a) => ({ ...a, priceUsd: n.target.value === "" ? "" : parseFloat(n.target.value) || 0 })),
|
|
1876
|
+
placeholder: "e.g., 5.00",
|
|
1877
|
+
min: "0",
|
|
1878
|
+
step: "0.01",
|
|
1879
|
+
required: !0
|
|
1880
|
+
}
|
|
1881
|
+
)
|
|
1882
|
+
] }) }),
|
|
1883
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1884
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1885
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Tags (comma-separated)" }),
|
|
1886
|
+
/* @__PURE__ */ e(
|
|
1887
|
+
"input",
|
|
1888
|
+
{
|
|
1889
|
+
type: "text",
|
|
1890
|
+
className: "cedros-admin__input",
|
|
1891
|
+
value: i.tagsCsv,
|
|
1892
|
+
onChange: (n) => h((a) => ({ ...a, tagsCsv: n.target.value })),
|
|
1893
|
+
placeholder: "e.g., core, new, gift"
|
|
1894
|
+
}
|
|
1895
|
+
)
|
|
1896
|
+
] }),
|
|
1897
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1898
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Category IDs (comma-separated)" }),
|
|
1899
|
+
/* @__PURE__ */ e(
|
|
1900
|
+
"input",
|
|
1901
|
+
{
|
|
1902
|
+
type: "text",
|
|
1903
|
+
className: "cedros-admin__input",
|
|
1904
|
+
value: i.categoryIdsCsv,
|
|
1905
|
+
onChange: (n) => h((a) => ({ ...a, categoryIdsCsv: n.target.value })),
|
|
1906
|
+
placeholder: "e.g., cat_apparel, cat_accessories"
|
|
1907
|
+
}
|
|
1908
|
+
)
|
|
1909
|
+
] })
|
|
1910
|
+
] }),
|
|
1911
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1912
|
+
/* @__PURE__ */ e(
|
|
1913
|
+
Q,
|
|
1914
|
+
{
|
|
1915
|
+
value: i.checkoutEmail,
|
|
1916
|
+
onChange: (n) => h((a) => ({ ...a, checkoutEmail: n })),
|
|
1917
|
+
options: [
|
|
1918
|
+
{ value: "none", label: "None" },
|
|
1919
|
+
{ value: "optional", label: "Optional" },
|
|
1920
|
+
{ value: "required", label: "Required" }
|
|
1921
|
+
],
|
|
1922
|
+
label: "Checkout: Email"
|
|
1923
|
+
}
|
|
1924
|
+
),
|
|
1925
|
+
/* @__PURE__ */ e(
|
|
1926
|
+
Q,
|
|
1927
|
+
{
|
|
1928
|
+
value: i.checkoutName,
|
|
1929
|
+
onChange: (n) => h((a) => ({ ...a, checkoutName: n })),
|
|
1930
|
+
options: [
|
|
1931
|
+
{ value: "none", label: "None" },
|
|
1932
|
+
{ value: "optional", label: "Optional" },
|
|
1933
|
+
{ value: "required", label: "Required" }
|
|
1934
|
+
],
|
|
1935
|
+
label: "Checkout: Name"
|
|
1936
|
+
}
|
|
1937
|
+
),
|
|
1938
|
+
/* @__PURE__ */ e(
|
|
1939
|
+
Q,
|
|
1940
|
+
{
|
|
1941
|
+
value: i.checkoutPhone,
|
|
1942
|
+
onChange: (n) => h((a) => ({ ...a, checkoutPhone: n })),
|
|
1943
|
+
options: [
|
|
1944
|
+
{ value: "none", label: "None" },
|
|
1945
|
+
{ value: "optional", label: "Optional" },
|
|
1946
|
+
{ value: "required", label: "Required" }
|
|
1947
|
+
],
|
|
1948
|
+
label: "Checkout: Phone"
|
|
1949
|
+
}
|
|
1950
|
+
)
|
|
1951
|
+
] }),
|
|
1952
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
1953
|
+
i.fulfillmentType === "shipping" && /* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1954
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Checkout: Shipping address" }),
|
|
1955
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
1956
|
+
/* @__PURE__ */ e(
|
|
1957
|
+
"input",
|
|
1958
|
+
{
|
|
1959
|
+
type: "checkbox",
|
|
1960
|
+
checked: i.checkoutShippingAddress,
|
|
1961
|
+
onChange: (n) => h((a) => ({ ...a, checkoutShippingAddress: n.target.checked }))
|
|
1962
|
+
}
|
|
1963
|
+
),
|
|
1964
|
+
"Collect shipping address"
|
|
1965
|
+
] })
|
|
1966
|
+
] }),
|
|
1967
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1968
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Checkout: Billing address" }),
|
|
1969
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
1970
|
+
/* @__PURE__ */ e(
|
|
1971
|
+
"input",
|
|
1972
|
+
{
|
|
1973
|
+
type: "checkbox",
|
|
1974
|
+
checked: i.checkoutBillingAddress,
|
|
1975
|
+
onChange: (n) => h((a) => ({ ...a, checkoutBillingAddress: n.target.checked }))
|
|
1976
|
+
}
|
|
1977
|
+
),
|
|
1978
|
+
"Collect billing address"
|
|
1979
|
+
] })
|
|
1980
|
+
] })
|
|
1981
|
+
] }),
|
|
1982
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__form-row", children: /* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1983
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Fulfillment notes" }),
|
|
1984
|
+
/* @__PURE__ */ e(
|
|
1985
|
+
"input",
|
|
1986
|
+
{
|
|
1987
|
+
type: "text",
|
|
1988
|
+
className: "cedros-admin__input",
|
|
1989
|
+
value: i.fulfillmentNotes,
|
|
1990
|
+
onChange: (n) => h((a) => ({ ...a, fulfillmentNotes: n.target.value })),
|
|
1991
|
+
placeholder: i.fulfillmentType === "shipping" ? "e.g., Ships within 3-5 business days" : "e.g., Downloadable from your account after purchase"
|
|
1992
|
+
}
|
|
1993
|
+
)
|
|
1994
|
+
] }) }),
|
|
1995
|
+
i.fulfillmentType === "shipping" && i.checkoutShippingAddress && /* @__PURE__ */ e("div", { className: "cedros-admin__form-row", children: /* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
1996
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Shipping countries" }),
|
|
1997
|
+
/* @__PURE__ */ e(
|
|
1998
|
+
"input",
|
|
1999
|
+
{
|
|
2000
|
+
type: "text",
|
|
2001
|
+
className: "cedros-admin__input",
|
|
2002
|
+
value: i.shippingCountriesCsv,
|
|
2003
|
+
onChange: (n) => h((a) => ({ ...a, shippingCountriesCsv: n.target.value })),
|
|
2004
|
+
placeholder: "e.g., US,CA"
|
|
2005
|
+
}
|
|
2006
|
+
),
|
|
2007
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "ISO 2-letter country codes, comma-separated. Required for shipping address collection." })
|
|
2008
|
+
] }) }),
|
|
2009
|
+
/* @__PURE__ */ e(
|
|
2010
|
+
Re,
|
|
2011
|
+
{
|
|
2012
|
+
value: i.complianceRequirements,
|
|
2013
|
+
onChange: (n) => h((a) => ({ ...a, complianceRequirements: n }))
|
|
2014
|
+
}
|
|
2015
|
+
),
|
|
2016
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__form-actions", children: /* @__PURE__ */ e("button", { type: "submit", className: "cedros-admin__button cedros-admin__button--primary", disabled: w, children: w ? "Creating..." : "Create Product" }) })
|
|
2017
|
+
] }),
|
|
2018
|
+
A ? /* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
|
|
2019
|
+
L.loading,
|
|
2020
|
+
" Loading products..."
|
|
2021
|
+
] }) : /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ t("table", { className: "cedros-admin__table", children: [
|
|
2022
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
|
|
2023
|
+
/* @__PURE__ */ e("th", { "aria-sort": k?.key === "id" ? k?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => te("id"), children: [
|
|
2024
|
+
"ID",
|
|
2025
|
+
ne("id")
|
|
2026
|
+
] }) }),
|
|
2027
|
+
/* @__PURE__ */ e("th", { "aria-sort": k?.key === "product" ? k?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => te("product"), children: [
|
|
2028
|
+
"Product",
|
|
2029
|
+
ne("product")
|
|
2030
|
+
] }) }),
|
|
2031
|
+
/* @__PURE__ */ e("th", { "aria-sort": k?.key === "type" ? k?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => te("type"), children: [
|
|
2032
|
+
"Type",
|
|
2033
|
+
ne("type")
|
|
2034
|
+
] }) }),
|
|
2035
|
+
/* @__PURE__ */ e("th", { "aria-sort": k?.key === "price" ? k?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => te("price"), children: [
|
|
2036
|
+
"Price",
|
|
2037
|
+
ne("price")
|
|
2038
|
+
] }) }),
|
|
2039
|
+
/* @__PURE__ */ e("th", { "aria-sort": k?.key === "status" ? k?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => te("status"), children: [
|
|
2040
|
+
"Status",
|
|
2041
|
+
ne("status")
|
|
2042
|
+
] }) }),
|
|
2043
|
+
/* @__PURE__ */ e("th", { children: "Actions" })
|
|
2044
|
+
] }) }),
|
|
2045
|
+
/* @__PURE__ */ e("tbody", { children: ye.map((n) => /* @__PURE__ */ t("tr", { children: [
|
|
2046
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: n.id }) }),
|
|
2047
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ t("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
2048
|
+
E(n) ? /* @__PURE__ */ e(
|
|
2049
|
+
"img",
|
|
2050
|
+
{
|
|
2051
|
+
src: E(n),
|
|
2052
|
+
alt: "",
|
|
2053
|
+
style: { width: 28, height: 28, borderRadius: 6, objectFit: "cover" }
|
|
2054
|
+
}
|
|
2055
|
+
) : /* @__PURE__ */ e("div", { style: { width: 28, height: 28, borderRadius: 6, background: "rgba(0,0,0,0.06)" } }),
|
|
2056
|
+
/* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
2057
|
+
/* @__PURE__ */ e("span", { style: { fontWeight: 600 }, children: z(n) }),
|
|
2058
|
+
/* @__PURE__ */ e("span", { style: { opacity: 0.8 }, children: n.description }),
|
|
2059
|
+
de(n) ? /* @__PURE__ */ e("span", { style: { opacity: 0.7, fontSize: "0.8rem" }, children: de(n) }) : null
|
|
2060
|
+
] })
|
|
2061
|
+
] }) }),
|
|
2062
|
+
/* @__PURE__ */ e("td", { children: oe(n.metadata?.product_type) }),
|
|
2063
|
+
/* @__PURE__ */ e("td", { children: fe(n.fiatAmountCents) }),
|
|
2064
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge ${n.active ? "cedros-admin__badge--success" : "cedros-admin__badge--muted"}`, children: n.active ? "Active" : "Inactive" }) }),
|
|
2065
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ t("div", { style: { display: "flex", gap: "0.25rem" }, children: [
|
|
2066
|
+
/* @__PURE__ */ e(
|
|
2067
|
+
"button",
|
|
2068
|
+
{
|
|
2069
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
2070
|
+
onClick: () => c(n),
|
|
2071
|
+
children: "Variations"
|
|
2072
|
+
}
|
|
2073
|
+
),
|
|
2074
|
+
n.metadata?.product_type === "tokenized_asset" && /* @__PURE__ */ e(
|
|
2075
|
+
"button",
|
|
2076
|
+
{
|
|
2077
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
2078
|
+
onClick: () => l(n),
|
|
2079
|
+
children: "NFT"
|
|
2080
|
+
}
|
|
2081
|
+
)
|
|
2082
|
+
] }) })
|
|
2083
|
+
] }, n.id)) })
|
|
2084
|
+
] }) }),
|
|
2085
|
+
f && /* @__PURE__ */ e("div", { className: "cedros-admin__modal-overlay", onClick: () => c(null), children: /* @__PURE__ */ e(
|
|
2086
|
+
"div",
|
|
2087
|
+
{
|
|
2088
|
+
className: "cedros-admin__modal cedros-admin__modal--lg",
|
|
2089
|
+
onClick: (n) => n.stopPropagation(),
|
|
2090
|
+
children: /* @__PURE__ */ e(
|
|
2091
|
+
xe,
|
|
2092
|
+
{
|
|
2093
|
+
serverUrl: p,
|
|
2094
|
+
productId: f.id,
|
|
2095
|
+
productTitle: z(f),
|
|
2096
|
+
defaultPrice: f.fiatAmountCents / 100,
|
|
2097
|
+
apiKey: r,
|
|
2098
|
+
authManager: u,
|
|
2099
|
+
onClose: () => c(null)
|
|
2100
|
+
}
|
|
2101
|
+
)
|
|
2102
|
+
}
|
|
2103
|
+
) }),
|
|
2104
|
+
s && /* @__PURE__ */ e("div", { className: "cedros-admin__modal-overlay", onClick: () => l(null), children: /* @__PURE__ */ e(
|
|
2105
|
+
"div",
|
|
2106
|
+
{
|
|
2107
|
+
className: "cedros-admin__modal cedros-admin__modal--lg",
|
|
2108
|
+
onClick: (n) => n.stopPropagation(),
|
|
2109
|
+
children: /* @__PURE__ */ e(
|
|
2110
|
+
$e,
|
|
2111
|
+
{
|
|
2112
|
+
serverUrl: p,
|
|
2113
|
+
productId: s.id,
|
|
2114
|
+
productTitle: z(s),
|
|
2115
|
+
apiKey: r,
|
|
2116
|
+
authManager: u,
|
|
2117
|
+
onClose: () => l(null)
|
|
2118
|
+
}
|
|
2119
|
+
)
|
|
2120
|
+
}
|
|
2121
|
+
) })
|
|
2122
|
+
] });
|
|
2123
|
+
}
|
|
2124
|
+
function je({ serverUrl: p, apiKey: r, pageSize: v = 20, authManager: u }) {
|
|
2125
|
+
const [g, T] = S([]), [A, $] = S(null), [_, U] = S(!0), [w, C] = S(!0), [I, F] = S(null), [f, c] = S(""), [s, l] = S(null), k = B(async () => {
|
|
2126
|
+
C(!0);
|
|
2127
|
+
try {
|
|
2128
|
+
F(null);
|
|
2129
|
+
let x;
|
|
2130
|
+
if (u?.isAuthenticated())
|
|
2131
|
+
x = await u.fetchWithAuth("/admin/stats");
|
|
2132
|
+
else {
|
|
2133
|
+
const d = { "Content-Type": "application/json" };
|
|
2134
|
+
r && (d["X-API-Key"] = r);
|
|
2135
|
+
const m = await fetch(`${p}/admin/stats`, { headers: d });
|
|
2136
|
+
if (!m.ok) throw new Error(`Failed to fetch stats: ${m.status}`);
|
|
2137
|
+
x = await m.json();
|
|
2138
|
+
}
|
|
2139
|
+
$(x);
|
|
2140
|
+
} catch {
|
|
2141
|
+
$(null), F("Failed to load payment stats");
|
|
2142
|
+
} finally {
|
|
2143
|
+
C(!1);
|
|
2144
|
+
}
|
|
2145
|
+
}, [p, r, u]);
|
|
2146
|
+
Y(() => {
|
|
2147
|
+
k();
|
|
2148
|
+
}, [k]);
|
|
2149
|
+
const y = B(async () => {
|
|
2150
|
+
try {
|
|
2151
|
+
F(null);
|
|
2152
|
+
let x;
|
|
2153
|
+
const d = new URLSearchParams({ limit: v.toString() });
|
|
2154
|
+
f && d.set("method", f);
|
|
2155
|
+
const m = `/admin/transactions?${d}`;
|
|
2156
|
+
if (u?.isAuthenticated())
|
|
2157
|
+
x = await u.fetchWithAuth(m);
|
|
2158
|
+
else {
|
|
2159
|
+
const z = { "Content-Type": "application/json" };
|
|
2160
|
+
r && (z["X-API-Key"] = r);
|
|
2161
|
+
const E = await fetch(`${p}${m}`, { headers: z });
|
|
2162
|
+
if (!E.ok) throw new Error(`Failed to fetch transactions: ${E.status}`);
|
|
2163
|
+
x = await E.json();
|
|
2164
|
+
}
|
|
2165
|
+
T(x.transactions || []);
|
|
2166
|
+
} catch {
|
|
2167
|
+
T([]), F("Failed to load transactions");
|
|
2168
|
+
} finally {
|
|
2169
|
+
U(!1);
|
|
2170
|
+
}
|
|
2171
|
+
}, [p, r, v, f, u]);
|
|
2172
|
+
Y(() => {
|
|
2173
|
+
y();
|
|
2174
|
+
}, [y]);
|
|
2175
|
+
const D = (x, d = "USD") => new Intl.NumberFormat("en-US", { style: "currency", currency: d }).format(x), N = (x) => {
|
|
2176
|
+
l((d) => !d || d.key !== x ? { key: x, direction: "asc" } : { key: x, direction: d.direction === "asc" ? "desc" : "asc" });
|
|
2177
|
+
}, i = (x) => !s || s.key !== x ? /* @__PURE__ */ e("span", { className: "cedros-admin__sort-icon cedros-admin__sort-icon--idle", children: L.chevronUp }) : /* @__PURE__ */ e("span", { className: "cedros-admin__sort-icon", children: s.direction === "asc" ? L.chevronUp : L.chevronDown }), h = H(() => {
|
|
2178
|
+
if (!s) return g;
|
|
2179
|
+
const x = s.direction === "asc" ? 1 : -1, d = (m) => {
|
|
2180
|
+
switch (s.key) {
|
|
2181
|
+
case "resource":
|
|
2182
|
+
return m.resourceId;
|
|
2183
|
+
case "method":
|
|
2184
|
+
return m.method;
|
|
2185
|
+
case "amount":
|
|
2186
|
+
return m.amount;
|
|
2187
|
+
case "status":
|
|
2188
|
+
return m.status;
|
|
2189
|
+
case "date":
|
|
2190
|
+
return new Date(m.paidAt).getTime();
|
|
2191
|
+
case "id":
|
|
2192
|
+
default:
|
|
2193
|
+
return m.id;
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
return [...g].sort((m, z) => {
|
|
2197
|
+
const E = d(m), M = d(z);
|
|
2198
|
+
return typeof E == "number" && typeof M == "number" ? (E - M) * x : String(E).localeCompare(String(M), void 0, { sensitivity: "base" }) * x;
|
|
2199
|
+
});
|
|
2200
|
+
}, [g, s]);
|
|
2201
|
+
return /* @__PURE__ */ t("div", { className: "cedros-admin__page", children: [
|
|
2202
|
+
/* @__PURE__ */ e(re, { message: I, onRetry: () => {
|
|
2203
|
+
k(), y();
|
|
2204
|
+
} }),
|
|
2205
|
+
/* @__PURE__ */ e(
|
|
2206
|
+
pe,
|
|
2207
|
+
{
|
|
2208
|
+
stats: [
|
|
2209
|
+
{ label: "Revenue", value: D(A?.totalRevenue ?? 0) },
|
|
2210
|
+
{ label: "Orders", value: A?.totalTransactions ?? 0 },
|
|
2211
|
+
{ label: "Card", value: D(A?.revenueByMethod.stripe ?? 0), description: `${A?.transactionsByMethod.stripe ?? 0} orders` },
|
|
2212
|
+
{ label: "Crypto", value: D(A?.revenueByMethod.x402 ?? 0), description: `${A?.transactionsByMethod.x402 ?? 0} orders` },
|
|
2213
|
+
{ label: "Credits", value: D(A?.revenueByMethod.credits ?? 0), description: `${A?.transactionsByMethod.credits ?? 0} orders` }
|
|
2214
|
+
],
|
|
2215
|
+
isLoading: w,
|
|
2216
|
+
onRefresh: k
|
|
2217
|
+
}
|
|
2218
|
+
),
|
|
2219
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: [
|
|
2220
|
+
/* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Transaction History" }),
|
|
2221
|
+
/* @__PURE__ */ e(
|
|
2222
|
+
Ne,
|
|
2223
|
+
{
|
|
2224
|
+
value: f,
|
|
2225
|
+
onChange: c,
|
|
2226
|
+
options: [
|
|
2227
|
+
{ value: "", label: "All" },
|
|
2228
|
+
{ value: "stripe", label: "Card" },
|
|
2229
|
+
{ value: "x402", label: "Crypto" },
|
|
2230
|
+
{ value: "credits", label: "Credits" }
|
|
2231
|
+
]
|
|
2232
|
+
}
|
|
2233
|
+
)
|
|
2234
|
+
] }),
|
|
2235
|
+
_ ? /* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
|
|
2236
|
+
L.loading,
|
|
2237
|
+
" Loading transactions..."
|
|
2238
|
+
] }) : /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ t("table", { className: "cedros-admin__table", children: [
|
|
2239
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
|
|
2240
|
+
/* @__PURE__ */ e("th", { "aria-sort": s?.key === "id" ? s?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => N("id"), children: [
|
|
2241
|
+
"ID",
|
|
2242
|
+
i("id")
|
|
2243
|
+
] }) }),
|
|
2244
|
+
/* @__PURE__ */ e("th", { "aria-sort": s?.key === "resource" ? s?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => N("resource"), children: [
|
|
2245
|
+
"Resource",
|
|
2246
|
+
i("resource")
|
|
2247
|
+
] }) }),
|
|
2248
|
+
/* @__PURE__ */ e("th", { "aria-sort": s?.key === "method" ? s?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => N("method"), children: [
|
|
2249
|
+
"Method",
|
|
2250
|
+
i("method")
|
|
2251
|
+
] }) }),
|
|
2252
|
+
/* @__PURE__ */ e("th", { "aria-sort": s?.key === "amount" ? s?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => N("amount"), children: [
|
|
2253
|
+
"Amount",
|
|
2254
|
+
i("amount")
|
|
2255
|
+
] }) }),
|
|
2256
|
+
/* @__PURE__ */ e("th", { "aria-sort": s?.key === "status" ? s?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => N("status"), children: [
|
|
2257
|
+
"Status",
|
|
2258
|
+
i("status")
|
|
2259
|
+
] }) }),
|
|
2260
|
+
/* @__PURE__ */ e("th", { "aria-sort": s?.key === "date" ? s?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => N("date"), children: [
|
|
2261
|
+
"Date",
|
|
2262
|
+
i("date")
|
|
2263
|
+
] }) })
|
|
2264
|
+
] }) }),
|
|
2265
|
+
/* @__PURE__ */ e("tbody", { children: h.map((x) => /* @__PURE__ */ t("tr", { children: [
|
|
2266
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: x.id }) }),
|
|
2267
|
+
/* @__PURE__ */ e("td", { children: x.resourceId }),
|
|
2268
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${x.method}`, children: x.method }) }),
|
|
2269
|
+
/* @__PURE__ */ t("td", { children: [
|
|
2270
|
+
"$",
|
|
2271
|
+
x.amount.toFixed(2),
|
|
2272
|
+
" ",
|
|
2273
|
+
x.currency.toUpperCase()
|
|
2274
|
+
] }),
|
|
2275
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${x.status}`, children: x.status }) }),
|
|
2276
|
+
/* @__PURE__ */ e("td", { children: he(x.paidAt) })
|
|
2277
|
+
] }, x.id)) })
|
|
2278
|
+
] }) })
|
|
2279
|
+
] });
|
|
2280
|
+
}
|
|
2281
|
+
function Ge({ serverUrl: p, apiKey: r, pageSize: v = 20, authManager: u }) {
|
|
2282
|
+
const [g, T] = S([]), [A, $] = S(!0), [_, U] = S(!1), [w, C] = S(!1), [I, F] = S(null), [f, c] = S(null), [s, l] = S({
|
|
2283
|
+
code: "",
|
|
2284
|
+
discountType: "percentage",
|
|
2285
|
+
discountValue: 0,
|
|
2286
|
+
usageLimit: void 0,
|
|
2287
|
+
expiresAt: "",
|
|
2288
|
+
// Scope and targeting
|
|
2289
|
+
scope: "all_products",
|
|
2290
|
+
productIdsCsv: "",
|
|
2291
|
+
categoryIdsCsv: "",
|
|
2292
|
+
// Payment and application
|
|
2293
|
+
paymentMethod: "any",
|
|
2294
|
+
autoApply: !1,
|
|
2295
|
+
appliesAt: "both",
|
|
2296
|
+
startsAt: "",
|
|
2297
|
+
// Advanced fields
|
|
2298
|
+
minimumAmountUsd: "",
|
|
2299
|
+
usageLimitPerCustomer: void 0,
|
|
2300
|
+
firstPurchaseOnly: !1
|
|
2301
|
+
}), k = B(async () => {
|
|
2302
|
+
try {
|
|
2303
|
+
c(null);
|
|
2304
|
+
let d;
|
|
2305
|
+
const m = `/admin/coupons?limit=${v}`;
|
|
2306
|
+
if (u?.isAuthenticated())
|
|
2307
|
+
d = await u.fetchWithAuth(m);
|
|
2308
|
+
else {
|
|
2309
|
+
const z = { "Content-Type": "application/json" };
|
|
2310
|
+
r && (z["X-API-Key"] = r);
|
|
2311
|
+
const E = await fetch(`${p}${m}`, { headers: z });
|
|
2312
|
+
if (!E.ok) throw new Error(`Failed to fetch coupons: ${E.status}`);
|
|
2313
|
+
d = await E.json();
|
|
2314
|
+
}
|
|
2315
|
+
T(d.coupons || []);
|
|
2316
|
+
} catch (d) {
|
|
2317
|
+
se().error("[CouponsSection] Failed to fetch coupons:", d, {
|
|
2318
|
+
serverUrl: p.slice(0, 20) + "...",
|
|
2319
|
+
hasApiKey: !!r
|
|
2320
|
+
}), T([]), c("Failed to load coupons");
|
|
2321
|
+
} finally {
|
|
2322
|
+
$(!1);
|
|
2323
|
+
}
|
|
2324
|
+
}, [p, r, v, u]);
|
|
2325
|
+
Y(() => {
|
|
2326
|
+
k();
|
|
2327
|
+
}, [k]);
|
|
2328
|
+
const y = async (d) => {
|
|
2329
|
+
if (d.preventDefault(), !(!s.code || s.discountValue <= 0)) {
|
|
2330
|
+
C(!0);
|
|
2331
|
+
try {
|
|
2332
|
+
const m = s.minimumAmountUsd ? Math.round(Number(s.minimumAmountUsd) * 100) : void 0, z = s.productIdsCsv.split(",").map((V) => V.trim()).filter(Boolean), E = s.categoryIdsCsv.split(",").map((V) => V.trim()).filter(Boolean), M = {
|
|
2333
|
+
code: s.code,
|
|
2334
|
+
discountType: s.discountType,
|
|
2335
|
+
discountValue: s.discountValue,
|
|
2336
|
+
usageLimit: s.usageLimit,
|
|
2337
|
+
active: !0,
|
|
2338
|
+
usageCount: 0,
|
|
2339
|
+
// Scope and targeting
|
|
2340
|
+
scope: s.scope,
|
|
2341
|
+
...z.length ? { productIds: z } : {},
|
|
2342
|
+
...E.length ? { categoryIds: E } : {},
|
|
2343
|
+
// Payment and application
|
|
2344
|
+
...s.paymentMethod !== "any" ? { paymentMethod: s.paymentMethod } : {},
|
|
2345
|
+
...s.autoApply ? { autoApply: !0 } : {},
|
|
2346
|
+
...s.appliesAt !== "both" ? { appliesAt: s.appliesAt } : {},
|
|
2347
|
+
...s.startsAt ? { startsAt: s.startsAt } : {},
|
|
2348
|
+
...s.expiresAt ? { expiresAt: s.expiresAt } : {},
|
|
2349
|
+
// Advanced
|
|
2350
|
+
...m ? { minimumAmountCents: m } : {},
|
|
2351
|
+
...s.usageLimitPerCustomer ? { usageLimitPerCustomer: s.usageLimitPerCustomer } : {},
|
|
2352
|
+
...s.firstPurchaseOnly ? { firstPurchaseOnly: !0 } : {}
|
|
2353
|
+
};
|
|
2354
|
+
if (u?.isAuthenticated())
|
|
2355
|
+
await u.fetchWithAuth("/admin/coupons", {
|
|
2356
|
+
method: "POST",
|
|
2357
|
+
body: JSON.stringify(M)
|
|
2358
|
+
});
|
|
2359
|
+
else {
|
|
2360
|
+
const V = { "Content-Type": "application/json" };
|
|
2361
|
+
r && (V["X-API-Key"] = r);
|
|
2362
|
+
const ee = await fetch(`${p}/admin/coupons`, {
|
|
2363
|
+
method: "POST",
|
|
2364
|
+
headers: V,
|
|
2365
|
+
body: JSON.stringify(M)
|
|
2366
|
+
});
|
|
2367
|
+
if (!ee.ok) throw new Error(`Failed to create coupon: ${ee.status}`);
|
|
2368
|
+
}
|
|
2369
|
+
l({
|
|
2370
|
+
code: "",
|
|
2371
|
+
discountType: "percentage",
|
|
2372
|
+
discountValue: 0,
|
|
2373
|
+
usageLimit: void 0,
|
|
2374
|
+
expiresAt: "",
|
|
2375
|
+
scope: "all_products",
|
|
2376
|
+
productIdsCsv: "",
|
|
2377
|
+
categoryIdsCsv: "",
|
|
2378
|
+
paymentMethod: "any",
|
|
2379
|
+
autoApply: !1,
|
|
2380
|
+
appliesAt: "both",
|
|
2381
|
+
startsAt: "",
|
|
2382
|
+
minimumAmountUsd: "",
|
|
2383
|
+
usageLimitPerCustomer: void 0,
|
|
2384
|
+
firstPurchaseOnly: !1
|
|
2385
|
+
}), U(!1), k();
|
|
2386
|
+
} catch (m) {
|
|
2387
|
+
se().error("[CouponsSection] Failed to add coupon:", m, {
|
|
2388
|
+
serverUrl: p.slice(0, 20) + "...",
|
|
2389
|
+
hasApiKey: !!r
|
|
2390
|
+
}), c("Failed to create coupon");
|
|
2391
|
+
} finally {
|
|
2392
|
+
C(!1);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
}, D = g.filter((d) => d.active).length, N = g.reduce((d, m) => d + (m.usageCount ?? 0), 0), i = (d) => {
|
|
2396
|
+
F((m) => !m || m.key !== d ? { key: d, direction: "asc" } : { key: d, direction: m.direction === "asc" ? "desc" : "asc" });
|
|
2397
|
+
}, h = (d) => !I || I.key !== d ? /* @__PURE__ */ e("span", { className: "cedros-admin__sort-icon cedros-admin__sort-icon--idle", children: L.chevronUp }) : /* @__PURE__ */ e("span", { className: "cedros-admin__sort-icon", children: I.direction === "asc" ? L.chevronUp : L.chevronDown }), x = H(() => {
|
|
2398
|
+
if (!I) return g;
|
|
2399
|
+
const d = I.direction === "asc" ? 1 : -1, m = (z) => {
|
|
2400
|
+
switch (I.key) {
|
|
2401
|
+
case "discount":
|
|
2402
|
+
return z.discountValue ?? 0;
|
|
2403
|
+
case "usage":
|
|
2404
|
+
return z.usageCount ?? 0;
|
|
2405
|
+
case "status":
|
|
2406
|
+
return z.active ? 1 : 0;
|
|
2407
|
+
case "code":
|
|
2408
|
+
default:
|
|
2409
|
+
return z.code;
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
return [...g].sort((z, E) => {
|
|
2413
|
+
const M = m(z), V = m(E);
|
|
2414
|
+
return typeof M == "number" && typeof V == "number" ? (M - V) * d : String(M).localeCompare(String(V), void 0, { sensitivity: "base" }) * d;
|
|
2415
|
+
});
|
|
2416
|
+
}, [g, I]);
|
|
2417
|
+
return /* @__PURE__ */ t("div", { className: "cedros-admin__page", children: [
|
|
2418
|
+
/* @__PURE__ */ e(re, { message: f, onRetry: k }),
|
|
2419
|
+
/* @__PURE__ */ e(
|
|
2420
|
+
pe,
|
|
2421
|
+
{
|
|
2422
|
+
stats: [
|
|
2423
|
+
{ label: "Total Coupons", value: g.length },
|
|
2424
|
+
{ label: "Active", value: D, variant: D > 0 ? "success" : "muted" },
|
|
2425
|
+
{ label: "Redemptions", value: N }
|
|
2426
|
+
],
|
|
2427
|
+
isLoading: A
|
|
2428
|
+
}
|
|
2429
|
+
),
|
|
2430
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: [
|
|
2431
|
+
/* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Discount Coupons" }),
|
|
2432
|
+
/* @__PURE__ */ t(
|
|
2433
|
+
"button",
|
|
2434
|
+
{
|
|
2435
|
+
className: "cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",
|
|
2436
|
+
onClick: () => U(!_),
|
|
2437
|
+
children: [
|
|
2438
|
+
_ ? L.close : L.plus,
|
|
2439
|
+
_ ? "Cancel" : "Add Coupon"
|
|
2440
|
+
]
|
|
2441
|
+
}
|
|
2442
|
+
)
|
|
2443
|
+
] }),
|
|
2444
|
+
_ && /* @__PURE__ */ t("form", { onSubmit: y, className: "cedros-admin__add-form", children: [
|
|
2445
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
2446
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2447
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Coupon Code" }),
|
|
2448
|
+
/* @__PURE__ */ e(
|
|
2449
|
+
"input",
|
|
2450
|
+
{
|
|
2451
|
+
type: "text",
|
|
2452
|
+
className: "cedros-admin__input",
|
|
2453
|
+
value: s.code,
|
|
2454
|
+
onChange: (d) => l((m) => ({ ...m, code: d.target.value.toUpperCase() })),
|
|
2455
|
+
placeholder: "e.g., SAVE20",
|
|
2456
|
+
required: !0
|
|
2457
|
+
}
|
|
2458
|
+
)
|
|
2459
|
+
] }),
|
|
2460
|
+
/* @__PURE__ */ e(
|
|
2461
|
+
Q,
|
|
2462
|
+
{
|
|
2463
|
+
value: s.discountType,
|
|
2464
|
+
onChange: (d) => l((m) => ({ ...m, discountType: d })),
|
|
2465
|
+
options: [
|
|
2466
|
+
{ value: "percentage", label: "Percentage (%)" },
|
|
2467
|
+
{ value: "fixed", label: "Fixed Amount ($)" }
|
|
2468
|
+
],
|
|
2469
|
+
label: "Discount Type"
|
|
2470
|
+
}
|
|
2471
|
+
)
|
|
2472
|
+
] }),
|
|
2473
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
2474
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2475
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: [
|
|
2476
|
+
"Discount Value ",
|
|
2477
|
+
s.discountType === "percentage" ? "(%)" : "($)"
|
|
2478
|
+
] }),
|
|
2479
|
+
/* @__PURE__ */ e(
|
|
2480
|
+
"input",
|
|
2481
|
+
{
|
|
2482
|
+
type: "number",
|
|
2483
|
+
className: "cedros-admin__input",
|
|
2484
|
+
value: s.discountValue || "",
|
|
2485
|
+
onChange: (d) => l((m) => ({ ...m, discountValue: parseFloat(d.target.value) || 0 })),
|
|
2486
|
+
placeholder: s.discountType === "percentage" ? "e.g., 20" : "e.g., 10.00",
|
|
2487
|
+
min: "0",
|
|
2488
|
+
step: s.discountType === "percentage" ? "1" : "0.01",
|
|
2489
|
+
required: !0
|
|
2490
|
+
}
|
|
2491
|
+
)
|
|
2492
|
+
] }),
|
|
2493
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2494
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Usage Limit (optional)" }),
|
|
2495
|
+
/* @__PURE__ */ e(
|
|
2496
|
+
"input",
|
|
2497
|
+
{
|
|
2498
|
+
type: "number",
|
|
2499
|
+
className: "cedros-admin__input",
|
|
2500
|
+
value: s.usageLimit || "",
|
|
2501
|
+
onChange: (d) => l((m) => ({ ...m, usageLimit: d.target.value ? parseInt(d.target.value) : void 0 })),
|
|
2502
|
+
placeholder: "Leave empty for unlimited",
|
|
2503
|
+
min: "1"
|
|
2504
|
+
}
|
|
2505
|
+
)
|
|
2506
|
+
] }),
|
|
2507
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2508
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Expiration Date (optional)" }),
|
|
2509
|
+
/* @__PURE__ */ e(
|
|
2510
|
+
"input",
|
|
2511
|
+
{
|
|
2512
|
+
type: "date",
|
|
2513
|
+
className: "cedros-admin__input",
|
|
2514
|
+
value: s.expiresAt,
|
|
2515
|
+
onChange: (d) => l((m) => ({ ...m, expiresAt: d.target.value }))
|
|
2516
|
+
}
|
|
2517
|
+
)
|
|
2518
|
+
] })
|
|
2519
|
+
] }),
|
|
2520
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
2521
|
+
/* @__PURE__ */ e(
|
|
2522
|
+
Q,
|
|
2523
|
+
{
|
|
2524
|
+
value: s.scope,
|
|
2525
|
+
onChange: (d) => l((m) => ({ ...m, scope: d })),
|
|
2526
|
+
options: [
|
|
2527
|
+
{ value: "all_products", label: "All Products" },
|
|
2528
|
+
{ value: "specific_products", label: "Specific Products" },
|
|
2529
|
+
{ value: "specific_categories", label: "Specific Categories" }
|
|
2530
|
+
],
|
|
2531
|
+
label: "Scope"
|
|
2532
|
+
}
|
|
2533
|
+
),
|
|
2534
|
+
/* @__PURE__ */ e(
|
|
2535
|
+
Q,
|
|
2536
|
+
{
|
|
2537
|
+
value: s.paymentMethod,
|
|
2538
|
+
onChange: (d) => l((m) => ({ ...m, paymentMethod: d })),
|
|
2539
|
+
options: [
|
|
2540
|
+
{ value: "any", label: "Any Payment Method" },
|
|
2541
|
+
{ value: "stripe", label: "Stripe (Card) Only" },
|
|
2542
|
+
{ value: "x402", label: "Crypto (x402) Only" },
|
|
2543
|
+
{ value: "credits", label: "Credits Only" }
|
|
2544
|
+
],
|
|
2545
|
+
label: "Payment Method"
|
|
2546
|
+
}
|
|
2547
|
+
),
|
|
2548
|
+
/* @__PURE__ */ e(
|
|
2549
|
+
Q,
|
|
2550
|
+
{
|
|
2551
|
+
value: s.appliesAt,
|
|
2552
|
+
onChange: (d) => l((m) => ({ ...m, appliesAt: d })),
|
|
2553
|
+
options: [
|
|
2554
|
+
{ value: "both", label: "Cart & Checkout" },
|
|
2555
|
+
{ value: "cart", label: "Cart Only" },
|
|
2556
|
+
{ value: "checkout", label: "Checkout Only" }
|
|
2557
|
+
],
|
|
2558
|
+
label: "Applies At"
|
|
2559
|
+
}
|
|
2560
|
+
)
|
|
2561
|
+
] }),
|
|
2562
|
+
s.scope === "specific_products" && /* @__PURE__ */ e("div", { className: "cedros-admin__form-row", children: /* @__PURE__ */ t("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
|
|
2563
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Product IDs" }),
|
|
2564
|
+
/* @__PURE__ */ e(
|
|
2565
|
+
"input",
|
|
2566
|
+
{
|
|
2567
|
+
type: "text",
|
|
2568
|
+
className: "cedros-admin__input",
|
|
2569
|
+
value: s.productIdsCsv,
|
|
2570
|
+
onChange: (d) => l((m) => ({ ...m, productIdsCsv: d.target.value })),
|
|
2571
|
+
placeholder: "e.g., prod_123, prod_456"
|
|
2572
|
+
}
|
|
2573
|
+
),
|
|
2574
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "Comma-separated product IDs this coupon applies to." })
|
|
2575
|
+
] }) }),
|
|
2576
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
2577
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2578
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Start Date (optional)" }),
|
|
2579
|
+
/* @__PURE__ */ e(
|
|
2580
|
+
"input",
|
|
2581
|
+
{
|
|
2582
|
+
type: "date",
|
|
2583
|
+
className: "cedros-admin__input",
|
|
2584
|
+
value: s.startsAt,
|
|
2585
|
+
onChange: (d) => l((m) => ({ ...m, startsAt: d.target.value }))
|
|
2586
|
+
}
|
|
2587
|
+
)
|
|
2588
|
+
] }),
|
|
2589
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2590
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Auto Apply" }),
|
|
2591
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
2592
|
+
/* @__PURE__ */ e(
|
|
2593
|
+
"input",
|
|
2594
|
+
{
|
|
2595
|
+
type: "checkbox",
|
|
2596
|
+
checked: s.autoApply,
|
|
2597
|
+
onChange: (d) => l((m) => ({ ...m, autoApply: d.target.checked }))
|
|
2598
|
+
}
|
|
2599
|
+
),
|
|
2600
|
+
"Automatically apply when conditions met"
|
|
2601
|
+
] })
|
|
2602
|
+
] })
|
|
2603
|
+
] }),
|
|
2604
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__form-row", children: [
|
|
2605
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2606
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Minimum Purchase (USD)" }),
|
|
2607
|
+
/* @__PURE__ */ e(
|
|
2608
|
+
"input",
|
|
2609
|
+
{
|
|
2610
|
+
type: "number",
|
|
2611
|
+
className: "cedros-admin__input",
|
|
2612
|
+
value: s.minimumAmountUsd === "" ? "" : s.minimumAmountUsd,
|
|
2613
|
+
onChange: (d) => l((m) => ({ ...m, minimumAmountUsd: d.target.value === "" ? "" : parseFloat(d.target.value) || 0 })),
|
|
2614
|
+
placeholder: "e.g., 50.00",
|
|
2615
|
+
min: "0",
|
|
2616
|
+
step: "0.01"
|
|
2617
|
+
}
|
|
2618
|
+
)
|
|
2619
|
+
] }),
|
|
2620
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2621
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Per-Customer Limit" }),
|
|
2622
|
+
/* @__PURE__ */ e(
|
|
2623
|
+
"input",
|
|
2624
|
+
{
|
|
2625
|
+
type: "number",
|
|
2626
|
+
className: "cedros-admin__input",
|
|
2627
|
+
value: s.usageLimitPerCustomer || "",
|
|
2628
|
+
onChange: (d) => l((m) => ({ ...m, usageLimitPerCustomer: d.target.value ? parseInt(d.target.value) : void 0 })),
|
|
2629
|
+
placeholder: "Leave empty for unlimited",
|
|
2630
|
+
min: "1"
|
|
2631
|
+
}
|
|
2632
|
+
)
|
|
2633
|
+
] }),
|
|
2634
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__field", children: [
|
|
2635
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "First Purchase Only" }),
|
|
2636
|
+
/* @__PURE__ */ t("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
2637
|
+
/* @__PURE__ */ e(
|
|
2638
|
+
"input",
|
|
2639
|
+
{
|
|
2640
|
+
type: "checkbox",
|
|
2641
|
+
checked: s.firstPurchaseOnly,
|
|
2642
|
+
onChange: (d) => l((m) => ({ ...m, firstPurchaseOnly: d.target.checked }))
|
|
2643
|
+
}
|
|
2644
|
+
),
|
|
2645
|
+
"New customers only"
|
|
2646
|
+
] })
|
|
2647
|
+
] })
|
|
2648
|
+
] }),
|
|
2649
|
+
s.scope === "specific_categories" && /* @__PURE__ */ e("div", { className: "cedros-admin__form-row", children: /* @__PURE__ */ t("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
|
|
2650
|
+
/* @__PURE__ */ e("label", { className: "cedros-admin__field-label", children: "Category IDs" }),
|
|
2651
|
+
/* @__PURE__ */ e(
|
|
2652
|
+
"input",
|
|
2653
|
+
{
|
|
2654
|
+
type: "text",
|
|
2655
|
+
className: "cedros-admin__input",
|
|
2656
|
+
value: s.categoryIdsCsv,
|
|
2657
|
+
onChange: (d) => l((m) => ({ ...m, categoryIdsCsv: d.target.value })),
|
|
2658
|
+
placeholder: "e.g., cat_apparel, cat_accessories"
|
|
2659
|
+
}
|
|
2660
|
+
),
|
|
2661
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 4, fontSize: 12, opacity: 0.75 }, children: "Comma-separated category IDs this coupon applies to." })
|
|
2662
|
+
] }) }),
|
|
2663
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__form-actions", children: /* @__PURE__ */ e("button", { type: "submit", className: "cedros-admin__button cedros-admin__button--primary", disabled: w, children: w ? "Creating..." : "Create Coupon" }) })
|
|
2664
|
+
] }),
|
|
2665
|
+
A ? /* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
|
|
2666
|
+
L.loading,
|
|
2667
|
+
" Loading coupons..."
|
|
2668
|
+
] }) : /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ t("table", { className: "cedros-admin__table", children: [
|
|
2669
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
|
|
2670
|
+
/* @__PURE__ */ e("th", { "aria-sort": I?.key === "code" ? I?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => i("code"), children: [
|
|
2671
|
+
"Code",
|
|
2672
|
+
h("code")
|
|
2673
|
+
] }) }),
|
|
2674
|
+
/* @__PURE__ */ e("th", { "aria-sort": I?.key === "discount" ? I?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => i("discount"), children: [
|
|
2675
|
+
"Discount",
|
|
2676
|
+
h("discount")
|
|
2677
|
+
] }) }),
|
|
2678
|
+
/* @__PURE__ */ e("th", { "aria-sort": I?.key === "usage" ? I?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => i("usage"), children: [
|
|
2679
|
+
"Usage",
|
|
2680
|
+
h("usage")
|
|
2681
|
+
] }) }),
|
|
2682
|
+
/* @__PURE__ */ e("th", { "aria-sort": I?.key === "status" ? I?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => i("status"), children: [
|
|
2683
|
+
"Status",
|
|
2684
|
+
h("status")
|
|
2685
|
+
] }) }),
|
|
2686
|
+
/* @__PURE__ */ e("th", { children: "Actions" })
|
|
2687
|
+
] }) }),
|
|
2688
|
+
/* @__PURE__ */ e("tbody", { children: x.map((d) => /* @__PURE__ */ t("tr", { children: [
|
|
2689
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: d.code }) }),
|
|
2690
|
+
/* @__PURE__ */ e("td", { children: d.discountType === "percentage" ? `${d.discountValue}%` : `$${d.discountValue.toFixed(2)}` }),
|
|
2691
|
+
/* @__PURE__ */ t("td", { children: [
|
|
2692
|
+
d.usageCount,
|
|
2693
|
+
d.usageLimit ? ` / ${d.usageLimit}` : ""
|
|
2694
|
+
] }),
|
|
2695
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge ${d.active ? "cedros-admin__badge--success" : "cedros-admin__badge--muted"}`, children: d.active ? "Active" : "Inactive" }) }),
|
|
2696
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("button", { className: "cedros-admin__button cedros-admin__button--ghost", children: "Edit" }) })
|
|
2697
|
+
] }, d.code)) })
|
|
2698
|
+
] }) })
|
|
2699
|
+
] });
|
|
2700
|
+
}
|
|
2701
|
+
function Me({ serverUrl: p, apiKey: r, pageSize: v = 20, authManager: u }) {
|
|
2702
|
+
const [g, T] = S([]), [A, $] = S(!0), [_, U] = S(null), [w, C] = S([]), [I, F] = S(!0), [f, c] = S(null), [s, l] = S([]), [k, y] = S(!0), [D, N] = S(null), [i, h] = S(null), [x, d] = S(null), m = B(async () => {
|
|
2703
|
+
try {
|
|
2704
|
+
let o;
|
|
2705
|
+
const b = `/admin/refunds?limit=${v}`;
|
|
2706
|
+
if (u?.isAuthenticated())
|
|
2707
|
+
o = await u.fetchWithAuth(b);
|
|
2708
|
+
else {
|
|
2709
|
+
const P = { "Content-Type": "application/json" };
|
|
2710
|
+
r && (P["X-API-Key"] = r);
|
|
2711
|
+
const G = await fetch(`${p}${b}`, { headers: P });
|
|
2712
|
+
if (!G.ok) throw new Error(`Failed to fetch x402 refunds: ${G.status}`);
|
|
2713
|
+
o = await G.json();
|
|
2714
|
+
}
|
|
2715
|
+
T(o.refunds || []);
|
|
2716
|
+
} catch (o) {
|
|
2717
|
+
se().error("[RefundsSection] Failed to fetch x402 refunds:", o, {
|
|
2718
|
+
serverUrl: p.slice(0, 20) + "...",
|
|
2719
|
+
hasApiKey: !!r
|
|
2720
|
+
}), T([]), d("Failed to load x402 refunds");
|
|
2721
|
+
} finally {
|
|
2722
|
+
$(!1);
|
|
2723
|
+
}
|
|
2724
|
+
}, [p, r, v, u]);
|
|
2725
|
+
Y(() => {
|
|
2726
|
+
m();
|
|
2727
|
+
}, [m]);
|
|
2728
|
+
const z = B(async () => {
|
|
2729
|
+
try {
|
|
2730
|
+
let o;
|
|
2731
|
+
const b = `/admin/credits/refund-requests?status=pending&limit=${v}&offset=0`;
|
|
2732
|
+
if (u?.isAuthenticated())
|
|
2733
|
+
o = await u.fetchWithAuth(b);
|
|
2734
|
+
else {
|
|
2735
|
+
const G = { "Content-Type": "application/json" };
|
|
2736
|
+
r && (G["X-API-Key"] = r);
|
|
2737
|
+
const W = await fetch(`${p}${b}`, { headers: G });
|
|
2738
|
+
if (!W.ok) throw new Error(`Failed to fetch credits refund requests: ${W.status}`);
|
|
2739
|
+
o = await W.json();
|
|
2740
|
+
}
|
|
2741
|
+
const P = Array.isArray(o) ? o : "refundRequests" in o ? o.refundRequests : o.requests || [];
|
|
2742
|
+
C(P);
|
|
2743
|
+
} catch (o) {
|
|
2744
|
+
se().error("[RefundsSection] Failed to fetch credits refunds:", o, {
|
|
2745
|
+
serverUrl: p.slice(0, 20) + "...",
|
|
2746
|
+
hasApiKey: !!r
|
|
2747
|
+
}), C([]), d("Failed to load credits refunds");
|
|
2748
|
+
} finally {
|
|
2749
|
+
F(!1);
|
|
2750
|
+
}
|
|
2751
|
+
}, [p, r, v, u]);
|
|
2752
|
+
Y(() => {
|
|
2753
|
+
z();
|
|
2754
|
+
}, [z]);
|
|
2755
|
+
const E = B(async () => {
|
|
2756
|
+
try {
|
|
2757
|
+
let o;
|
|
2758
|
+
const b = `/admin/stripe/refunds?limit=${v}`;
|
|
2759
|
+
if (u?.isAuthenticated())
|
|
2760
|
+
o = await u.fetchWithAuth(b);
|
|
2761
|
+
else {
|
|
2762
|
+
const P = { "Content-Type": "application/json" };
|
|
2763
|
+
r && (P["X-API-Key"] = r);
|
|
2764
|
+
const G = await fetch(`${p}${b}`, { headers: P });
|
|
2765
|
+
if (!G.ok) throw new Error(`Failed to fetch Stripe refunds: ${G.status}`);
|
|
2766
|
+
o = await G.json();
|
|
2767
|
+
}
|
|
2768
|
+
l(o.refunds || []);
|
|
2769
|
+
} catch (o) {
|
|
2770
|
+
se().error("[RefundsSection] Failed to fetch Stripe refunds:", o, {
|
|
2771
|
+
serverUrl: p.slice(0, 20) + "...",
|
|
2772
|
+
hasApiKey: !!r
|
|
2773
|
+
}), l([]), d("Failed to load Stripe refunds");
|
|
2774
|
+
} finally {
|
|
2775
|
+
y(!1);
|
|
2776
|
+
}
|
|
2777
|
+
}, [p, r, v, u]);
|
|
2778
|
+
Y(() => {
|
|
2779
|
+
E();
|
|
2780
|
+
}, [E]);
|
|
2781
|
+
const M = async (o) => {
|
|
2782
|
+
N(o);
|
|
2783
|
+
try {
|
|
2784
|
+
const b = `/admin/stripe/refunds/${o}/process`;
|
|
2785
|
+
if (u?.isAuthenticated())
|
|
2786
|
+
await u.fetchWithAuth(b, { method: "POST" });
|
|
2787
|
+
else {
|
|
2788
|
+
const P = { "Content-Type": "application/json" };
|
|
2789
|
+
r && (P["X-API-Key"] = r);
|
|
2790
|
+
const G = await fetch(`${p}${b}`, { method: "POST", headers: P });
|
|
2791
|
+
if (!G.ok) throw new Error(`Failed to process refund: ${G.status}`);
|
|
2792
|
+
}
|
|
2793
|
+
await E();
|
|
2794
|
+
} catch (b) {
|
|
2795
|
+
se().error("[RefundsSection] Failed to process Stripe refund:", b, {
|
|
2796
|
+
serverUrl: p.slice(0, 20) + "...",
|
|
2797
|
+
hasApiKey: !!r,
|
|
2798
|
+
refundId: o
|
|
2799
|
+
}), d("Failed to process Stripe refund");
|
|
2800
|
+
} finally {
|
|
2801
|
+
N(null);
|
|
2802
|
+
}
|
|
2803
|
+
}, V = (o, b) => new Intl.NumberFormat("en-US", { style: "currency", currency: b }).format(o / 100), ee = (o) => o ? o.replace(/_/g, " ").replace(/\b\w/g, (b) => b.toUpperCase()) : "—", ge = (o) => {
|
|
2804
|
+
switch (o) {
|
|
2805
|
+
case "processed":
|
|
2806
|
+
return "success";
|
|
2807
|
+
case "pending":
|
|
2808
|
+
return "pending";
|
|
2809
|
+
case "rejected":
|
|
2810
|
+
default:
|
|
2811
|
+
return "muted";
|
|
2812
|
+
}
|
|
2813
|
+
}, de = (o, b) => b ? b.toLowerCase() === "usd" ? `${new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(o / 1e6)} (USD credits)` : `${o.toLocaleString()} ${b.toUpperCase()} (atomic)` : `${o.toLocaleString()} (atomic)`, ie = (o) => {
|
|
2814
|
+
switch (o) {
|
|
2815
|
+
case "succeeded":
|
|
2816
|
+
return "success";
|
|
2817
|
+
case "failed":
|
|
2818
|
+
return "failed";
|
|
2819
|
+
case "pending":
|
|
2820
|
+
case "requires_action":
|
|
2821
|
+
return "pending";
|
|
2822
|
+
case "canceled":
|
|
2823
|
+
default:
|
|
2824
|
+
return "muted";
|
|
2825
|
+
}
|
|
2826
|
+
}, _e = (o) => o.stripeRefundId ?? "—", fe = (o) => o.chargeId ?? "—", oe = s.filter((o) => o.status === "pending" || o.status === "requires_action").length, ce = w.filter((o) => o.status === "pending").length, ae = g.filter((o) => o.status === "pending").length, te = oe + ce + ae, ne = s.filter((o) => o.status === "succeeded").reduce((o, b) => o + b.amount, 0), ye = w.filter((o) => o.status === "processed").reduce((o, b) => o + b.amountLamports, 0), n = g.filter((o) => o.status === "completed").reduce((o, b) => o + b.amount, 0), a = ne / 100 + ye / 1e6 + n, R = (o) => new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(o), X = k || I || A, j = (o) => {
|
|
2827
|
+
h((b) => !b || b.key !== o ? { key: o, direction: "asc" } : { key: o, direction: b.direction === "asc" ? "desc" : "asc" });
|
|
2828
|
+
}, q = (o) => {
|
|
2829
|
+
c((b) => !b || b.key !== o ? { key: o, direction: "asc" } : { key: o, direction: b.direction === "asc" ? "desc" : "asc" });
|
|
2830
|
+
}, J = (o) => {
|
|
2831
|
+
U((b) => !b || b.key !== o ? { key: o, direction: "asc" } : { key: o, direction: b.direction === "asc" ? "desc" : "asc" });
|
|
2832
|
+
}, O = (o, b) => !o || !b ? /* @__PURE__ */ e("span", { className: "cedros-admin__sort-icon cedros-admin__sort-icon--idle", children: L.chevronUp }) : /* @__PURE__ */ e("span", { className: "cedros-admin__sort-icon", children: b === "asc" ? L.chevronUp : L.chevronDown }), Z = H(() => {
|
|
2833
|
+
if (!i) return s;
|
|
2834
|
+
const o = i.direction === "asc" ? 1 : -1, b = (P) => {
|
|
2835
|
+
switch (i.key) {
|
|
2836
|
+
case "stripe":
|
|
2837
|
+
return P.stripeRefundId ?? "";
|
|
2838
|
+
case "charge":
|
|
2839
|
+
return P.chargeId ?? "";
|
|
2840
|
+
case "amount":
|
|
2841
|
+
return P.amount ?? 0;
|
|
2842
|
+
case "reason":
|
|
2843
|
+
return P.reason ?? "";
|
|
2844
|
+
case "status":
|
|
2845
|
+
return P.status ?? "";
|
|
2846
|
+
case "date":
|
|
2847
|
+
return new Date(P.createdAt).getTime();
|
|
2848
|
+
case "id":
|
|
2849
|
+
default:
|
|
2850
|
+
return P.id;
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
return [...s].sort((P, G) => {
|
|
2854
|
+
const W = b(P), K = b(G);
|
|
2855
|
+
return typeof W == "number" && typeof K == "number" ? (W - K) * o : String(W).localeCompare(String(K), void 0, { sensitivity: "base" }) * o;
|
|
2856
|
+
});
|
|
2857
|
+
}, [s, i]), le = H(() => {
|
|
2858
|
+
if (!f) return w;
|
|
2859
|
+
const o = f.direction === "asc" ? 1 : -1, b = (P) => {
|
|
2860
|
+
switch (f.key) {
|
|
2861
|
+
case "original":
|
|
2862
|
+
return P.originalTransactionId ?? "";
|
|
2863
|
+
case "user":
|
|
2864
|
+
return P.userId ?? "";
|
|
2865
|
+
case "amount":
|
|
2866
|
+
return P.amountLamports ?? 0;
|
|
2867
|
+
case "reason":
|
|
2868
|
+
return P.reason ?? "";
|
|
2869
|
+
case "status":
|
|
2870
|
+
return P.status ?? "";
|
|
2871
|
+
case "date":
|
|
2872
|
+
return new Date(P.createdAt).getTime();
|
|
2873
|
+
case "id":
|
|
2874
|
+
default:
|
|
2875
|
+
return P.id;
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
return [...w].sort((P, G) => {
|
|
2879
|
+
const W = b(P), K = b(G);
|
|
2880
|
+
return typeof W == "number" && typeof K == "number" ? (W - K) * o : String(W).localeCompare(String(K), void 0, { sensitivity: "base" }) * o;
|
|
2881
|
+
});
|
|
2882
|
+
}, [w, f]), ue = H(() => {
|
|
2883
|
+
if (!_) return g;
|
|
2884
|
+
const o = _.direction === "asc" ? 1 : -1, b = (P) => {
|
|
2885
|
+
switch (_.key) {
|
|
2886
|
+
case "transaction":
|
|
2887
|
+
return P.transactionId ?? "";
|
|
2888
|
+
case "amount":
|
|
2889
|
+
return P.amount ?? 0;
|
|
2890
|
+
case "reason":
|
|
2891
|
+
return P.reason ?? "";
|
|
2892
|
+
case "status":
|
|
2893
|
+
return P.status ?? "";
|
|
2894
|
+
case "date":
|
|
2895
|
+
return new Date(P.createdAt).getTime();
|
|
2896
|
+
case "id":
|
|
2897
|
+
default:
|
|
2898
|
+
return P.id;
|
|
2899
|
+
}
|
|
2900
|
+
};
|
|
2901
|
+
return [...g].sort((P, G) => {
|
|
2902
|
+
const W = b(P), K = b(G);
|
|
2903
|
+
return typeof W == "number" && typeof K == "number" ? (W - K) * o : String(W).localeCompare(String(K), void 0, { sensitivity: "base" }) * o;
|
|
2904
|
+
});
|
|
2905
|
+
}, [g, _]);
|
|
2906
|
+
return /* @__PURE__ */ t("div", { className: "cedros-admin__page", children: [
|
|
2907
|
+
/* @__PURE__ */ e(re, { message: x, onRetry: () => {
|
|
2908
|
+
m(), z(), E();
|
|
2909
|
+
} }),
|
|
2910
|
+
/* @__PURE__ */ e(
|
|
2911
|
+
pe,
|
|
2912
|
+
{
|
|
2913
|
+
stats: [
|
|
2914
|
+
{ label: "Pending", value: te, variant: te > 0 ? "warning" : "muted" },
|
|
2915
|
+
{ label: "Card Pending", value: oe, description: "Stripe" },
|
|
2916
|
+
{ label: "Credits Pending", value: ce },
|
|
2917
|
+
{ label: "Crypto Pending", value: ae, description: "x402" },
|
|
2918
|
+
{ label: "Total Refunded", value: R(a), variant: "success" }
|
|
2919
|
+
],
|
|
2920
|
+
isLoading: X
|
|
2921
|
+
}
|
|
2922
|
+
),
|
|
2923
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Stripe Refund Requests" }) }),
|
|
2924
|
+
k ? /* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
|
|
2925
|
+
L.loading,
|
|
2926
|
+
" Loading Stripe refunds..."
|
|
2927
|
+
] }) : s.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No Stripe refund requests found." }) : /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ t("table", { className: "cedros-admin__table", children: [
|
|
2928
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
|
|
2929
|
+
/* @__PURE__ */ e("th", { "aria-sort": i?.key === "id" ? i?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => j("id"), children: [
|
|
2930
|
+
"Request ID",
|
|
2931
|
+
O(i?.key === "id", i?.direction)
|
|
2932
|
+
] }) }),
|
|
2933
|
+
/* @__PURE__ */ e("th", { "aria-sort": i?.key === "stripe" ? i?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => j("stripe"), children: [
|
|
2934
|
+
"Stripe Refund ID",
|
|
2935
|
+
O(i?.key === "stripe", i?.direction)
|
|
2936
|
+
] }) }),
|
|
2937
|
+
/* @__PURE__ */ e("th", { "aria-sort": i?.key === "charge" ? i?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => j("charge"), children: [
|
|
2938
|
+
"Charge",
|
|
2939
|
+
O(i?.key === "charge", i?.direction)
|
|
2940
|
+
] }) }),
|
|
2941
|
+
/* @__PURE__ */ e("th", { "aria-sort": i?.key === "amount" ? i?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => j("amount"), children: [
|
|
2942
|
+
"Amount",
|
|
2943
|
+
O(i?.key === "amount", i?.direction)
|
|
2944
|
+
] }) }),
|
|
2945
|
+
/* @__PURE__ */ e("th", { "aria-sort": i?.key === "reason" ? i?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => j("reason"), children: [
|
|
2946
|
+
"Reason",
|
|
2947
|
+
O(i?.key === "reason", i?.direction)
|
|
2948
|
+
] }) }),
|
|
2949
|
+
/* @__PURE__ */ e("th", { "aria-sort": i?.key === "status" ? i?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => j("status"), children: [
|
|
2950
|
+
"Status",
|
|
2951
|
+
O(i?.key === "status", i?.direction)
|
|
2952
|
+
] }) }),
|
|
2953
|
+
/* @__PURE__ */ e("th", { "aria-sort": i?.key === "date" ? i?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => j("date"), children: [
|
|
2954
|
+
"Date",
|
|
2955
|
+
O(i?.key === "date", i?.direction)
|
|
2956
|
+
] }) }),
|
|
2957
|
+
/* @__PURE__ */ e("th", { children: "Actions" })
|
|
2958
|
+
] }) }),
|
|
2959
|
+
/* @__PURE__ */ e("tbody", { children: Z.map((o) => /* @__PURE__ */ t("tr", { children: [
|
|
2960
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: o.id }) }),
|
|
2961
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: _e(o) }) }),
|
|
2962
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: fe(o) }) }),
|
|
2963
|
+
/* @__PURE__ */ e("td", { children: V(o.amount, o.currency) }),
|
|
2964
|
+
/* @__PURE__ */ e("td", { children: ee(o.reason) }),
|
|
2965
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${ie(o.status)}`, children: o.status }) }),
|
|
2966
|
+
/* @__PURE__ */ e("td", { children: he(o.createdAt) }),
|
|
2967
|
+
/* @__PURE__ */ e("td", { children: (o.status === "pending" || o.status === "requires_action") && /* @__PURE__ */ e(
|
|
2968
|
+
"button",
|
|
2969
|
+
{
|
|
2970
|
+
className: "cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",
|
|
2971
|
+
onClick: () => M(o.id),
|
|
2972
|
+
disabled: D === o.id,
|
|
2973
|
+
children: D === o.id ? "Processing..." : "Process"
|
|
2974
|
+
}
|
|
2975
|
+
) })
|
|
2976
|
+
] }, o.id)) })
|
|
2977
|
+
] }) }),
|
|
2978
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", style: { marginTop: "2rem" }, children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Credits Refund Requests" }) }),
|
|
2979
|
+
/* @__PURE__ */ e("p", { className: "cedros-admin__hint", style: { marginBottom: "0.75rem" }, children: "Credits refund requests are read-only in this admin surface." }),
|
|
2980
|
+
I ? /* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
|
|
2981
|
+
L.loading,
|
|
2982
|
+
" Loading credits refunds..."
|
|
2983
|
+
] }) : w.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No credits refund requests found." }) : /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ t("table", { className: "cedros-admin__table", children: [
|
|
2984
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
|
|
2985
|
+
/* @__PURE__ */ e("th", { "aria-sort": f?.key === "id" ? f?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => q("id"), children: [
|
|
2986
|
+
"Request ID",
|
|
2987
|
+
O(f?.key === "id", f?.direction)
|
|
2988
|
+
] }) }),
|
|
2989
|
+
/* @__PURE__ */ e("th", { "aria-sort": f?.key === "original" ? f?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => q("original"), children: [
|
|
2990
|
+
"Original Tx",
|
|
2991
|
+
O(f?.key === "original", f?.direction)
|
|
2992
|
+
] }) }),
|
|
2993
|
+
/* @__PURE__ */ e("th", { "aria-sort": f?.key === "user" ? f?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => q("user"), children: [
|
|
2994
|
+
"User",
|
|
2995
|
+
O(f?.key === "user", f?.direction)
|
|
2996
|
+
] }) }),
|
|
2997
|
+
/* @__PURE__ */ e("th", { "aria-sort": f?.key === "amount" ? f?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => q("amount"), children: [
|
|
2998
|
+
"Amount",
|
|
2999
|
+
O(f?.key === "amount", f?.direction)
|
|
3000
|
+
] }) }),
|
|
3001
|
+
/* @__PURE__ */ e("th", { "aria-sort": f?.key === "reason" ? f?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => q("reason"), children: [
|
|
3002
|
+
"Reason",
|
|
3003
|
+
O(f?.key === "reason", f?.direction)
|
|
3004
|
+
] }) }),
|
|
3005
|
+
/* @__PURE__ */ e("th", { "aria-sort": f?.key === "status" ? f?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => q("status"), children: [
|
|
3006
|
+
"Status",
|
|
3007
|
+
O(f?.key === "status", f?.direction)
|
|
3008
|
+
] }) }),
|
|
3009
|
+
/* @__PURE__ */ e("th", { "aria-sort": f?.key === "date" ? f?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => q("date"), children: [
|
|
3010
|
+
"Date",
|
|
3011
|
+
O(f?.key === "date", f?.direction)
|
|
3012
|
+
] }) })
|
|
3013
|
+
] }) }),
|
|
3014
|
+
/* @__PURE__ */ e("tbody", { children: le.map((o) => /* @__PURE__ */ t("tr", { children: [
|
|
3015
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: o.id }) }),
|
|
3016
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: o.originalTransactionId }) }),
|
|
3017
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: o.userId ?? "—" }) }),
|
|
3018
|
+
/* @__PURE__ */ e("td", { children: de(o.amountLamports, o.currency) }),
|
|
3019
|
+
/* @__PURE__ */ e("td", { children: o.reason ?? "—" }),
|
|
3020
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${ge(o.status)}`, children: o.status }) }),
|
|
3021
|
+
/* @__PURE__ */ e("td", { children: he(o.createdAt) })
|
|
3022
|
+
] }, o.id)) })
|
|
3023
|
+
] }) }),
|
|
3024
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", style: { marginTop: "2rem" }, children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "x402 Refund Requests" }) }),
|
|
3025
|
+
/* @__PURE__ */ e("p", { className: "cedros-admin__hint", style: { marginBottom: "0.75rem" }, children: "x402 refund approvals use the signed refund workflow, not this dashboard table." }),
|
|
3026
|
+
A ? /* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
|
|
3027
|
+
L.loading,
|
|
3028
|
+
" Loading x402 refunds..."
|
|
3029
|
+
] }) : g.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No x402 refund requests found." }) : /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ t("table", { className: "cedros-admin__table", children: [
|
|
3030
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
|
|
3031
|
+
/* @__PURE__ */ e("th", { "aria-sort": _?.key === "id" ? _?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => J("id"), children: [
|
|
3032
|
+
"ID",
|
|
3033
|
+
O(_?.key === "id", _?.direction)
|
|
3034
|
+
] }) }),
|
|
3035
|
+
/* @__PURE__ */ e("th", { "aria-sort": _?.key === "transaction" ? _?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => J("transaction"), children: [
|
|
3036
|
+
"Transaction",
|
|
3037
|
+
O(_?.key === "transaction", _?.direction)
|
|
3038
|
+
] }) }),
|
|
3039
|
+
/* @__PURE__ */ e("th", { "aria-sort": _?.key === "amount" ? _?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => J("amount"), children: [
|
|
3040
|
+
"Amount",
|
|
3041
|
+
O(_?.key === "amount", _?.direction)
|
|
3042
|
+
] }) }),
|
|
3043
|
+
/* @__PURE__ */ e("th", { "aria-sort": _?.key === "reason" ? _?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => J("reason"), children: [
|
|
3044
|
+
"Reason",
|
|
3045
|
+
O(_?.key === "reason", _?.direction)
|
|
3046
|
+
] }) }),
|
|
3047
|
+
/* @__PURE__ */ e("th", { "aria-sort": _?.key === "status" ? _?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => J("status"), children: [
|
|
3048
|
+
"Status",
|
|
3049
|
+
O(_?.key === "status", _?.direction)
|
|
3050
|
+
] }) }),
|
|
3051
|
+
/* @__PURE__ */ e("th", { "aria-sort": _?.key === "date" ? _?.direction === "asc" ? "ascending" : "descending" : "none", children: /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__table-sort", onClick: () => J("date"), children: [
|
|
3052
|
+
"Date",
|
|
3053
|
+
O(_?.key === "date", _?.direction)
|
|
3054
|
+
] }) })
|
|
3055
|
+
] }) }),
|
|
3056
|
+
/* @__PURE__ */ e("tbody", { children: ue.map((o) => /* @__PURE__ */ t("tr", { children: [
|
|
3057
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: o.id }) }),
|
|
3058
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: o.transactionId }) }),
|
|
3059
|
+
/* @__PURE__ */ t("td", { children: [
|
|
3060
|
+
"$",
|
|
3061
|
+
o.amount.toFixed(2)
|
|
3062
|
+
] }),
|
|
3063
|
+
/* @__PURE__ */ e("td", { children: o.reason || "—" }),
|
|
3064
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${o.status}`, children: o.status }) }),
|
|
3065
|
+
/* @__PURE__ */ e("td", { children: he(o.createdAt) })
|
|
3066
|
+
] }, o.id)) })
|
|
3067
|
+
] }) })
|
|
3068
|
+
] });
|
|
3069
|
+
}
|
|
3070
|
+
const Fe = Se(
|
|
3071
|
+
() => import("./SettingsSection-DoeNDbqd.mjs").then((p) => ({ default: p.SettingsSection }))
|
|
3072
|
+
);
|
|
3073
|
+
function We(p) {
|
|
3074
|
+
return /* @__PURE__ */ e(ke, { fallback: null, children: /* @__PURE__ */ e(Fe, { ...p }) });
|
|
3075
|
+
}
|
|
3076
|
+
export {
|
|
3077
|
+
Ge as C,
|
|
3078
|
+
qe as P,
|
|
3079
|
+
Me as R,
|
|
3080
|
+
We as S,
|
|
3081
|
+
je as T
|
|
3082
|
+
};
|