@cedros/pay-react 1.1.20 → 1.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/{AISettingsSection-BH-RXvk1.mjs → AISettingsSection-8eDaxYp8.mjs} +2 -2
- package/dist/{AISettingsSection-f5K0nUoQ.js → AISettingsSection-BXWZcMQT.js} +1 -1
- package/dist/{AutosaveIndicator-DTOaopUP.mjs → AutosaveIndicator-3S7EvXip.mjs} +1 -1
- package/dist/{AutosaveIndicator-CpTVtJIz.js → AutosaveIndicator-DW4IPbZ5.js} +1 -1
- package/dist/{FAQSection-BO7ZfQMN.mjs → FAQSection-Dg-I7Z-N.mjs} +1 -1
- package/dist/{FAQSection-CVJ5w6cB.js → FAQSection-r6eKjfdO.js} +1 -1
- package/dist/MessagingSection-Cld5Q7ZM.js +1 -0
- package/dist/{MessagingSection-CmFYFdaw.mjs → MessagingSection-D39EuOLN.mjs} +143 -96
- package/dist/{PaymentSettingsSection-BKDiep-C.js → PaymentSettingsSection-B-MRsh1K.js} +1 -1
- package/dist/{PaymentSettingsSection-VDcgpOkp.mjs → PaymentSettingsSection-CEGHN6VI.mjs} +1 -1
- package/dist/{SettingsSection-B0TpaIOG.mjs → SettingsSection-CPFOuoZG.mjs} +1 -1
- package/dist/{SettingsSection-DSlW47o4.js → SettingsSection-ZrzfLBlS.js} +1 -1
- package/dist/{SingleCategorySettings-Cwlehl0u.mjs → SingleCategorySettings-DhHGIGwB.mjs} +50 -46
- package/dist/SingleCategorySettings-DxjCafCk.js +3 -0
- package/dist/{StorefrontSection-DfN5yxkV.js → StorefrontSection-DGVcJu1T.js} +1 -1
- package/dist/{StorefrontSection-BAY9V1j6.mjs → StorefrontSection-f54ySA6i.mjs} +2 -2
- package/dist/{SubscriptionsSection-D_RKCILr.mjs → SubscriptionsSection-F2IiU2jv.mjs} +1 -1
- package/dist/{SubscriptionsSection-BboudRYv.js → SubscriptionsSection-fzbL5DGC.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +133 -130
- package/dist/{index-B5ck27xb.js → index-7YUxR4u5.js} +10 -10
- package/dist/{index-75RhiLDq.mjs → index-bqhsxBTY.mjs} +3116 -3099
- package/dist/index.js +1 -1
- package/dist/index.mjs +51 -48
- package/dist/sections-CiAMjlPd.mjs +8 -0
- package/dist/{sections-BCdzdqlG.js → sections-Dh0qFSUW.js} +1 -1
- package/dist/src/admin/index.d.ts +2 -0
- package/dist/src/admin/index.d.ts.map +1 -1
- package/dist/src/admin/sectionIds.d.ts +43 -0
- package/dist/src/admin/sectionIds.d.ts.map +1 -0
- package/dist/src/components/admin/MessagingSection.d.ts.map +1 -1
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/emailProviders.d.ts +18 -0
- package/dist/src/components/admin/emailProviders.d.ts.map +1 -0
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/MessagingSection-CRFtSoE8.js +0 -1
- package/dist/SingleCategorySettings-BTXR7zex.js +0 -3
- package/dist/sections-BIBMX6KS.mjs +0 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as o, jsx as t, Fragment as U } from "react/jsx-runtime";
|
|
2
2
|
import { useState as k, useEffect as V, useMemo as H, useCallback as I } from "react";
|
|
3
|
-
import { I as T, F as Z, E as Q,
|
|
3
|
+
import { I as T, F as Z, E as Q, g as ee } from "./index-bqhsxBTY.mjs";
|
|
4
4
|
import { u as te } from "./useAutosave-YwMqRzqy.mjs";
|
|
5
|
-
import { A as re } from "./AutosaveIndicator-
|
|
5
|
+
import { A as re } from "./AutosaveIndicator-3S7EvXip.mjs";
|
|
6
6
|
import { S as O } from "./CedrosContext-BE6P5PQ0.mjs";
|
|
7
7
|
class ie {
|
|
8
8
|
constructor(s, d, n) {
|
|
@@ -301,6 +301,10 @@ const F = {
|
|
|
301
301
|
type: "boolean",
|
|
302
302
|
description: "Send order confirmation emails to customers."
|
|
303
303
|
},
|
|
304
|
+
email_provider: {
|
|
305
|
+
description: "Email service provider (mailgun, sendgrid, postmark, ses, resend, custom).",
|
|
306
|
+
showWhen: "email_enabled"
|
|
307
|
+
},
|
|
304
308
|
smtp_host: {
|
|
305
309
|
description: "SMTP server hostname.",
|
|
306
310
|
showWhen: "email_enabled"
|
|
@@ -423,8 +427,8 @@ function oe({
|
|
|
423
427
|
onChange: d,
|
|
424
428
|
decimals: n,
|
|
425
429
|
onDecimalsChange: S,
|
|
426
|
-
disabled:
|
|
427
|
-
description:
|
|
430
|
+
disabled: l = !1,
|
|
431
|
+
description: c,
|
|
428
432
|
customSymbol: m = "",
|
|
429
433
|
customIcon: h = "",
|
|
430
434
|
onCustomSymbolChange: p,
|
|
@@ -448,7 +452,7 @@ function oe({
|
|
|
448
452
|
{
|
|
449
453
|
type: "button",
|
|
450
454
|
onClick: () => C(e),
|
|
451
|
-
disabled:
|
|
455
|
+
disabled: l,
|
|
452
456
|
style: {
|
|
453
457
|
display: "flex",
|
|
454
458
|
alignItems: "center",
|
|
@@ -457,8 +461,8 @@ function oe({
|
|
|
457
461
|
border: s === e ? "2px solid var(--cedros-admin-primary, #171717)" : "1px solid var(--cedros-admin-border, #d4d4d4)",
|
|
458
462
|
borderRadius: "0.5rem",
|
|
459
463
|
background: s === e ? "var(--cedros-admin-primary-bg, #f5f5f5)" : "var(--cedros-admin-bg, #fff)",
|
|
460
|
-
cursor:
|
|
461
|
-
opacity:
|
|
464
|
+
cursor: l ? "not-allowed" : "pointer",
|
|
465
|
+
opacity: l ? 0.5 : 1,
|
|
462
466
|
fontWeight: s === e ? 600 : 400
|
|
463
467
|
},
|
|
464
468
|
children: [
|
|
@@ -483,7 +487,7 @@ function oe({
|
|
|
483
487
|
{
|
|
484
488
|
type: "button",
|
|
485
489
|
onClick: () => C("custom"),
|
|
486
|
-
disabled:
|
|
490
|
+
disabled: l,
|
|
487
491
|
style: {
|
|
488
492
|
display: "flex",
|
|
489
493
|
alignItems: "center",
|
|
@@ -492,8 +496,8 @@ function oe({
|
|
|
492
496
|
border: x ? "2px solid var(--cedros-admin-primary, #171717)" : "1px solid var(--cedros-admin-border, #d4d4d4)",
|
|
493
497
|
borderRadius: "0.5rem",
|
|
494
498
|
background: x ? "var(--cedros-admin-primary-bg, #f5f5f5)" : "var(--cedros-admin-bg, #fff)",
|
|
495
|
-
cursor:
|
|
496
|
-
opacity:
|
|
499
|
+
cursor: l ? "not-allowed" : "pointer",
|
|
500
|
+
opacity: l ? 0.5 : 1,
|
|
497
501
|
fontWeight: x ? 600 : 400
|
|
498
502
|
},
|
|
499
503
|
children: [
|
|
@@ -531,7 +535,7 @@ function oe({
|
|
|
531
535
|
value: s,
|
|
532
536
|
onChange: (i) => d(i.target.value),
|
|
533
537
|
placeholder: "e.g., EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
534
|
-
disabled:
|
|
538
|
+
disabled: l,
|
|
535
539
|
style: {
|
|
536
540
|
fontFamily: "monospace",
|
|
537
541
|
fontSize: "0.875rem",
|
|
@@ -559,7 +563,7 @@ function oe({
|
|
|
559
563
|
value: m,
|
|
560
564
|
onChange: (e) => p?.(e.target.value),
|
|
561
565
|
placeholder: "e.g., MYTOKEN",
|
|
562
|
-
disabled:
|
|
566
|
+
disabled: l,
|
|
563
567
|
style: { textTransform: "uppercase" }
|
|
564
568
|
}
|
|
565
569
|
)
|
|
@@ -581,7 +585,7 @@ function oe({
|
|
|
581
585
|
value: h,
|
|
582
586
|
onChange: (e) => y?.(e.target.value),
|
|
583
587
|
placeholder: "https://example.com/token-logo.png",
|
|
584
|
-
disabled:
|
|
588
|
+
disabled: l,
|
|
585
589
|
style: { flex: 1 }
|
|
586
590
|
}
|
|
587
591
|
),
|
|
@@ -626,7 +630,7 @@ function oe({
|
|
|
626
630
|
onChange: (e) => S?.(parseInt(e.target.value, 10) || 0),
|
|
627
631
|
min: 0,
|
|
628
632
|
max: 18,
|
|
629
|
-
disabled:
|
|
633
|
+
disabled: l,
|
|
630
634
|
style: { width: "100px" }
|
|
631
635
|
}
|
|
632
636
|
),
|
|
@@ -643,11 +647,11 @@ function oe({
|
|
|
643
647
|
fontFamily: "monospace",
|
|
644
648
|
wordBreak: "break-all"
|
|
645
649
|
}, children: s }),
|
|
646
|
-
|
|
650
|
+
c && /* @__PURE__ */ t("div", { style: {
|
|
647
651
|
fontSize: "0.75rem",
|
|
648
652
|
color: "var(--cedros-admin-text-muted, #64748b)",
|
|
649
653
|
marginTop: "0.25rem"
|
|
650
|
-
}, children:
|
|
654
|
+
}, children: c })
|
|
651
655
|
] })
|
|
652
656
|
] });
|
|
653
657
|
}
|
|
@@ -658,8 +662,8 @@ function se({
|
|
|
658
662
|
disabled: n = !1,
|
|
659
663
|
description: S
|
|
660
664
|
}) {
|
|
661
|
-
const [
|
|
662
|
-
|
|
665
|
+
const [l, c] = k(/* @__PURE__ */ new Set()), [m, h] = k(null), [p, y] = k(""), w = Array.isArray(s) ? s : [], A = (e) => {
|
|
666
|
+
c((i) => {
|
|
663
667
|
const r = new Set(i);
|
|
664
668
|
return r.has(e) ? r.delete(e) : r.add(e), r;
|
|
665
669
|
});
|
|
@@ -670,7 +674,7 @@ function se({
|
|
|
670
674
|
r[e] = i, d(r);
|
|
671
675
|
}, _ = (e) => {
|
|
672
676
|
const i = w.filter((r, g) => g !== e);
|
|
673
|
-
d(i),
|
|
677
|
+
d(i), c((r) => {
|
|
674
678
|
const g = /* @__PURE__ */ new Set();
|
|
675
679
|
return r.forEach((v) => {
|
|
676
680
|
v < e ? g.add(v) : v > e && g.add(v - 1);
|
|
@@ -721,7 +725,7 @@ function se({
|
|
|
721
725
|
borderRadius: "0.5rem"
|
|
722
726
|
}, children: 'No items. Click "Add" to create one.' }),
|
|
723
727
|
w.map((e, i) => {
|
|
724
|
-
const r =
|
|
728
|
+
const r = l.has(i), g = m === i, v = e === z;
|
|
725
729
|
return /* @__PURE__ */ t(
|
|
726
730
|
"div",
|
|
727
731
|
{
|
|
@@ -861,14 +865,14 @@ function se({
|
|
|
861
865
|
] });
|
|
862
866
|
}
|
|
863
867
|
function q(b, s, d) {
|
|
864
|
-
const n = G(b, s), S = s.replace(/_/g, " ").replace(/\b\w/g, (h) => h.toUpperCase()),
|
|
868
|
+
const n = G(b, s), S = s.replace(/_/g, " ").replace(/\b\w/g, (h) => h.toUpperCase()), c = F[b]?.fields?.[s], m = {
|
|
865
869
|
isSecret: n,
|
|
866
870
|
label: S,
|
|
867
|
-
description:
|
|
868
|
-
hidden:
|
|
869
|
-
showWhen:
|
|
871
|
+
description: c?.description,
|
|
872
|
+
hidden: c?.hidden,
|
|
873
|
+
showWhen: c?.showWhen
|
|
870
874
|
};
|
|
871
|
-
return
|
|
875
|
+
return c?.type === "dropdown" && c.options ? { ...m, type: "dropdown", options: c.options } : c?.type === "token_mint" ? { ...m, type: "token_mint" } : c?.type === "toggle" ? { ...m, type: "toggle" } : c?.type === "secret_array" ? { ...m, type: "secret_array", isSecret: !0 } : c?.type === "solana_address" ? { ...m, type: "solana_address" } : c?.type === "number" ? { ...m, type: "number", unit: c.unit } : typeof d == "boolean" ? { ...m, type: "boolean" } : typeof d == "number" ? { ...m, type: "number", unit: c?.unit } : Array.isArray(d) ? { ...m, type: "array" } : typeof d == "object" && d !== null ? { ...m, type: "object" } : { ...m, type: "string" };
|
|
872
876
|
}
|
|
873
877
|
function ae({
|
|
874
878
|
category: b,
|
|
@@ -877,28 +881,28 @@ function ae({
|
|
|
877
881
|
isLoading: n = !1,
|
|
878
882
|
onSave: S
|
|
879
883
|
}) {
|
|
880
|
-
const [
|
|
884
|
+
const [l, c] = k(s), [m, h] = k(/* @__PURE__ */ new Set());
|
|
881
885
|
V(() => {
|
|
882
|
-
|
|
886
|
+
c(s);
|
|
883
887
|
}, [s]);
|
|
884
888
|
const p = H(() => {
|
|
885
|
-
const e = { ...
|
|
889
|
+
const e = { ...l };
|
|
886
890
|
for (const i of Object.keys(e))
|
|
887
891
|
if (G(b, i)) {
|
|
888
892
|
const r = d[i], g = e[i];
|
|
889
893
|
(g === z || g === r) && (e[i] = z);
|
|
890
894
|
}
|
|
891
895
|
return e;
|
|
892
|
-
}, [
|
|
893
|
-
const e =
|
|
896
|
+
}, [l, d, b]), y = H(() => {
|
|
897
|
+
const e = l.token_mint;
|
|
894
898
|
return typeof e != "string" || !e ? !1 : !B(e).valid;
|
|
895
|
-
}, [
|
|
899
|
+
}, [l]), { status: w, error: A } = te({
|
|
896
900
|
data: p,
|
|
897
901
|
onSave: S,
|
|
898
902
|
debounceMs: 1500,
|
|
899
903
|
enabled: !y
|
|
900
904
|
}), f = I((e, i) => {
|
|
901
|
-
|
|
905
|
+
c((r) => ({ ...r, [e]: i }));
|
|
902
906
|
}, []), M = I((e) => {
|
|
903
907
|
h((i) => {
|
|
904
908
|
const r = new Set(i);
|
|
@@ -929,12 +933,12 @@ function ae({
|
|
|
929
933
|
label: r.label,
|
|
930
934
|
value: i,
|
|
931
935
|
onChange: (a) => f(e, a),
|
|
932
|
-
decimals:
|
|
936
|
+
decimals: l.token_decimals ?? 6,
|
|
933
937
|
onDecimalsChange: (a) => f("token_decimals", a),
|
|
934
938
|
disabled: n,
|
|
935
939
|
description: r.description,
|
|
936
|
-
customSymbol:
|
|
937
|
-
customIcon:
|
|
940
|
+
customSymbol: l.custom_token_symbol || "",
|
|
941
|
+
customIcon: l.custom_token_icon || "",
|
|
938
942
|
onCustomSymbolChange: (a) => f("custom_token_symbol", a),
|
|
939
943
|
onCustomIconChange: (a) => f("custom_token_icon", a)
|
|
940
944
|
}
|
|
@@ -1148,19 +1152,19 @@ function ae({
|
|
|
1148
1152
|
] }),
|
|
1149
1153
|
_(r.description)
|
|
1150
1154
|
] });
|
|
1151
|
-
}, x = Object.keys(
|
|
1152
|
-
const i = q(b, e, d[e] ??
|
|
1153
|
-
if (i.hidden || i.showWhen && !
|
|
1155
|
+
}, x = Object.keys(l), C = (e) => {
|
|
1156
|
+
const i = q(b, e, d[e] ?? l[e]);
|
|
1157
|
+
if (i.hidden || i.showWhen && !l[i.showWhen])
|
|
1154
1158
|
return !1;
|
|
1155
1159
|
if (e === "token_decimals") {
|
|
1156
|
-
const r =
|
|
1160
|
+
const r = l.token_mint;
|
|
1157
1161
|
if (r && O[r])
|
|
1158
1162
|
return !1;
|
|
1159
1163
|
}
|
|
1160
1164
|
return !0;
|
|
1161
1165
|
};
|
|
1162
1166
|
return /* @__PURE__ */ o("div", { className: "cedros-admin__config-editor", children: [
|
|
1163
|
-
/* @__PURE__ */ t("div", { className: "cedros-admin__config-fields", children: x.filter(C).map((e) => /* @__PURE__ */ t("div", { className: "cedros-admin__config-field", children: R(e,
|
|
1167
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__config-fields", children: x.filter(C).map((e) => /* @__PURE__ */ t("div", { className: "cedros-admin__config-field", children: R(e, l[e]) }, e)) }),
|
|
1164
1168
|
/* @__PURE__ */ t("div", { className: "cedros-admin__config-actions", children: /* @__PURE__ */ t("div", { className: "cedros-admin__autosave-status", children: /* @__PURE__ */ t(re, { status: w, error: A }) }) })
|
|
1165
1169
|
] });
|
|
1166
1170
|
}
|
|
@@ -1170,14 +1174,14 @@ function he({
|
|
|
1170
1174
|
authManager: d,
|
|
1171
1175
|
category: n,
|
|
1172
1176
|
title: S,
|
|
1173
|
-
description:
|
|
1174
|
-
enabledField:
|
|
1177
|
+
description: l,
|
|
1178
|
+
enabledField: c = "enabled",
|
|
1175
1179
|
showEnabledToggle: m = !1
|
|
1176
1180
|
}) {
|
|
1177
1181
|
const h = H(
|
|
1178
1182
|
() => new ie(b, void 0, d),
|
|
1179
1183
|
[b, d]
|
|
1180
|
-
), [p, y] = k(null), [w, A] = k([]), [f, M] = k(!1), [_, R] = k(!0), [x, C] = k(null), [e, i] = k(null), [r, g] = k(!1), v = F[n] || { label: n, icon: "⚙️" }, a = S || v.label, N =
|
|
1184
|
+
), [p, y] = k(null), [w, A] = k([]), [f, M] = k(!1), [_, R] = k(!0), [x, C] = k(null), [e, i] = k(null), [r, g] = k(!1), v = F[n] || { label: n, icon: "⚙️" }, a = S || v.label, N = l || v.description, D = I(async () => {
|
|
1181
1185
|
R(!0), C(null);
|
|
1182
1186
|
try {
|
|
1183
1187
|
const u = await h.getConfig(n, !0);
|
|
@@ -1206,16 +1210,16 @@ function he({
|
|
|
1206
1210
|
await h.updateConfig(n, u, "Updated via admin dashboard");
|
|
1207
1211
|
}, [h, n]), j = I(async (u) => h.validateConfig(n, u), [h, n]), [W, $] = k(!1), X = I(async () => {
|
|
1208
1212
|
if (!p || W) return;
|
|
1209
|
-
const u = !!p.config[
|
|
1213
|
+
const u = !!p.config[c], P = !u, K = { ...p.config, [c]: P };
|
|
1210
1214
|
$(!0), y({ ...p, config: K });
|
|
1211
1215
|
try {
|
|
1212
1216
|
await h.updateConfig(n, K, `${P ? "Enabled" : "Disabled"} via admin dashboard`);
|
|
1213
1217
|
} catch (J) {
|
|
1214
|
-
y({ ...p, config: { ...p.config, [
|
|
1218
|
+
y({ ...p, config: { ...p.config, [c]: u } }), C(J instanceof Error ? J.message : "Failed to save enabled state");
|
|
1215
1219
|
} finally {
|
|
1216
1220
|
$(!1);
|
|
1217
1221
|
}
|
|
1218
|
-
}, [p, h, n,
|
|
1222
|
+
}, [p, h, n, c, W]), E = !!p?.config[c];
|
|
1219
1223
|
return _ && !p ? /* @__PURE__ */ t("div", { className: "cedros-admin__section", children: /* @__PURE__ */ o("div", { className: "cedros-admin__loading", children: [
|
|
1220
1224
|
T.loading,
|
|
1221
1225
|
" Loading ",
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),m=require("react"),w=require("./index-7YUxR4u5.js"),J=require("./useAutosave-B2p6iwh8.js"),$=require("./AutosaveIndicator-DW4IPbZ5.js"),P=require("./CedrosContext-D-lnoEkR.js");class G{constructor(n,a,i){this._serverUrl=n,this.auth=a,this.authManager=i}get serverUrl(){return this._serverUrl}async fetch(n,a={}){if(this.authManager?.isAuthenticated())return this.authManager.fetchWithAuth(n,a);throw this.auth?new Error("Legacy AdminAuth is no longer supported due to replay vulnerability. Use IAdminAuthManager instead."):new Error("Admin authentication required. Provide an IAdminAuthManager to ConfigApi.")}async listCategories(n=100){return this.fetch(`/admin/config?limit=${n}`)}async getConfig(n,a=!0){return this.fetch(`/admin/config/${n}?redact_secrets=${a}`)}async updateConfig(n,a,i){await this.fetch(`/admin/config/${n}`,{method:"PUT",body:JSON.stringify({config:a,description:i})})}async patchConfig(n,a,i){await this.fetch(`/admin/config/${n}`,{method:"PATCH",body:JSON.stringify({updates:a,description:i})})}async batchUpdate(n){await this.fetch("/admin/config/batch",{method:"POST",body:JSON.stringify({updates:n})})}async validateConfig(n,a){return this.fetch("/admin/config/validate",{method:"POST",body:JSON.stringify({category:n,config:a})})}async getHistory(n,a=50){const i=new URLSearchParams({limit:a.toString()});return n&&i.set("category",n),this.fetch(`/admin/config/history?${i}`)}}const O={server:{label:"Server",secrets:[],icon:"🖥️",fields:{admin_metrics_api_key:{hidden:!0},cors_allowed_origins:{hidden:!0}}},security:{label:"Security",description:"Configure CORS, rate limiting, and other security settings",secrets:[],icon:"🔒",fields:{cors_allowed_origins:{description:'List of allowed origins for CORS requests. Use ["*"] to allow all origins (not recommended for production).'}}},metrics:{label:"Metrics",description:"Configure metrics collection and API access",secrets:["admin_metrics_api_key"],icon:"📊",fields:{admin_metrics_api_key:{description:"API key for accessing the admin metrics endpoint. Keep this secret."}}},logging:{label:"Logging",secrets:[],icon:"📝",fields:{level:{type:"dropdown",options:["trace","debug","info","warn","error"]},format:{hidden:!0},environment:{hidden:!0}}},stripe:{label:"Stripe",secrets:["secret_key","webhook_secret"],icon:"💳",fields:{enabled:{hidden:!0},secret_key:{description:"Stripe Dashboard → Developers → API keys → Secret key. Use the test key (sk_test_...) for testing, or the live key (sk_live_...) for production."},publishable_key:{description:"Stripe Dashboard → Developers → API keys → Publishable key. Starts with pk_test_... or pk_live_..."},mode:{type:"dropdown",options:["test","live"],description:'Use "test" mode with test API keys during development, then switch to "live" with live keys for real payments.'},webhook_url:{description:"The full URL Stripe sends webhook events to. Default is your server URL + /webhook/stripe (e.g. https://example.com/webhook/stripe). Only change this if you've customized the route in your cedros-pay server."},webhook_secret:{description:`Stripe Dashboard → Developers → Webhooks → "Create an event destination" → select events: checkout.session.completed, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.paid, invoice.payment_failed → Continue → choose "Webhook endpoint" → enter your server's webhook endpoint, e.g. https://example.com/webhook/stripe (your server URL + /webhook/stripe) → after creating, click the endpoint and "Click to reveal" the signing secret. Starts with whsec_...`},tax_rate_id:{description:`Stripe Dashboard → More → Product catalog → Tax rates → "+ New" → set the percentage, region, and whether tax is inclusive or exclusive → Save → copy the tax rate ID from the detail page (starts with txr_...). Leave empty if you don't collect tax.`},success_url:{hidden:!0},cancel_url:{hidden:!0}}},x402:{label:"X402 (Crypto)",secrets:["server_wallets"],icon:"⚡",fields:{enabled:{hidden:!0},payment_address:{type:"solana_address",description:"The Solana wallet address where payments are received. This is where customer funds are sent."},token_mint:{type:"token_mint",description:"The SPL token used for payments. Most commonly USDC."},token_decimals:{type:"number",description:"Number of decimal places for the token (e.g., USDC has 6 decimals).",hidden:!0},custom_token_symbol:{description:'Display symbol for your custom token (e.g., "MYTOKEN").',hidden:!0},custom_token_icon:{description:"URL to your token's icon image.",hidden:!0},rpc_url:{description:"Custom Solana RPC endpoint. Leave empty to use the default public RPC."},gasless_enabled:{type:"toggle",description:"When enabled, your server pays transaction fees so customers don't need SOL."},server_wallets:{type:"secret_array",description:"Server keypair(s) used to sign and pay for transactions. Required for gasless payments.",showWhen:"gasless_enabled"},rounding_mode:{type:"dropdown",options:["nearest","up","down"],description:"How to round fractional token amounts: nearest (default), up (always round up), or down (always round down)."},network:{hidden:!0},ws_url:{hidden:!0},skip_preflight:{hidden:!0},commitment:{hidden:!0},compute_unit_limit:{hidden:!0},compute_unit_price:{hidden:!0}}},paywall:{label:"Paywall",secrets:[],icon:"🚪",fields:{product_cache_ttl:{type:"number",unit:"seconds"}}},coupons:{label:"Coupons",secrets:[],icon:"🎟️",fields:{cache_ttl:{type:"number",unit:"seconds"}}},subscriptions:{label:"Subscriptions",secrets:[],icon:"🔄",fields:{grace_period_hours:{type:"number",unit:"hours"}}},callbacks:{label:"Callbacks",secrets:["hmac_secret"],icon:"🔔"},email:{label:"Email",description:"Email receipts for customers after purchase",secrets:["smtp_password"],icon:"📧",fields:{enabled:{hidden:!0},provider:{type:"dropdown",options:["sendgrid","mailgun","postmark","ses","resend","custom"],description:"Email service provider."},smtp_host:{description:"SMTP server hostname.",showWhen:"provider"},smtp_port:{type:"number",description:"SMTP server port (typically 587 for TLS).",showWhen:"provider"},smtp_user:{description:"SMTP authentication username or API key name.",showWhen:"provider"},smtp_password:{description:"SMTP password or API key.",showWhen:"provider"},from_address:{description:"Sender email address (e.g., orders@yourstore.com)."},from_name:{description:'Sender display name (e.g., "Your Store").'}}},webhook:{label:"Webhook",description:"HTTP notifications when purchases occur",secrets:["secret"],icon:"🔔",fields:{enabled:{hidden:!0},url:{description:"URL to receive POST notifications (e.g., https://api.yoursite.com/webhooks/orders)."},secret:{description:"Shared secret for HMAC-SHA256 signature verification."},retry_attempts:{type:"number",description:"Number of retry attempts on failure (default: 3)."}}},messaging:{label:"Messaging",description:"Email and webhook notifications for purchases",secrets:["smtp_password","webhook_secret"],icon:"📬",fields:{email_enabled:{type:"boolean",description:"Send order confirmation emails to customers."},email_provider:{description:"Email service provider (mailgun, sendgrid, postmark, ses, resend, custom).",showWhen:"email_enabled"},smtp_host:{description:"SMTP server hostname.",showWhen:"email_enabled"},smtp_port:{type:"number",description:"SMTP server port (typically 587 for TLS).",showWhen:"email_enabled"},smtp_username:{description:"SMTP authentication username or API key.",showWhen:"email_enabled"},smtp_password:{description:"SMTP password or API key.",showWhen:"email_enabled"},from_email:{description:"Sender email address (e.g., orders@yourstore.com).",showWhen:"email_enabled"},from_name:{description:'Sender display name (e.g., "Your Store").',showWhen:"email_enabled"},webhook_enabled:{type:"boolean",description:"Send webhook notifications when purchases complete."},webhook_url:{description:"URL to receive POST notifications.",showWhen:"webhook_enabled"},webhook_secret:{description:"Shared secret for HMAC-SHA256 signature verification.",showWhen:"webhook_enabled"},webhook_timeout:{type:"number",description:"Request timeout in seconds (default: 30).",showWhen:"webhook_enabled"}}},monitoring:{label:"Monitoring",secrets:[],icon:"📊",fields:{check_interval:{type:"number",unit:"seconds"},low_balance_threshold:{type:"number",unit:"SOL"}}},rate_limit:{label:"Rate Limiting",secrets:[],icon:"⏱️"},circuit_breaker:{label:"Circuit Breaker",secrets:[],icon:"🔌"},admin:{label:"Admin Keys",secrets:[],icon:"👤"},api_keys:{label:"API Keys",secrets:[],icon:"🔐"},cedros_login:{label:"Cedros Login",secrets:["api_key"],icon:"🔑",fields:{enabled:{hidden:!0},credits_enabled:{hidden:!0},base_url:{hidden:!0},timeout:{hidden:!0},jwt_issuer:{hidden:!0},jwt_audience:{hidden:!0}}},shop:{label:"Storefront",description:"Product pages & display settings",secrets:[],icon:"🏪",fields:{enabled:{hidden:!0},"relatedProducts.mode":{type:"dropdown",options:["most_recent","by_category","manual","ai"]},"relatedProducts.maxItems":{type:"number"}}}};function F(b,n){return O[b]?.secrets.includes(n)??!1}const D="[REDACTED]",Y=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function W(b){return!b||b.trim()===""?{valid:!0}:Y.test(b.trim())?{valid:!0}:{valid:!1,error:"Invalid Solana address"}}function X({label:b,value:n,onChange:a,decimals:i,onDecimalsChange:S,disabled:d=!1,description:c,customSymbol:l="",customIcon:h="",onCustomSymbolChange:p,onCustomIconChange:y}){const[x,N]=m.useState(!1),f=Object.entries(P.STABLECOIN_METADATA),_=!!P.STABLECOIN_METADATA[n],k=x||!!n&&!_,j=t=>{if(t==="custom")N(!0),_&&a("");else{N(!1),a(t);const s=P.STABLECOIN_METADATA[t];s&&S&&S(s.decimals),p&&p(""),y&&y("")}};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:b}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.5rem"},children:[f.map(([t,s])=>e.jsxs("button",{type:"button",onClick:()=>j(t),disabled:d,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:n===t?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:n===t?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:d?"not-allowed":"pointer",opacity:d?.5:1,fontWeight:n===t?600:400},children:[e.jsx("img",{src:s.icon,alt:s.symbol,style:{width:20,height:20,borderRadius:"50%"},onError:r=>{r.target.style.display="none"}}),e.jsx("span",{children:s.symbol})]},t)),e.jsxs("button",{type:"button",onClick:()=>j("custom"),disabled:d,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:k?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:k?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:d?"not-allowed":"pointer",opacity:d?.5:1,fontWeight:k?600:400},children:[e.jsx("span",{style:{fontSize:"1rem"},children:"+"}),e.jsx("span",{children:"Custom"})]})]}),k&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Mint Address"}),(()=>{const t=W(n);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${t.valid?"":"cedros-admin__input--error"}`,value:n,onChange:s=>a(s.target.value),placeholder:"e.g., EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",disabled:d,style:{fontFamily:"monospace",fontSize:"0.875rem",borderColor:t.valid?void 0:"var(--cedros-admin-error, #dc2626)"}}),!t.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:t.error})]})})()]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:l,onChange:t=>p?.(t.target.value),placeholder:"e.g., MYTOKEN",disabled:d,style:{textTransform:"uppercase"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Icon URL"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:h,onChange:t=>y?.(t.target.value),placeholder:"https://example.com/token-logo.png",disabled:d,style:{flex:1}}),h&&e.jsx("img",{src:h,alt:"Token icon preview",style:{width:32,height:32,borderRadius:"50%",border:"1px solid var(--cedros-admin-border, #e5e7eb)",objectFit:"cover"},onError:t=>{t.target.style.display="none"}})]}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Shown to customers during checkout"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i??6,onChange:t=>S?.(parseInt(t.target.value,10)||0),min:0,max:18,disabled:d,style:{width:"100px"}}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Most SPL tokens use 6 decimals (like USDC)"})]})]}),n&&_&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",fontFamily:"monospace",wordBreak:"break-all"},children:n}),c&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:c})]})]})}function Z({label:b,value:n,onChange:a,disabled:i=!1,description:S}){const[d,c]=m.useState(new Set),[l,h]=m.useState(null),[p,y]=m.useState(""),x=Array.isArray(n)?n:[],N=t=>{c(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},f=()=>{a([...x,""]),h(x.length),y("")},E=(t,s)=>{const r=[...x];r[t]=s,a(r)},_=t=>{const s=x.filter((r,g)=>g!==t);a(s),c(r=>{const g=new Set;return r.forEach(v=>{v<t?g.add(v):v>t&&g.add(v-1)}),g})},T=t=>{h(t),y(x[t]||"")},k=()=>{l!==null&&(E(l,p),h(null),y(""))},j=()=>{l!==null&&x[l]===""&&_(l),h(null),y("")};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",style:{marginBottom:0},children:b}),e.jsxs("button",{type:"button",onClick:f,disabled:i,style:{display:"flex",alignItems:"center",gap:"0.25rem",padding:"0.25rem 0.5rem",fontSize:"0.75rem",border:"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.375rem",background:"var(--cedros-admin-bg, #fff)",cursor:i?"not-allowed":"pointer",opacity:i?.5:1},children:[w.Icons.plus,"Add"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[x.length===0&&e.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.875rem",border:"1px dashed var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem"},children:'No items. Click "Add" to create one.'}),x.map((t,s)=>{const r=d.has(s),g=l===s,v=t===D;return e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.375rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:g?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:p,onChange:o=>y(o.target.value),placeholder:"Enter wallet keypair...",autoFocus:!0,style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem"},onKeyDown:o=>{o.key==="Enter"&&k(),o.key==="Escape"&&j()}}),e.jsx("button",{type:"button",onClick:k,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-success, #22c55e)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Save",children:w.Icons.check}),e.jsx("button",{type:"button",onClick:j,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-text-muted, #64748b)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Cancel",children:w.Icons.close})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r&&!v?t:v?"[REDACTED]":"••••••••••••••••••••"}),e.jsx("button",{type:"button",onClick:()=>N(s),disabled:i||v,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:i||v?"not-allowed":"pointer",opacity:i||v?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:r?"Hide":"Show",children:r?w.Icons.eyeOff:w.Icons.eye}),e.jsx("button",{type:"button",onClick:()=>T(s),disabled:i,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:i?"not-allowed":"pointer",opacity:i?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:"Edit",children:w.Icons.settings}),e.jsx("button",{type:"button",onClick:()=>_(s),disabled:i,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:i?"not-allowed":"pointer",opacity:i?.5:1,color:"var(--cedros-admin-error, #ef4444)"},title:"Delete",children:w.Icons.trash})]})},s)})]}),S&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.5rem"},children:S})]})}function L(b,n,a){const i=F(b,n),S=n.replace(/_/g," ").replace(/\b\w/g,h=>h.toUpperCase()),c=O[b]?.fields?.[n],l={isSecret:i,label:S,description:c?.description,hidden:c?.hidden,showWhen:c?.showWhen};return c?.type==="dropdown"&&c.options?{...l,type:"dropdown",options:c.options}:c?.type==="token_mint"?{...l,type:"token_mint"}:c?.type==="toggle"?{...l,type:"toggle"}:c?.type==="secret_array"?{...l,type:"secret_array",isSecret:!0}:c?.type==="solana_address"?{...l,type:"solana_address"}:c?.type==="number"?{...l,type:"number",unit:c.unit}:typeof a=="boolean"?{...l,type:"boolean"}:typeof a=="number"?{...l,type:"number",unit:c?.unit}:Array.isArray(a)?{...l,type:"array"}:typeof a=="object"&&a!==null?{...l,type:"object"}:{...l,type:"string"}}function Q({category:b,config:n,originalConfig:a,isLoading:i=!1,onSave:S}){const[d,c]=m.useState(n),[l,h]=m.useState(new Set);m.useEffect(()=>{c(n)},[n]);const p=m.useMemo(()=>{const t={...d};for(const s of Object.keys(t))if(F(b,s)){const r=a[s],g=t[s];(g===D||g===r)&&(t[s]=D)}return t},[d,a,b]),y=m.useMemo(()=>{const t=d.token_mint;return typeof t!="string"||!t?!1:!W(t).valid},[d]),{status:x,error:N}=J.useAutosave({data:p,onSave:S,debounceMs:1500,enabled:!y}),f=m.useCallback((t,s)=>{c(r=>({...r,[t]:s}))},[]),E=m.useCallback(t=>{h(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},[]),_=t=>t?e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:t}):null,T=(t,s)=>{const r=L(b,t,a[t]??s);if(r.type==="dropdown"&&r.options)return e.jsx(w.FormDropdown,{value:s,onChange:o=>f(t,o),options:r.options.map(o=>({value:o,label:o})),label:r.label,description:r.description,disabled:i});if(r.type==="token_mint")return e.jsx(X,{label:r.label,value:s,onChange:o=>f(t,o),decimals:d.token_decimals??6,onDecimalsChange:o=>f("token_decimals",o),disabled:i,description:r.description,customSymbol:d.custom_token_symbol||"",customIcon:d.custom_token_icon||"",onCustomSymbolChange:o=>f("custom_token_symbol",o),onCustomIconChange:o=>f("custom_token_icon",o)});if(r.type==="toggle")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>f(t,!s),disabled:i,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:i?"not-allowed":"pointer",position:"relative",transition:"background-color 0.2s",opacity:i?.5:1,flexShrink:0},children:e.jsx("span",{style:{position:"absolute",top:2,left:s?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{className:"cedros-admin__field-label",style:{marginBottom:0},children:r.label})]}),_(r.description)]});if(r.type==="solana_address"){const o=s||"",C=W(o);return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${C.valid?"":"cedros-admin__input--error"}`,value:o,onChange:R=>f(t,R.target.value),disabled:i,placeholder:"e.g. 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",style:{width:"100%",fontFamily:"monospace",fontSize:"0.875rem",borderColor:C.valid?void 0:"var(--cedros-admin-error, #dc2626)",paddingRight:o&&C.valid?"2rem":void 0}}),o&&C.valid&&e.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",color:"var(--cedros-admin-success, #16a34a)",fontSize:"1rem"},title:"Valid Solana address",children:"✓"})]}),!C.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:C.error}),_(r.description)]})}if(r.type==="boolean")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:o=>f(t,o.target.checked),disabled:i}),r.label]}),_(r.description)]});if(r.type==="number")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.unit&&e.jsxs("span",{className:"cedros-admin__field-unit",children:[" (",r.unit,")"]})]}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s,onChange:o=>f(t,parseFloat(o.target.value)||0),disabled:i}),_(r.description)]});if(r.type==="secret_array")return e.jsx(Z,{label:r.label,value:s,onChange:o=>f(t,o),disabled:i,description:r.description});if(r.type==="array"){const o=s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea",value:o.join(`
|
|
2
|
+
`),onChange:C=>f(t,C.target.value.split(`
|
|
3
|
+
`).filter(Boolean)),placeholder:"One item per line",rows:3,disabled:i}),_(r.description)]})}if(r.type==="object")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea cedros-admin__textarea--mono",value:JSON.stringify(s,null,2),onChange:o=>{try{f(t,JSON.parse(o.target.value))}catch{}},rows:5,disabled:i}),_(r.description)]});const g=l.has(t),v=r.isSecret&&!g&&s===D?D:s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.isSecret&&e.jsx("span",{className:"cedros-admin__field-secret",children:" (secret)"})]}),e.jsxs("div",{className:"cedros-admin__input-group",children:[e.jsx("input",{type:r.isSecret&&!g?"password":"text",className:"cedros-admin__input",value:v,onChange:o=>f(t,o.target.value),disabled:i,placeholder:r.isSecret?"••••••••":""}),r.isSecret&&e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>E(t),style:{padding:"0.5rem",minWidth:"auto"},title:g?"Hide":"Show",children:g?w.Icons.eyeOff:w.Icons.eye})]}),_(r.description)]})},k=Object.keys(d),j=t=>{const s=L(b,t,a[t]??d[t]);if(s.hidden||s.showWhen&&!d[s.showWhen])return!1;if(t==="token_decimals"){const r=d.token_mint;if(r&&P.STABLECOIN_METADATA[r])return!1}return!0};return e.jsxs("div",{className:"cedros-admin__config-editor",children:[e.jsx("div",{className:"cedros-admin__config-fields",children:k.filter(j).map(t=>e.jsx("div",{className:"cedros-admin__config-field",children:T(t,d[t])},t))}),e.jsx("div",{className:"cedros-admin__config-actions",children:e.jsx("div",{className:"cedros-admin__autosave-status",children:e.jsx($.AutosaveIndicator,{status:x,error:N})})})]})}function ee({serverUrl:b,apiKey:n,authManager:a,category:i,title:S,description:d,enabledField:c="enabled",showEnabledToggle:l=!1}){const h=m.useMemo(()=>new G(b,void 0,a),[b,a]),[p,y]=m.useState(null),[x,N]=m.useState([]),[f,E]=m.useState(!1),[_,T]=m.useState(!0),[k,j]=m.useState(null),[t,s]=m.useState(null),[r,g]=m.useState(!1),v=O[i]||{label:i,icon:"⚙️"},o=S||v.label,C=d||v.description,R=m.useCallback(async()=>{T(!0),j(null);try{const u=await h.getConfig(i,!0);y(u)}catch{y(null),j("Failed to load settings")}finally{T(!1)}},[h,i]);m.useEffect(()=>{R()},[R]);const z=m.useCallback(async()=>{try{const u=await h.getHistory(i,20);N(u.history)}catch{N([])}},[h,i]);m.useEffect(()=>{f&&z()},[f,z]);const q=m.useCallback(async u=>{await h.updateConfig(i,u,"Updated via admin dashboard")},[h,i]),B=m.useCallback(async u=>h.validateConfig(i,u),[h,i]),[M,U]=m.useState(!1),K=m.useCallback(async()=>{if(!p||M)return;const u=!!p.config[c],I=!u,V={...p.config,[c]:I};U(!0),y({...p,config:V});try{await h.updateConfig(i,V,`${I?"Enabled":"Disabled"} via admin dashboard`)}catch(H){y({...p,config:{...p.config,[c]:u}}),j(H instanceof Error?H.message:"Failed to save enabled state")}finally{U(!1)}},[p,h,i,c,M]),A=!!p?.config[c];return _&&!p?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[w.Icons.loading," Loading ",o," settings..."]})}):e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx(w.ErrorBanner,{message:k,onRetry:R}),e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"cedros-admin__section-title",children:[e.jsx("span",{style:{marginRight:"0.5rem"},children:v.icon}),o]}),C&&e.jsx("p",{className:"cedros-admin__text-muted",style:{marginTop:"0.25rem"},children:C})]}),l&&p&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:A?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:A?"Enabled":"Disabled"}),e.jsx("button",{type:"button",role:"switch","aria-checked":A,onClick:K,disabled:M,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:A?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:M?"wait":"pointer",position:"relative",transition:"background-color 0.2s",flexShrink:0,opacity:M?.6:1},children:e.jsx("span",{style:{position:"absolute",top:2,left:A?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})]}),p&&e.jsxs("div",{className:"cedros-admin__settings-editor",style:{marginTop:"1rem",opacity:l&&!A?.6:1,pointerEvents:l&&!A?"none":"auto"},children:[l&&!A&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)",pointerEvents:"auto"},children:"This payment method is disabled. Enable it using the toggle above to accept payments."}),e.jsx(Q,{category:p.category,config:p.config,originalConfig:p.config,onSave:q,onValidate:B})]}),f&&e.jsxs("div",{className:"cedros-admin__settings-history",style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{marginBottom:"0.75rem",fontWeight:600},children:"Change History"}),x.length===0?e.jsx("p",{className:"cedros-admin__text-muted",children:"No history entries found."}):e.jsx("div",{className:"cedros-admin__settings-timeline",children:x.map(u=>e.jsxs("div",{className:"cedros-admin__settings-timeline-item",children:[e.jsx("div",{className:"cedros-admin__settings-timeline-dot"}),e.jsxs("div",{className:"cedros-admin__settings-timeline-content",children:[e.jsxs("div",{className:"cedros-admin__settings-timeline-header",children:[e.jsx("code",{children:u.configKey}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${u.action.toLowerCase()}`,children:u.action})]}),e.jsxs("div",{className:"cedros-admin__settings-timeline-meta",children:[w.formatDateTime(u.changedAt)," by ",u.changedBy]})]})]},u.id))})]}),t&&e.jsx("div",{style:{marginTop:"1rem",padding:"0.75rem 1rem",borderRadius:"0.375rem",backgroundColor:t.valid?"var(--cedros-admin-success-bg, #dcfce7)":"var(--cedros-admin-error-bg, #fef2f2)",border:`1px solid ${t.valid?"var(--cedros-admin-success-border, #86efac)":"var(--cedros-admin-error-border, #fecaca)"}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600,color:t.valid?"var(--cedros-admin-success, #16a34a)":"var(--cedros-admin-error, #dc2626)",marginBottom:t.errors.length>0||t.warnings.length>0?"0.5rem":0},children:t.valid?"✓ Configuration is valid":"✗ Validation failed"}),t.errors.length>0&&e.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.875rem"},children:t.errors.map((u,I)=>e.jsx("li",{children:u},I))}),t.warnings.length>0&&e.jsx("ul",{style:{margin:t.errors.length>0?"0.5rem 0 0":0,paddingLeft:"1.25rem",color:"var(--cedros-admin-warning, #ca8a04)",fontSize:"0.875rem"},children:t.warnings.map((u,I)=>e.jsx("li",{children:u},I))})]}),e.jsx("button",{type:"button",onClick:()=>s(null),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"1.25rem",lineHeight:1},title:"Dismiss",children:"×"})]})}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>E(!f),children:f?"Hide History":"History"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r||!p,onClick:async()=>{if(p){g(!0),s(null);try{const u=await B(p.config);s(u)}catch(u){s({valid:!1,errors:[u instanceof Error?u.message:"Validation failed"],warnings:[]})}finally{g(!1)}}},children:r?"Validating...":"Validate"})]})]})}exports.SingleCategorySettings=ee;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("./index-B5ck27xb.js"),o=require("./Toggle-CsPSF8Dr.js"),O=require("./useAutosave-B2p6iwh8.js"),M=require("./AutosaveIndicator-CpTVtJIz.js"),b={enabled:!0,relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}},$=[{value:"most_recent",label:"Most Recent",description:"Show the most recently added products (excluding current product)."},{value:"by_category",label:"By Category",description:"Show products from the same category as the current product."},{value:"manual",label:"Manual Selection",description:"Specify related products per-product using relatedProductIds in metadata."},{value:"ai",label:"AI Recommendations",description:"Let AI analyze products and suggest the best matches. Requires AI to be configured in AI Settings."}],S=[{value:"large",label:"Large",description:"Portrait cards (4:5) with full product info, description, and tags."},{value:"square",label:"Square",description:"Square cards (1:1) showing title and price only."},{value:"compact",label:"Compact",description:"Compact cards (3:4) with smaller text to fit more products."}],C=[{value:"center",label:"Center"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],q=[{id:"shop-page",label:"Shop Page"},{id:"catalog",label:"Catalog"},{id:"layouts",label:"Layouts"},{id:"product-pages",label:"Product Pages"},{id:"checkout",label:"Checkout"}];function H({serverUrl:h,apiKey:d,authManager:c}){const[m,P]=l.useState("shop-page"),[a,i]=l.useState(b),[I,z]=l.useState(!0),[W,B]=l.useState(!0),[L,y]=l.useState(null),x=l.useCallback(async()=>{try{y(null);let t;const s="/admin/config/shop";if(c?.isAuthenticated())t=await c.fetchWithAuth(s);else{const r={"Content-Type":"application/json"};d&&(r["X-API-Key"]=d);const n=await fetch(`${h}${s}`,{headers:r});if(!n.ok)throw new Error(`Failed to fetch settings: ${n.status}`);t=await n.json()}i({...b,...t.config})}catch{i(b),y("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[h,d,c]);l.useEffect(()=>{x()},[x]);const D=l.useCallback(async t=>{const s="/admin/config/shop",r=JSON.stringify({config:t});try{if(c?.isAuthenticated())await c.fetchWithAuth(s,{method:"PUT",body:r});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const p=await fetch(`${h}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw y("Failed to save storefront settings"),new Error("Save failed")}},[h,d,c]),{status:N,error:R}=O.useAutosave({data:a,onSave:D,debounceMs:1500,enabled:!W}),A=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,mode:t}}))},E=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,maxItems:t}}))},_=(t,s)=>{i(r=>({...r,relatedProducts:{...r.relatedProducts,layout:{...r.relatedProducts.layout,[t]:s}}}))},f=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},v=(t,s)=>{const r=a.catalog.sort,n=Object.values(r).filter(Boolean).length;!s&&n<=1||i(p=>({...p,catalog:{...p.catalog,sort:{...p.catalog.sort,[t]:s}}}))},F=(t,s)=>{i(r=>({...r,checkout:{...r.checkout,[t]:s}}))},k=(t,s)=>{i(r=>({...r,shopLayout:{...r.shopLayout,[t]:s}}))},T=(t,s)=>{i(r=>({...r,categoryLayout:{...r.categoryLayout,[t]:s}}))},u=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},j=(t,s)=>{i(r=>({...r,inventory:{...r.inventory,[t]:s}}))},w=(t,s)=>{i(r=>({...r,shopPage:{...r.shopPage,[t]:s}}))};return I?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[g.Icons.loading," Loading storefront settings..."]})}):e.jsxs("div",{className:"cedros-admin__storefront-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Storefront"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure catalog filters, product layouts, and checkout settings."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:a.enabled?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:a.enabled?"Enabled":"Disabled"}),e.jsx(o.Toggle,{checked:a.enabled,onChange:t=>i(s=>({...s,enabled:t}))})]})]}),!a.enabled&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)"},children:"The storefront is disabled. Enable it using the toggle above to activate your store."}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",style:{opacity:a.enabled?1:.5,pointerEvents:a.enabled?"auto":"none"},children:[q.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${m===t.id?"cedros-admin__tab--active":""}`,onClick:()=>P(t.id),children:t.label},t.id)),e.jsx("div",{style:{flex:1}}),e.jsx(M.AutosaveIndicator,{status:N,error:R})]}),e.jsx(g.ErrorBanner,{message:L,onRetry:x}),m==="shop-page"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Shop Page Content"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Customize the title and description shown on your shop page."}),e.jsxs("div",{className:"cedros-admin__field",style:{marginBottom:"1.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.shopPage.title,onChange:t=>w("title",t.target.value),placeholder:"Shop"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"The main heading displayed on your shop page."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Description"}),e.jsx("textarea",{className:"cedros-admin__textarea",value:a.shopPage.description,onChange:t=>w("description",t.target.value),placeholder:"Browse our collection of products...",rows:3,style:{resize:"vertical"}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"A short description or subtitle shown below the title. Leave empty to hide."})]})]}),m==="catalog"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Catalog Filters"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which filters appear in the shop and category page sidebars."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.tags,onChange:t=>f("tags",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Tags"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter products by tags (multi-select checkboxes)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.priceRange,onChange:t=>f("priceRange",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price Range"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter by minimum and maximum price"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.inStock,onChange:t=>f("inStock",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"In Stock"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show only products that are in stock"})]})]})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Sort Options"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sort options appear in the shop and category pages. At least one must be enabled."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.featured,onChange:t=>v("featured",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Featured"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Default sort order (as returned by backend)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceAsc,onChange:t=>v("priceAsc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: Low to High"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price ascending"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceDesc,onChange:t=>v("priceDesc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: High to Low"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price descending"})]})]})]})]})]}),m==="layouts"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Product Layouts"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Configure product card layouts for shop and category pages."}),e.jsxs("div",{style:{marginBottom:"2rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Shop Page"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.shopLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"shopLayout",value:t.value,checked:s,onChange:()=>k("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.shopLayout.imageCrop,onChange:t=>k("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]}),e.jsxs("div",{style:{paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Category Pages"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.categoryLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"categoryLayout",value:t.value,checked:s,onChange:()=>T("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.categoryLayout.imageCrop,onChange:t=>T("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),m==="product-pages"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Related Products"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure how related products are displayed on product detail pages."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",marginBottom:"1.5rem"},children:$.map(t=>{const s=a.relatedProducts.mode===t.value,r=t.badge==="Coming Soon";return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"1rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:8,cursor:r?"not-allowed":"pointer",opacity:r?.6:1,background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedProductsMode",value:t.value,checked:s,onChange:()=>!r&&A(t.value),disabled:r,style:{marginTop:2}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("span",{style:{fontWeight:600},children:t.label}),t.badge&&e.jsx("span",{style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#6366f1",color:"#fff"},children:t.badge})]}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:13,opacity:.75},children:t.description})]})]},t.value)})}),a.relatedProducts.mode==="manual"&&e.jsxs("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #f5f5f5)",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("strong",{style:{fontSize:14},children:"How to set related products:"}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.8},children:["When editing a product, add a ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"relatedProductIds"})," field to its metadata containing a comma-separated list of product IDs."]}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.6},children:["Example: ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"prod_123,prod_456,prod_789"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Related Products"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.relatedProducts.maxItems,onChange:t=>E(Math.max(1,Math.min(12,parseInt(t.target.value)||4))),min:1,max:12}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How many related products to show (1-12)"})]}),e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Display Layout"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.relatedProducts.layout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedLayout",value:t.value,checked:s,onChange:()=>_("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.relatedProducts.layout.imageCrop,onChange:t=>_("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Page Sections"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sections appear on product detail pages."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showDescription,onChange:t=>u("showDescription",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Description"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Expandable description accordion"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showSpecs,onChange:t=>u("showSpecs",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Specifications"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product attributes and details"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showShipping,onChange:t=>u("showShipping",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Shipping & Returns"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Shipping and return policy information"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showRelatedProducts,onChange:t=>u("showRelatedProducts",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Related Products"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product recommendations section"})]})]})]})]})]}),m==="checkout"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Checkout Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure checkout and cart page features."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.checkout.promoCodes,onChange:t=>F("promoCodes",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Promo Codes"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show promo/coupon code input on cart and checkout pages"})]})]})})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Inventory Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure inventory verification and reservation behavior."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.preCheckoutVerification,onChange:t=>j("preCheckoutVerification",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Pre-Checkout Verification"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Verify inventory availability before processing payment"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.holdsEnabled,onChange:t=>j("holdsEnabled",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Inventory Holds"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Reserve inventory when items are added to cart"})]})]})]}),a.inventory.holdsEnabled&&e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200,marginTop:"1rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Hold Duration (minutes)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.inventory.holdDurationMinutes,onChange:t=>j("holdDurationMinutes",Math.max(5,Math.min(60,parseInt(t.target.value)||15))),min:5,max:60}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How long to reserve inventory in carts (5-60 minutes)"})]})]})]})]})}exports.StorefrontSection=H;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("./index-7YUxR4u5.js"),o=require("./Toggle-CsPSF8Dr.js"),O=require("./useAutosave-B2p6iwh8.js"),M=require("./AutosaveIndicator-DW4IPbZ5.js"),b={enabled:!0,relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}},$=[{value:"most_recent",label:"Most Recent",description:"Show the most recently added products (excluding current product)."},{value:"by_category",label:"By Category",description:"Show products from the same category as the current product."},{value:"manual",label:"Manual Selection",description:"Specify related products per-product using relatedProductIds in metadata."},{value:"ai",label:"AI Recommendations",description:"Let AI analyze products and suggest the best matches. Requires AI to be configured in AI Settings."}],S=[{value:"large",label:"Large",description:"Portrait cards (4:5) with full product info, description, and tags."},{value:"square",label:"Square",description:"Square cards (1:1) showing title and price only."},{value:"compact",label:"Compact",description:"Compact cards (3:4) with smaller text to fit more products."}],C=[{value:"center",label:"Center"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],q=[{id:"shop-page",label:"Shop Page"},{id:"catalog",label:"Catalog"},{id:"layouts",label:"Layouts"},{id:"product-pages",label:"Product Pages"},{id:"checkout",label:"Checkout"}];function H({serverUrl:h,apiKey:d,authManager:c}){const[m,P]=l.useState("shop-page"),[a,i]=l.useState(b),[I,z]=l.useState(!0),[W,B]=l.useState(!0),[L,y]=l.useState(null),x=l.useCallback(async()=>{try{y(null);let t;const s="/admin/config/shop";if(c?.isAuthenticated())t=await c.fetchWithAuth(s);else{const r={"Content-Type":"application/json"};d&&(r["X-API-Key"]=d);const n=await fetch(`${h}${s}`,{headers:r});if(!n.ok)throw new Error(`Failed to fetch settings: ${n.status}`);t=await n.json()}i({...b,...t.config})}catch{i(b),y("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[h,d,c]);l.useEffect(()=>{x()},[x]);const D=l.useCallback(async t=>{const s="/admin/config/shop",r=JSON.stringify({config:t});try{if(c?.isAuthenticated())await c.fetchWithAuth(s,{method:"PUT",body:r});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const p=await fetch(`${h}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw y("Failed to save storefront settings"),new Error("Save failed")}},[h,d,c]),{status:N,error:R}=O.useAutosave({data:a,onSave:D,debounceMs:1500,enabled:!W}),A=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,mode:t}}))},E=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,maxItems:t}}))},_=(t,s)=>{i(r=>({...r,relatedProducts:{...r.relatedProducts,layout:{...r.relatedProducts.layout,[t]:s}}}))},f=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},v=(t,s)=>{const r=a.catalog.sort,n=Object.values(r).filter(Boolean).length;!s&&n<=1||i(p=>({...p,catalog:{...p.catalog,sort:{...p.catalog.sort,[t]:s}}}))},F=(t,s)=>{i(r=>({...r,checkout:{...r.checkout,[t]:s}}))},k=(t,s)=>{i(r=>({...r,shopLayout:{...r.shopLayout,[t]:s}}))},T=(t,s)=>{i(r=>({...r,categoryLayout:{...r.categoryLayout,[t]:s}}))},u=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},j=(t,s)=>{i(r=>({...r,inventory:{...r.inventory,[t]:s}}))},w=(t,s)=>{i(r=>({...r,shopPage:{...r.shopPage,[t]:s}}))};return I?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[g.Icons.loading," Loading storefront settings..."]})}):e.jsxs("div",{className:"cedros-admin__storefront-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Storefront"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure catalog filters, product layouts, and checkout settings."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:a.enabled?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:a.enabled?"Enabled":"Disabled"}),e.jsx(o.Toggle,{checked:a.enabled,onChange:t=>i(s=>({...s,enabled:t}))})]})]}),!a.enabled&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)"},children:"The storefront is disabled. Enable it using the toggle above to activate your store."}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",style:{opacity:a.enabled?1:.5,pointerEvents:a.enabled?"auto":"none"},children:[q.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${m===t.id?"cedros-admin__tab--active":""}`,onClick:()=>P(t.id),children:t.label},t.id)),e.jsx("div",{style:{flex:1}}),e.jsx(M.AutosaveIndicator,{status:N,error:R})]}),e.jsx(g.ErrorBanner,{message:L,onRetry:x}),m==="shop-page"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Shop Page Content"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Customize the title and description shown on your shop page."}),e.jsxs("div",{className:"cedros-admin__field",style:{marginBottom:"1.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.shopPage.title,onChange:t=>w("title",t.target.value),placeholder:"Shop"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"The main heading displayed on your shop page."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Description"}),e.jsx("textarea",{className:"cedros-admin__textarea",value:a.shopPage.description,onChange:t=>w("description",t.target.value),placeholder:"Browse our collection of products...",rows:3,style:{resize:"vertical"}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"A short description or subtitle shown below the title. Leave empty to hide."})]})]}),m==="catalog"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Catalog Filters"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which filters appear in the shop and category page sidebars."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.tags,onChange:t=>f("tags",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Tags"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter products by tags (multi-select checkboxes)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.priceRange,onChange:t=>f("priceRange",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price Range"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter by minimum and maximum price"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.inStock,onChange:t=>f("inStock",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"In Stock"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show only products that are in stock"})]})]})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Sort Options"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sort options appear in the shop and category pages. At least one must be enabled."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.featured,onChange:t=>v("featured",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Featured"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Default sort order (as returned by backend)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceAsc,onChange:t=>v("priceAsc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: Low to High"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price ascending"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceDesc,onChange:t=>v("priceDesc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: High to Low"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price descending"})]})]})]})]})]}),m==="layouts"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Product Layouts"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Configure product card layouts for shop and category pages."}),e.jsxs("div",{style:{marginBottom:"2rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Shop Page"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.shopLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"shopLayout",value:t.value,checked:s,onChange:()=>k("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.shopLayout.imageCrop,onChange:t=>k("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]}),e.jsxs("div",{style:{paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Category Pages"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.categoryLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"categoryLayout",value:t.value,checked:s,onChange:()=>T("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.categoryLayout.imageCrop,onChange:t=>T("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),m==="product-pages"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Related Products"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure how related products are displayed on product detail pages."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",marginBottom:"1.5rem"},children:$.map(t=>{const s=a.relatedProducts.mode===t.value,r=t.badge==="Coming Soon";return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"1rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:8,cursor:r?"not-allowed":"pointer",opacity:r?.6:1,background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedProductsMode",value:t.value,checked:s,onChange:()=>!r&&A(t.value),disabled:r,style:{marginTop:2}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("span",{style:{fontWeight:600},children:t.label}),t.badge&&e.jsx("span",{style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#6366f1",color:"#fff"},children:t.badge})]}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:13,opacity:.75},children:t.description})]})]},t.value)})}),a.relatedProducts.mode==="manual"&&e.jsxs("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #f5f5f5)",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("strong",{style:{fontSize:14},children:"How to set related products:"}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.8},children:["When editing a product, add a ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"relatedProductIds"})," field to its metadata containing a comma-separated list of product IDs."]}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.6},children:["Example: ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"prod_123,prod_456,prod_789"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Related Products"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.relatedProducts.maxItems,onChange:t=>E(Math.max(1,Math.min(12,parseInt(t.target.value)||4))),min:1,max:12}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How many related products to show (1-12)"})]}),e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Display Layout"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.relatedProducts.layout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedLayout",value:t.value,checked:s,onChange:()=>_("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.relatedProducts.layout.imageCrop,onChange:t=>_("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Page Sections"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sections appear on product detail pages."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showDescription,onChange:t=>u("showDescription",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Description"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Expandable description accordion"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showSpecs,onChange:t=>u("showSpecs",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Specifications"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product attributes and details"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showShipping,onChange:t=>u("showShipping",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Shipping & Returns"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Shipping and return policy information"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showRelatedProducts,onChange:t=>u("showRelatedProducts",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Related Products"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product recommendations section"})]})]})]})]})]}),m==="checkout"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Checkout Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure checkout and cart page features."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.checkout.promoCodes,onChange:t=>F("promoCodes",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Promo Codes"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show promo/coupon code input on cart and checkout pages"})]})]})})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Inventory Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure inventory verification and reservation behavior."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.preCheckoutVerification,onChange:t=>j("preCheckoutVerification",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Pre-Checkout Verification"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Verify inventory availability before processing payment"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.holdsEnabled,onChange:t=>j("holdsEnabled",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Inventory Holds"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Reserve inventory when items are added to cart"})]})]})]}),a.inventory.holdsEnabled&&e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200,marginTop:"1rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Hold Duration (minutes)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.inventory.holdDurationMinutes,onChange:t=>j("holdDurationMinutes",Math.max(5,Math.min(60,parseInt(t.target.value)||15))),min:5,max:60}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How long to reserve inventory in carts (5-60 minutes)"})]})]})]})]})}exports.StorefrontSection=H;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
2
|
import { useState as h, useCallback as z, useEffect as j } from "react";
|
|
3
|
-
import { I as H, E as V, F as x } from "./index-
|
|
3
|
+
import { I as H, E as V, F as x } from "./index-bqhsxBTY.mjs";
|
|
4
4
|
import { T as d } from "./Toggle-DAxIdpY4.mjs";
|
|
5
5
|
import { u as q } from "./useAutosave-YwMqRzqy.mjs";
|
|
6
|
-
import { A as X } from "./AutosaveIndicator-
|
|
6
|
+
import { A as X } from "./AutosaveIndicator-3S7EvXip.mjs";
|
|
7
7
|
const C = {
|
|
8
8
|
enabled: !0,
|
|
9
9
|
relatedProducts: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as a, jsxs as i } from "react/jsx-runtime";
|
|
2
2
|
import { useState as g, useCallback as F, useEffect as D, useMemo as E } from "react";
|
|
3
|
-
import { I as h, E as Z,
|
|
3
|
+
import { I as h, E as Z, f as K } from "./index-bqhsxBTY.mjs";
|
|
4
4
|
const l = {
|
|
5
5
|
enabled: !1,
|
|
6
6
|
plans: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),u=require("./index-B5ck27xb.js"),i={enabled:!1,plans:[],pageTitle:"Choose Your Plan",pageSubtitle:"Select the plan that best fits your needs.",annualSavingsBadge:"2 months free",popularBadgeText:"Best Deal",footerNotice:""},X={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function Y(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function G({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[p,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,j]=d.useState(null),[l,m]=d.useState({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),[x,P]=d.useState(l),[F,C]=d.useState(""),w=d.useCallback(async()=>{try{j(null);let e;const t="/admin/subscriptions/settings";if(f?.isAuthenticated())e=await f.fetchWithAuth(t);else{const n={"Content-Type":"application/json"};b&&(n["X-API-Key"]=b);const s=await fetch(`${v}${t}`,{headers:n});if(!s.ok)throw new Error(`Failed to fetch settings: ${s.status}`);e=await s.json()}h({...i,...e}),m({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),P({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),C(JSON.stringify(e.plans??[]))}catch{h(i),m({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),P({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),C(JSON.stringify([])),j("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const I=d.useCallback(async e=>{try{j(null);const t="/admin/subscriptions/settings",n=JSON.stringify(e);if(f?.isAuthenticated())await f.fetchWithAuth(t,{method:"PUT",body:n});else{const s={"Content-Type":"application/json"};b&&(s["X-API-Key"]=b);const o=await fetch(`${v}${t}`,{method:"PUT",headers:s,body:n});if(!o.ok)throw new Error(`Failed to save settings: ${o.status}`)}return!0}catch{return j("Failed to save subscription settings"),!1}},[f,b,v]),E=d.useMemo(()=>x.enabled!==l.enabled||x.pageTitle!==l.pageTitle||x.pageSubtitle!==l.pageSubtitle||x.annualSavingsBadge!==l.annualSavingsBadge||x.popularBadgeText!==l.popularBadgeText||x.footerNotice!==l.footerNotice,[l,x]),D=d.useMemo(()=>JSON.stringify(r.plans),[r.plans]),U=d.useMemo(()=>F!==D,[D,F]),S=d.useCallback(async()=>{const e={...r,enabled:l.enabled,pageTitle:l.pageTitle,pageSubtitle:l.pageSubtitle,annualSavingsBadge:l.annualSavingsBadge,popularBadgeText:l.popularBadgeText,footerNotice:l.footerNotice};B("saving");const t=await I(e);h(e),t&&(P({enabled:e.enabled,pageTitle:e.pageTitle,pageSubtitle:e.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge,popularBadgeText:e.popularBadgeText,footerNotice:e.footerNotice}),C(JSON.stringify(e.plans))),B(t?"saved":"error"),setTimeout(()=>B("idle"),1500)},[l,I,r]);d.useEffect(()=>{if(p!=="page"||_||!E)return;const e=setTimeout(S,600);return()=>clearTimeout(e)},[p,E,_,S]),d.useEffect(()=>{if(p!=="plans"||_||!U)return;const e=setTimeout(S,800);return()=>clearTimeout(e)},[p,U,_,S]);const O=()=>{const e={...X,id:Y(),sortOrder:r.plans.length};h(t=>({...t,plans:[...t.plans,e]})),T(e.id)},c=(e,t)=>{h(n=>({...n,plans:n.plans.map(s=>s.id===e?{...s,...t}:s)}))},H=e=>{confirm("Delete this plan? This cannot be undone.")&&(h(t=>({...t,plans:t.plans.filter(n=>n.id!==e)})),k===e&&T(null))},$=(e,t)=>{const n=r.plans.findIndex(g=>g.id===e);if(n===-1||t==="up"&&n===0||t==="down"&&n===r.plans.length-1)return;const s=[...r.plans],o=t==="up"?n-1:n+1;[s[n],s[o]]=[s[o],s[n]],h(g=>({...g,plans:s}))},Q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},J=(e,t,n)=>{const s=r.plans.find(g=>g.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},q=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,g)=>g!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[u.Icons.loading," Loading subscription settings..."]})});const M=r.plans.filter(e=>e.isActive).length,L=r.plans.reduce((e,t)=>e+(t.activeSubscribers??0),0),N=l.enabled,W=r.plans.filter(e=>e.isActive).map(e=>({label:e.title,value:e.activeSubscribers??0,description:"subscribers"}));return a.jsxs("div",{className:"cedros-admin__page",children:[a.jsx(u.ErrorBanner,{message:z,onRetry:w}),a.jsx(u.StatsBar,{stats:[{label:"Status",value:N?"Enabled":"Disabled",variant:N?"success":"muted"},{label:"Active Plans",value:M,variant:M>0?"success":"muted"},{label:"Total Subscribers",value:L,variant:L>0?"success":"muted"},...W],isLoading:_}),a.jsxs("div",{className:"cedros-admin__section",children:[a.jsxs("div",{className:"cedros-admin__section-header",children:[a.jsx("h3",{className:"cedros-admin__section-title",children:"Subscription Settings"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[p==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[u.Icons.plus,"Add Plan"]}),a.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${y}`,children:[y==="saving"&&"Saving...",y==="saved"&&"Saved",y==="error"&&"Error"]})]})]}),a.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),p==="page"&&a.jsxs("div",{children:[a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Subscriptions"}),a.jsxs("label",{className:"cedros-admin__toggle",children:[a.jsx("input",{type:"checkbox",className:"cedros-admin__toggle-input",checked:l.enabled,onChange:e=>m(t=>({...t,enabled:e.target.checked}))}),a.jsx("span",{className:"cedros-admin__toggle-track",children:a.jsx("span",{className:"cedros-admin__toggle-thumb"})}),a.jsx("span",{className:"cedros-admin__toggle-label",children:"Enable Subscriptions"})]})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageTitle||"",onChange:e=>m(t=>({...t,pageTitle:e.target.value})),placeholder:"Choose Your Plan"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Subtitle"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageSubtitle||"",onChange:e=>m(t=>({...t,pageSubtitle:e.target.value})),placeholder:"Select the plan that best fits your needs."})]})]}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Savings Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.annualSavingsBadge||"",onChange:e=>m(t=>({...t,annualSavingsBadge:e.target.value})),placeholder:"2 months free"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Popular Plan Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.popularBadgeText||"",onChange:e=>m(t=>({...t,popularBadgeText:e.target.value})),placeholder:"Best Deal"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Footer Notice (optional)"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.footerNotice||"",onChange:e=>m(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),p==="plans"&&a.jsxs("div",{children:[!N&&a.jsx("div",{style:{padding:"1.5rem",textAlign:"center",opacity:.6},children:"Subscriptions are disabled. Enable them to configure plans."}),r.plans.length===0?a.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6,border:"1px dashed currentColor",borderRadius:8},children:'No plans configured. Click "Add Plan" to create your first subscription tier.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:r.plans.map((e,t)=>{const n=k===e.id;return a.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:8,overflow:"hidden",background:e.isPopular?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",padding:"0.75rem 1rem",cursor:"pointer"},onClick:()=>T(n?null:e.id),children:[a.jsx("span",{style:{opacity:.5},children:n?u.Icons.chevronDown:u.Icons.chevronRight}),a.jsxs("div",{style:{flex:1},children:[a.jsx("span",{style:{fontWeight:600},children:e.title||"Untitled Plan"}),e.isPopular&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"var(--cedros-admin-primary, #171717)",color:"#fff"},children:"Popular"}),!e.isActive&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"#9ca3af",color:"#fff"},children:"Inactive"})]}),a.jsxs("span",{style:{opacity:.6,fontSize:14},children:["$",e.priceMonthlyUsd,"/mo · $",e.priceAnnualUsd,"/yr"]}),a.jsxs("div",{style:{display:"flex",gap:"0.25rem"},onClick:s=>s.stopPropagation(),children:[a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"up"),disabled:t===0,title:"Move up",style:{padding:"4px 8px"},children:u.Icons.chevronUp}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"down"),disabled:t===r.plans.length-1,title:"Move down",style:{padding:"4px 8px"},children:u.Icons.chevronDown}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>H(e.id),title:"Delete plan",style:{padding:"4px 8px",color:"#dc2626"},children:u.Icons.trash})]})]}),n&&a.jsxs("div",{style:{padding:"1rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Plan Name"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.title,onChange:s=>c(e.id,{title:s.target.value}),placeholder:"e.g., Starter"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Button Text"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.buttonText||"",onChange:s=>c(e.id,{buttonText:s.target.value}),placeholder:"Purchase"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.description,onChange:s=>c(e.id,{description:s.target.value}),placeholder:"For entry-level developers managing lightweight workloads"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Monthly Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceMonthlyUsd||"",onChange:s=>c(e.id,{priceMonthlyUsd:parseFloat(s.target.value)||0}),placeholder:"10",min:"0",step:"0.01"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceAnnualUsd||"",onChange:s=>c(e.id,{priceAnnualUsd:parseFloat(s.target.value)||0}),placeholder:"100",min:"0",step:"0.01"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Feature Highlight"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.featureHighlight||"",onChange:s=>c(e.id,{featureHighlight:s.target.value}),placeholder:"100 prompts every 5 hours"}),a.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Bold text shown above feature list"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isPopular||!1,onChange:s=>c(e.id,{isPopular:s.target.checked})}),"Mark as Popular (featured styling)"]})}),a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isActive,onChange:s=>c(e.id,{isActive:s.target.checked})}),"Active (available for purchase)"]})})]}),a.jsxs("div",{className:"cedros-admin__form-row",style:{marginTop:"0.5rem"},children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.inventoryQuantity!=null,onChange:s=>c(e.id,{inventoryQuantity:s.target.checked?100:null})}),"Limit quantity available"]})}),e.inventoryQuantity!=null&&a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Total Available"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.inventoryQuantity??"",onChange:s=>c(e.id,{inventoryQuantity:parseInt(s.target.value)||0}),min:"0",style:{width:100}}),e.inventorySold!=null&&e.inventorySold>0&&a.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:[e.inventorySold," sold · ",Math.max(0,e.inventoryQuantity-e.inventorySold)," remaining"]})]})]}),a.jsxs("div",{style:{marginTop:"1rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[a.jsxs("label",{className:"cedros-admin__field-label",style:{margin:0},children:["Feature List (",e.features.length,")"]}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>Q(e.id),style:{fontSize:12,padding:"4px 8px"},children:"+ Add Feature"})]}),e.features.length===0?a.jsx("div",{style:{padding:"1rem",textAlign:"center",opacity:.5,fontSize:13,border:"1px dashed currentColor",borderRadius:6},children:'No features. Click "Add Feature" to add bullet points.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:e.features.map((s,o)=>a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsxs("span",{style:{opacity:.4,fontSize:12},children:[o+1,"."]}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:s,onChange:g=>J(e.id,o,g.target.value),placeholder:"e.g., Powered by MiniMax M2.1",style:{flex:1}}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>q(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:u.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=G;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),u=require("./index-7YUxR4u5.js"),i={enabled:!1,plans:[],pageTitle:"Choose Your Plan",pageSubtitle:"Select the plan that best fits your needs.",annualSavingsBadge:"2 months free",popularBadgeText:"Best Deal",footerNotice:""},X={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function Y(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function G({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[p,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,j]=d.useState(null),[l,m]=d.useState({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),[x,P]=d.useState(l),[F,C]=d.useState(""),w=d.useCallback(async()=>{try{j(null);let e;const t="/admin/subscriptions/settings";if(f?.isAuthenticated())e=await f.fetchWithAuth(t);else{const n={"Content-Type":"application/json"};b&&(n["X-API-Key"]=b);const s=await fetch(`${v}${t}`,{headers:n});if(!s.ok)throw new Error(`Failed to fetch settings: ${s.status}`);e=await s.json()}h({...i,...e}),m({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),P({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),C(JSON.stringify(e.plans??[]))}catch{h(i),m({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),P({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),C(JSON.stringify([])),j("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const I=d.useCallback(async e=>{try{j(null);const t="/admin/subscriptions/settings",n=JSON.stringify(e);if(f?.isAuthenticated())await f.fetchWithAuth(t,{method:"PUT",body:n});else{const s={"Content-Type":"application/json"};b&&(s["X-API-Key"]=b);const o=await fetch(`${v}${t}`,{method:"PUT",headers:s,body:n});if(!o.ok)throw new Error(`Failed to save settings: ${o.status}`)}return!0}catch{return j("Failed to save subscription settings"),!1}},[f,b,v]),E=d.useMemo(()=>x.enabled!==l.enabled||x.pageTitle!==l.pageTitle||x.pageSubtitle!==l.pageSubtitle||x.annualSavingsBadge!==l.annualSavingsBadge||x.popularBadgeText!==l.popularBadgeText||x.footerNotice!==l.footerNotice,[l,x]),D=d.useMemo(()=>JSON.stringify(r.plans),[r.plans]),U=d.useMemo(()=>F!==D,[D,F]),S=d.useCallback(async()=>{const e={...r,enabled:l.enabled,pageTitle:l.pageTitle,pageSubtitle:l.pageSubtitle,annualSavingsBadge:l.annualSavingsBadge,popularBadgeText:l.popularBadgeText,footerNotice:l.footerNotice};B("saving");const t=await I(e);h(e),t&&(P({enabled:e.enabled,pageTitle:e.pageTitle,pageSubtitle:e.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge,popularBadgeText:e.popularBadgeText,footerNotice:e.footerNotice}),C(JSON.stringify(e.plans))),B(t?"saved":"error"),setTimeout(()=>B("idle"),1500)},[l,I,r]);d.useEffect(()=>{if(p!=="page"||_||!E)return;const e=setTimeout(S,600);return()=>clearTimeout(e)},[p,E,_,S]),d.useEffect(()=>{if(p!=="plans"||_||!U)return;const e=setTimeout(S,800);return()=>clearTimeout(e)},[p,U,_,S]);const O=()=>{const e={...X,id:Y(),sortOrder:r.plans.length};h(t=>({...t,plans:[...t.plans,e]})),T(e.id)},c=(e,t)=>{h(n=>({...n,plans:n.plans.map(s=>s.id===e?{...s,...t}:s)}))},H=e=>{confirm("Delete this plan? This cannot be undone.")&&(h(t=>({...t,plans:t.plans.filter(n=>n.id!==e)})),k===e&&T(null))},$=(e,t)=>{const n=r.plans.findIndex(g=>g.id===e);if(n===-1||t==="up"&&n===0||t==="down"&&n===r.plans.length-1)return;const s=[...r.plans],o=t==="up"?n-1:n+1;[s[n],s[o]]=[s[o],s[n]],h(g=>({...g,plans:s}))},Q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},J=(e,t,n)=>{const s=r.plans.find(g=>g.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},q=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,g)=>g!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[u.Icons.loading," Loading subscription settings..."]})});const M=r.plans.filter(e=>e.isActive).length,L=r.plans.reduce((e,t)=>e+(t.activeSubscribers??0),0),N=l.enabled,W=r.plans.filter(e=>e.isActive).map(e=>({label:e.title,value:e.activeSubscribers??0,description:"subscribers"}));return a.jsxs("div",{className:"cedros-admin__page",children:[a.jsx(u.ErrorBanner,{message:z,onRetry:w}),a.jsx(u.StatsBar,{stats:[{label:"Status",value:N?"Enabled":"Disabled",variant:N?"success":"muted"},{label:"Active Plans",value:M,variant:M>0?"success":"muted"},{label:"Total Subscribers",value:L,variant:L>0?"success":"muted"},...W],isLoading:_}),a.jsxs("div",{className:"cedros-admin__section",children:[a.jsxs("div",{className:"cedros-admin__section-header",children:[a.jsx("h3",{className:"cedros-admin__section-title",children:"Subscription Settings"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[p==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[u.Icons.plus,"Add Plan"]}),a.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${y}`,children:[y==="saving"&&"Saving...",y==="saved"&&"Saved",y==="error"&&"Error"]})]})]}),a.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),p==="page"&&a.jsxs("div",{children:[a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Subscriptions"}),a.jsxs("label",{className:"cedros-admin__toggle",children:[a.jsx("input",{type:"checkbox",className:"cedros-admin__toggle-input",checked:l.enabled,onChange:e=>m(t=>({...t,enabled:e.target.checked}))}),a.jsx("span",{className:"cedros-admin__toggle-track",children:a.jsx("span",{className:"cedros-admin__toggle-thumb"})}),a.jsx("span",{className:"cedros-admin__toggle-label",children:"Enable Subscriptions"})]})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageTitle||"",onChange:e=>m(t=>({...t,pageTitle:e.target.value})),placeholder:"Choose Your Plan"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Subtitle"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageSubtitle||"",onChange:e=>m(t=>({...t,pageSubtitle:e.target.value})),placeholder:"Select the plan that best fits your needs."})]})]}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Savings Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.annualSavingsBadge||"",onChange:e=>m(t=>({...t,annualSavingsBadge:e.target.value})),placeholder:"2 months free"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Popular Plan Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.popularBadgeText||"",onChange:e=>m(t=>({...t,popularBadgeText:e.target.value})),placeholder:"Best Deal"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Footer Notice (optional)"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.footerNotice||"",onChange:e=>m(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),p==="plans"&&a.jsxs("div",{children:[!N&&a.jsx("div",{style:{padding:"1.5rem",textAlign:"center",opacity:.6},children:"Subscriptions are disabled. Enable them to configure plans."}),r.plans.length===0?a.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6,border:"1px dashed currentColor",borderRadius:8},children:'No plans configured. Click "Add Plan" to create your first subscription tier.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:r.plans.map((e,t)=>{const n=k===e.id;return a.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:8,overflow:"hidden",background:e.isPopular?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",padding:"0.75rem 1rem",cursor:"pointer"},onClick:()=>T(n?null:e.id),children:[a.jsx("span",{style:{opacity:.5},children:n?u.Icons.chevronDown:u.Icons.chevronRight}),a.jsxs("div",{style:{flex:1},children:[a.jsx("span",{style:{fontWeight:600},children:e.title||"Untitled Plan"}),e.isPopular&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"var(--cedros-admin-primary, #171717)",color:"#fff"},children:"Popular"}),!e.isActive&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"#9ca3af",color:"#fff"},children:"Inactive"})]}),a.jsxs("span",{style:{opacity:.6,fontSize:14},children:["$",e.priceMonthlyUsd,"/mo · $",e.priceAnnualUsd,"/yr"]}),a.jsxs("div",{style:{display:"flex",gap:"0.25rem"},onClick:s=>s.stopPropagation(),children:[a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"up"),disabled:t===0,title:"Move up",style:{padding:"4px 8px"},children:u.Icons.chevronUp}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"down"),disabled:t===r.plans.length-1,title:"Move down",style:{padding:"4px 8px"},children:u.Icons.chevronDown}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>H(e.id),title:"Delete plan",style:{padding:"4px 8px",color:"#dc2626"},children:u.Icons.trash})]})]}),n&&a.jsxs("div",{style:{padding:"1rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Plan Name"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.title,onChange:s=>c(e.id,{title:s.target.value}),placeholder:"e.g., Starter"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Button Text"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.buttonText||"",onChange:s=>c(e.id,{buttonText:s.target.value}),placeholder:"Purchase"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.description,onChange:s=>c(e.id,{description:s.target.value}),placeholder:"For entry-level developers managing lightweight workloads"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Monthly Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceMonthlyUsd||"",onChange:s=>c(e.id,{priceMonthlyUsd:parseFloat(s.target.value)||0}),placeholder:"10",min:"0",step:"0.01"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceAnnualUsd||"",onChange:s=>c(e.id,{priceAnnualUsd:parseFloat(s.target.value)||0}),placeholder:"100",min:"0",step:"0.01"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Feature Highlight"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.featureHighlight||"",onChange:s=>c(e.id,{featureHighlight:s.target.value}),placeholder:"100 prompts every 5 hours"}),a.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Bold text shown above feature list"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isPopular||!1,onChange:s=>c(e.id,{isPopular:s.target.checked})}),"Mark as Popular (featured styling)"]})}),a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isActive,onChange:s=>c(e.id,{isActive:s.target.checked})}),"Active (available for purchase)"]})})]}),a.jsxs("div",{className:"cedros-admin__form-row",style:{marginTop:"0.5rem"},children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.inventoryQuantity!=null,onChange:s=>c(e.id,{inventoryQuantity:s.target.checked?100:null})}),"Limit quantity available"]})}),e.inventoryQuantity!=null&&a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Total Available"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.inventoryQuantity??"",onChange:s=>c(e.id,{inventoryQuantity:parseInt(s.target.value)||0}),min:"0",style:{width:100}}),e.inventorySold!=null&&e.inventorySold>0&&a.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:[e.inventorySold," sold · ",Math.max(0,e.inventoryQuantity-e.inventorySold)," remaining"]})]})]}),a.jsxs("div",{style:{marginTop:"1rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[a.jsxs("label",{className:"cedros-admin__field-label",style:{margin:0},children:["Feature List (",e.features.length,")"]}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>Q(e.id),style:{fontSize:12,padding:"4px 8px"},children:"+ Add Feature"})]}),e.features.length===0?a.jsx("div",{style:{padding:"1rem",textAlign:"center",opacity:.5,fontSize:13,border:"1px dashed currentColor",borderRadius:6},children:'No features. Click "Add Feature" to add bullet points.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:e.features.map((s,o)=>a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsxs("span",{style:{opacity:.4,fontSize:12},children:[o+1,"."]}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:s,onChange:g=>J(e.id,o,g.target.value),placeholder:"e.g., Powered by MiniMax M2.1",style:{flex:1}}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>q(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:u.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=G;
|