admin-lib-cms 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -41,31 +41,256 @@ __export(index_exports, {
41
41
  module.exports = __toCommonJS(index_exports);
42
42
 
43
43
  // src/provider.tsx
44
+ var import_react3 = require("react");
45
+
46
+ // src/subscription/SubscriptionProvider.tsx
44
47
  var import_react = require("react");
45
48
  var import_jsx_runtime = require("react/jsx-runtime");
46
- var CmsContext = (0, import_react.createContext)(null);
49
+ var SubscriptionContext = (0, import_react.createContext)(void 0);
50
+ function useSubscriptionContext() {
51
+ const ctx = (0, import_react.useContext)(SubscriptionContext);
52
+ if (!ctx) {
53
+ throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
54
+ }
55
+ return ctx;
56
+ }
57
+ function useSubscription() {
58
+ return useSubscriptionContext();
59
+ }
60
+ function SubscriptionProvider({
61
+ children,
62
+ apiUrl,
63
+ projectId,
64
+ email,
65
+ validateSubscriptionUrl
66
+ }) {
67
+ const [subscription, setSubscription] = (0, import_react.useState)(null);
68
+ const [loading, setLoading] = (0, import_react.useState)(true);
69
+ const [error, setError] = (0, import_react.useState)(null);
70
+ const fetchSubscription = (0, import_react.useCallback)(
71
+ async (silent = false) => {
72
+ if (!apiUrl || !projectId) {
73
+ setLoading(false);
74
+ return;
75
+ }
76
+ if (!silent) setLoading(true);
77
+ setError(null);
78
+ try {
79
+ const endpoint = validateSubscriptionUrl || `${apiUrl}/api/validate-subscription`;
80
+ const res = await fetch(endpoint, {
81
+ method: "POST",
82
+ headers: { "Content-Type": "application/json" },
83
+ body: JSON.stringify({ projectId })
84
+ });
85
+ if (!res.ok) throw new Error(`Server error: ${res.status}`);
86
+ const data = await res.json();
87
+ setSubscription({
88
+ subscriptionStatus: data.valid ? data.status : "inactive",
89
+ currentPeriodEnd: data.expiryDate,
90
+ customerEmail: email,
91
+ subscriptionId: data._id,
92
+ stripeCustomerId: data.stripeCustomerId,
93
+ stripePaymentLink: data.stripePaymentLink,
94
+ valid: data.valid
95
+ });
96
+ } catch (err) {
97
+ console.error("SubscriptionProvider Error:", err);
98
+ setError(err.message || "Failed to fetch subscription");
99
+ setSubscription({ subscriptionStatus: "active", valid: true });
100
+ } finally {
101
+ setLoading(false);
102
+ }
103
+ },
104
+ [apiUrl, projectId, email]
105
+ );
106
+ (0, import_react.useEffect)(() => {
107
+ fetchSubscription();
108
+ const handleFocus = () => {
109
+ fetchSubscription(true);
110
+ };
111
+ window.addEventListener("focus", handleFocus);
112
+ let intervalId;
113
+ if (subscription && !subscription.valid) {
114
+ intervalId = setInterval(() => {
115
+ fetchSubscription(true);
116
+ }, 1e4);
117
+ }
118
+ return () => {
119
+ window.removeEventListener("focus", handleFocus);
120
+ if (intervalId) clearInterval(intervalId);
121
+ };
122
+ }, [fetchSubscription, subscription?.valid]);
123
+ let daysOverdue = 0;
124
+ if (subscription && !subscription.valid && subscription.currentPeriodEnd) {
125
+ const diffTime = Date.now() - new Date(subscription.currentPeriodEnd).getTime();
126
+ if (diffTime > 0) {
127
+ daysOverdue = Math.floor(diffTime / (1e3 * 60 * 60 * 24));
128
+ }
129
+ }
130
+ const isSubscriptionActive = subscription ? subscription.valid || daysOverdue < 30 : true;
131
+ const value = {
132
+ subscription,
133
+ loading,
134
+ error,
135
+ refetch: fetchSubscription,
136
+ isSubscriptionActive,
137
+ daysOverdue,
138
+ config: { apiUrl, projectId }
139
+ };
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubscriptionContext.Provider, { value, children });
141
+ }
142
+
143
+ // src/subscription/SubscriptionPage.tsx
144
+ var import_react2 = require("react");
145
+ var import_lucide_react = require("lucide-react");
146
+ var import_jsx_runtime2 = require("react/jsx-runtime");
147
+ function SubscriptionPage() {
148
+ const { subscription, loading, config } = useSubscription();
149
+ const [actionLoading, setActionLoading] = (0, import_react2.useState)(null);
150
+ const status = subscription?.subscriptionStatus || "inactive";
151
+ const isValid = subscription?.valid ?? false;
152
+ const handleSubscribe = () => {
153
+ if (!subscription?.stripePaymentLink) {
154
+ alert("No payment link found. Please contact support.");
155
+ return;
156
+ }
157
+ const raw = subscription.stripePaymentLink;
158
+ const url = raw.startsWith("http") ? raw : `https://buy.stripe.com/${raw}`;
159
+ window.open(url, "_blank");
160
+ };
161
+ const handleManageBilling = async () => {
162
+ if (!subscription?.stripeCustomerId) {
163
+ alert("No customer ID available. Please contact support.");
164
+ return;
165
+ }
166
+ setActionLoading("billing");
167
+ try {
168
+ const returnUrl = window.location.href;
169
+ const apiUrl = config.apiUrl || "https://dev-soft-admin-sigma.vercel.app";
170
+ const res = await fetch(`${apiUrl}/api/create-billing-session`, {
171
+ method: "POST",
172
+ headers: { "Content-Type": "application/json" },
173
+ body: JSON.stringify({
174
+ customerId: subscription.stripeCustomerId,
175
+ returnUrl
176
+ })
177
+ });
178
+ if (!res.ok) throw new Error(`Server error: ${res.status}`);
179
+ const data = await res.json();
180
+ if (data.url) {
181
+ window.open(data.url, "_blank");
182
+ } else {
183
+ alert("Could not create billing session.");
184
+ }
185
+ } catch (err) {
186
+ alert(`Portal failed: ${err.message}`);
187
+ } finally {
188
+ setActionLoading(null);
189
+ }
190
+ };
191
+ if (loading && !subscription) {
192
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex h-full min-h-[500px] w-full items-center justify-center bg-slate-50", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col items-center gap-3 text-slate-500", children: [
193
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-indigo-200 border-t-indigo-600" }),
194
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-sm font-medium", children: "Verifying subscription..." })
195
+ ] }) });
196
+ }
197
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex min-h-screen w-full flex-col items-center justify-center bg-slate-50 p-6", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "w-full max-w-md overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-xl", children: [
198
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `p-8 text-center ${isValid ? "bg-emerald-50" : "bg-rose-50"}`, children: [
199
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white shadow-sm", children: isValid ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.CheckCircle2, { className: "h-8 w-8 text-emerald-500" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.AlertTriangle, { className: "h-8 w-8 text-rose-500" }) }),
200
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: isValid ? "Subscription Active" : "Subscription Inactive" }),
201
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mt-2 text-sm text-slate-600", children: isValid ? "Your subscription is currently active and in good standing." : "Your project requires an active subscription to access the administration panel." })
202
+ ] }),
203
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-8", children: [
204
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "space-y-4", children: [
205
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
206
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Status" }),
207
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold capitalize ${isValid ? "bg-emerald-100 text-emerald-700" : "bg-rose-100 text-rose-700"}`, children: status })
208
+ ] }),
209
+ subscription?.currentPeriodEnd && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
210
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Next Billing Date" }),
211
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-sm font-semibold text-slate-900", children: new Date(subscription.currentPeriodEnd).toLocaleDateString() })
212
+ ] })
213
+ ] }),
214
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mt-8 space-y-3", children: [
215
+ !isValid && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
216
+ "button",
217
+ {
218
+ onClick: handleSubscribe,
219
+ className: "group flex w-full items-center justify-center gap-2 rounded-xl bg-indigo-600 px-4 py-3.5 text-sm font-semibold text-white shadow-sm transition-all hover:bg-indigo-700 hover:shadow",
220
+ children: [
221
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.CreditCard, { className: "h-4 w-4" }),
222
+ "Pay Now to Restore Access",
223
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ExternalLink, { className: "h-3.5 w-3.5 opacity-70 transition-transform group-hover:translate-x-0.5" })
224
+ ]
225
+ }
226
+ ),
227
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
228
+ "button",
229
+ {
230
+ onClick: handleManageBilling,
231
+ disabled: actionLoading === "billing",
232
+ className: "group flex w-full items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-3.5 text-sm font-semibold text-slate-700 shadow-sm transition-all hover:bg-slate-50 hover:text-slate-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50",
233
+ children: [
234
+ actionLoading === "billing" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-slate-300 border-t-slate-600" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Settings, { className: "h-4 w-4 text-slate-400 group-hover:text-slate-600" }),
235
+ "Manage Billing & Invoices"
236
+ ]
237
+ }
238
+ )
239
+ ] })
240
+ ] })
241
+ ] }) });
242
+ }
243
+
244
+ // src/provider.tsx
245
+ var import_jsx_runtime3 = require("react/jsx-runtime");
246
+ var CmsContext = (0, import_react3.createContext)(null);
47
247
  function useCmsContext() {
48
- const ctx = (0, import_react.useContext)(CmsContext);
248
+ const ctx = (0, import_react3.useContext)(CmsContext);
49
249
  if (!ctx) throw new Error("useCms must be used inside <CmsProvider>");
50
250
  return ctx;
51
251
  }
52
252
  function useCmsOptional() {
53
- return (0, import_react.useContext)(CmsContext);
253
+ return (0, import_react3.useContext)(CmsContext);
54
254
  }
55
- function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
56
- const [overrides, setOverrides] = (0, import_react.useState)(initialOverrides || {});
57
- const [savedOverrides, setSavedOverrides] = (0, import_react.useState)(initialOverrides || {});
58
- const [selectedId, setSelectedIdRaw] = (0, import_react.useState)(null);
59
- const [editMode, setEditMode] = (0, import_react.useState)(false);
60
- const [collectionChangedAt, setCollectionChangedAt] = (0, import_react.useState)(0);
61
- const registryRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
62
- (0, import_react.useEffect)(() => {
255
+ function CmsProvider(props) {
256
+ if (props.projectId) {
257
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
258
+ SubscriptionProvider,
259
+ {
260
+ apiUrl: props.apiUrl,
261
+ projectId: props.projectId,
262
+ email: props.email,
263
+ validateSubscriptionUrl: props.validateSubscriptionUrl,
264
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CmsProviderInner, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SiteGuard, { children: props.children }) })
265
+ }
266
+ );
267
+ }
268
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CmsProviderInner, { ...props, children: props.children });
269
+ }
270
+ function SiteGuard({ children }) {
271
+ const { daysOverdue, isSubscriptionActive } = useSubscription();
272
+ if (!isSubscriptionActive && daysOverdue >= 60) {
273
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", height: "100vh", width: "100%", alignItems: "center", justifyContent: "center", backgroundColor: "#f8fafc", color: "#0f172a", fontFamily: "system-ui, -apple-system, sans-serif" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { textAlign: "center", padding: "2rem", maxWidth: "32rem" }, children: [
274
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { style: { fontSize: "1.5rem", fontWeight: 600, marginBottom: "0.5rem" }, children: "This website is temporarily unavailable" }),
275
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { style: { color: "#64748b" }, children: "Please contact the site administrator if you believe this is an error." })
276
+ ] }) });
277
+ }
278
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
279
+ }
280
+ function CmsProviderInner({ config, adapter, children, iconMap, initialOverrides }) {
281
+ const [overrides, setOverrides] = (0, import_react3.useState)(initialOverrides || {});
282
+ const [savedOverrides, setSavedOverrides] = (0, import_react3.useState)(initialOverrides || {});
283
+ const [selectedId, setSelectedIdRaw] = (0, import_react3.useState)(null);
284
+ const [editMode, setEditMode] = (0, import_react3.useState)(false);
285
+ const [collectionChangedAt, setCollectionChangedAt] = (0, import_react3.useState)(0);
286
+ const registryRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
287
+ (0, import_react3.useEffect)(() => {
63
288
  if (typeof window === "undefined" || typeof BroadcastChannel === "undefined") return;
64
289
  const bc = new BroadcastChannel("admin-cms:collection-changed");
65
290
  bc.onmessage = () => setCollectionChangedAt(Date.now());
66
291
  return () => bc.close();
67
292
  }, []);
68
- const notifyCollectionChanged = (0, import_react.useCallback)(() => {
293
+ const notifyCollectionChanged = (0, import_react3.useCallback)(() => {
69
294
  setCollectionChangedAt(Date.now());
70
295
  if (typeof BroadcastChannel !== "undefined") {
71
296
  const bc = new BroadcastChannel("admin-cms:collection-changed");
@@ -73,12 +298,12 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
73
298
  bc.close();
74
299
  }
75
300
  }, []);
76
- (0, import_react.useEffect)(() => {
301
+ (0, import_react3.useEffect)(() => {
77
302
  if (typeof window === "undefined") return;
78
303
  const params = new URLSearchParams(window.location.search);
79
304
  if (params.get("__cms") === "edit") setEditMode(true);
80
305
  }, []);
81
- (0, import_react.useEffect)(() => {
306
+ (0, import_react3.useEffect)(() => {
82
307
  let cancelled = false;
83
308
  adapter.getOverrides().then((o) => {
84
309
  if (cancelled) return;
@@ -89,7 +314,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
89
314
  cancelled = true;
90
315
  };
91
316
  }, [adapter]);
92
- (0, import_react.useEffect)(() => {
317
+ (0, import_react3.useEffect)(() => {
93
318
  if (!editMode || typeof window === "undefined") return;
94
319
  const parent = window.parent;
95
320
  if (!parent || parent === window) return;
@@ -107,7 +332,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
107
332
  window.addEventListener("message", onMsg);
108
333
  return () => window.removeEventListener("message", onMsg);
109
334
  }, [editMode]);
110
- const setSelectedId = (0, import_react.useCallback)(
335
+ const setSelectedId = (0, import_react3.useCallback)(
111
336
  (id) => {
112
337
  setSelectedIdRaw(id);
113
338
  if (editMode && typeof window !== "undefined" && window.parent && window.parent !== window) {
@@ -119,7 +344,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
119
344
  },
120
345
  [editMode]
121
346
  );
122
- const registerEditable = (0, import_react.useCallback)((meta) => {
347
+ const registerEditable = (0, import_react3.useCallback)((meta) => {
123
348
  registryRef.current.set(meta.id, meta);
124
349
  if (typeof window !== "undefined" && window.parent && window.parent !== window) {
125
350
  window.parent.postMessage(
@@ -132,7 +357,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
132
357
  );
133
358
  }
134
359
  }, []);
135
- const unregisterEditable = (0, import_react.useCallback)((id) => {
360
+ const unregisterEditable = (0, import_react3.useCallback)((id) => {
136
361
  registryRef.current.delete(id);
137
362
  if (typeof window !== "undefined" && window.parent && window.parent !== window) {
138
363
  window.parent.postMessage(
@@ -145,14 +370,14 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
145
370
  );
146
371
  }
147
372
  }, []);
148
- const setOverride = (0, import_react.useCallback)((id, value2) => {
373
+ const setOverride = (0, import_react3.useCallback)((id, value2) => {
149
374
  setOverrides((prev) => ({ ...prev, [id]: value2 }));
150
375
  }, []);
151
- const save = (0, import_react.useCallback)(async () => {
376
+ const save = (0, import_react3.useCallback)(async () => {
152
377
  await adapter.setOverrides(overrides);
153
378
  setSavedOverrides(overrides);
154
379
  }, [adapter, overrides]);
155
- const reset = (0, import_react.useCallback)(
380
+ const reset = (0, import_react3.useCallback)(
156
381
  async (id) => {
157
382
  if (id) {
158
383
  setOverrides((prev) => {
@@ -166,15 +391,15 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
166
391
  },
167
392
  []
168
393
  );
169
- const isDirty = (0, import_react.useMemo)(
394
+ const isDirty = (0, import_react3.useMemo)(
170
395
  () => JSON.stringify(overrides) !== JSON.stringify(savedOverrides),
171
396
  [overrides, savedOverrides]
172
397
  );
173
- const getRegistered = (0, import_react.useCallback)(
398
+ const getRegistered = (0, import_react3.useCallback)(
174
399
  () => Array.from(registryRef.current.values()),
175
400
  []
176
401
  );
177
- const value = (0, import_react.useMemo)(() => ({
402
+ const value = (0, import_react3.useMemo)(() => ({
178
403
  config,
179
404
  adapter,
180
405
  overrides,
@@ -193,10 +418,10 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
193
418
  collectionChangedAt,
194
419
  notifyCollectionChanged
195
420
  }), [config, adapter, overrides, editMode, selectedId, setSelectedId, setOverride, registerEditable, unregisterEditable, getRegistered, save, reset, isDirty, iconMap, collectionChangedAt, notifyCollectionChanged]);
196
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CmsContext.Provider, { value, children });
421
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CmsContext.Provider, { value, children });
197
422
  }
198
423
  function useSubmit(formId) {
199
- const ctx = (0, import_react.useContext)(CmsContext);
424
+ const ctx = (0, import_react3.useContext)(CmsContext);
200
425
  return async (data) => {
201
426
  const submission = {
202
427
  id: crypto.randomUUID(),
@@ -223,11 +448,11 @@ function useSubmit(formId) {
223
448
  }
224
449
 
225
450
  // src/editable.tsx
226
- var import_react2 = require("react");
227
- var import_jsx_runtime2 = require("react/jsx-runtime");
451
+ var import_react4 = require("react");
452
+ var import_jsx_runtime4 = require("react/jsx-runtime");
228
453
  function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength) {
229
454
  const ctx = useCmsOptional();
230
- (0, import_react2.useEffect)(() => {
455
+ (0, import_react4.useEffect)(() => {
231
456
  if (!ctx) return;
232
457
  ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength });
233
458
  return () => ctx.unregisterEditable(id);
@@ -260,7 +485,7 @@ function EditableText({
260
485
  e.stopPropagation();
261
486
  ctx.setSelectedId(id);
262
487
  };
263
- return (0, import_react2.createElement)(
488
+ return (0, import_react4.createElement)(
264
489
  as,
265
490
  {
266
491
  className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
@@ -291,7 +516,7 @@ function EditableImage({
291
516
  e.stopPropagation();
292
517
  ctx.setSelectedId(id);
293
518
  };
294
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
519
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
295
520
  "img",
296
521
  {
297
522
  src: value,
@@ -311,13 +536,15 @@ function EditableLink({
311
536
  pageId,
312
537
  href,
313
538
  children,
539
+ text,
314
540
  className,
315
541
  target
316
542
  }) {
317
- const ctx = useRegister(id, "link", label, section, pageId, { href, text: children });
543
+ const defaultText = text ?? (typeof children === "string" ? children : "");
544
+ const ctx = useRegister(id, "link", label, section, pageId, { href, text: defaultText });
318
545
  const override = ctx?.overrides[id];
319
546
  const hrefValue = override?.href ?? href;
320
- const textValue = override?.text ?? children;
547
+ const textValue = override?.text ?? defaultText;
321
548
  const active = !!ctx?.editMode;
322
549
  const selected = ctx?.selectedId === id;
323
550
  const onClick = (e) => {
@@ -329,7 +556,7 @@ function EditableLink({
329
556
  const isExternal = hrefValue.startsWith("http");
330
557
  const computedTarget = target || (isExternal ? "_blank" : void 0);
331
558
  const computedRel = computedTarget === "_blank" ? "noopener noreferrer" : void 0;
332
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
559
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
333
560
  "a",
334
561
  {
335
562
  href: hrefValue,
@@ -338,7 +565,7 @@ function EditableLink({
338
565
  "data-cms-id": id,
339
566
  onClick: active ? onClick : void 0,
340
567
  className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
341
- children: textValue
568
+ children: typeof children !== "undefined" ? children : textValue
342
569
  }
343
570
  );
344
571
  }
@@ -366,13 +593,13 @@ function EditableList({
366
593
  e.stopPropagation();
367
594
  ctx.setSelectedId(id);
368
595
  };
369
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
596
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
370
597
  "div",
371
598
  {
372
599
  "data-cms-id": id,
373
600
  onClick: active ? onClick : void 0,
374
601
  className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
375
- children: renderList ? renderList(value) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: listClassName, children: renderItem && value.map(renderItem) })
602
+ children: renderList ? renderList(value) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: listClassName, children: renderItem && value.map(renderItem) })
376
603
  }
377
604
  );
378
605
  }
@@ -381,195 +608,6 @@ function EditableList({
381
608
  var import_react5 = require("react");
382
609
  var import_lucide_react2 = require("lucide-react");
383
610
  var import_lucide_react3 = require("lucide-react");
384
-
385
- // src/subscription/SubscriptionProvider.tsx
386
- var import_react3 = require("react");
387
- var import_jsx_runtime3 = require("react/jsx-runtime");
388
- var SubscriptionContext = (0, import_react3.createContext)(void 0);
389
- function useSubscriptionContext() {
390
- const ctx = (0, import_react3.useContext)(SubscriptionContext);
391
- if (!ctx) {
392
- throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
393
- }
394
- return ctx;
395
- }
396
- function useSubscription() {
397
- return useSubscriptionContext();
398
- }
399
- function SubscriptionProvider({
400
- children,
401
- apiUrl,
402
- projectId,
403
- email
404
- }) {
405
- const [subscription, setSubscription] = (0, import_react3.useState)(null);
406
- const [loading, setLoading] = (0, import_react3.useState)(true);
407
- const [error, setError] = (0, import_react3.useState)(null);
408
- const fetchSubscription = (0, import_react3.useCallback)(
409
- async (silent = false) => {
410
- if (!apiUrl || !projectId) {
411
- setLoading(false);
412
- return;
413
- }
414
- if (!silent) setLoading(true);
415
- setError(null);
416
- try {
417
- const res = await fetch(`${apiUrl}/api/validate-subscription`, {
418
- method: "POST",
419
- headers: { "Content-Type": "application/json" },
420
- body: JSON.stringify({ projectId })
421
- });
422
- if (!res.ok) throw new Error(`Server error: ${res.status}`);
423
- const data = await res.json();
424
- setSubscription({
425
- subscriptionStatus: data.valid ? data.status : "inactive",
426
- currentPeriodEnd: data.expiryDate,
427
- customerEmail: email,
428
- subscriptionId: data._id,
429
- stripeCustomerId: data.stripeCustomerId,
430
- stripePaymentLink: data.stripePaymentLink,
431
- valid: data.valid
432
- });
433
- } catch (err) {
434
- console.error("SubscriptionProvider Error:", err);
435
- setError(err.message || "Failed to fetch subscription");
436
- setSubscription({ subscriptionStatus: "active", valid: true });
437
- } finally {
438
- setLoading(false);
439
- }
440
- },
441
- [apiUrl, projectId, email]
442
- );
443
- (0, import_react3.useEffect)(() => {
444
- fetchSubscription();
445
- const handleFocus = () => {
446
- fetchSubscription(true);
447
- };
448
- window.addEventListener("focus", handleFocus);
449
- let intervalId;
450
- if (subscription && !subscription.valid) {
451
- intervalId = setInterval(() => {
452
- fetchSubscription(true);
453
- }, 1e4);
454
- }
455
- return () => {
456
- window.removeEventListener("focus", handleFocus);
457
- if (intervalId) clearInterval(intervalId);
458
- };
459
- }, [fetchSubscription, subscription?.valid]);
460
- const value = {
461
- subscription,
462
- loading,
463
- error,
464
- refetch: fetchSubscription,
465
- isSubscriptionActive: subscription?.valid ?? true,
466
- config: { apiUrl, projectId }
467
- };
468
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SubscriptionContext.Provider, { value, children });
469
- }
470
-
471
- // src/subscription/SubscriptionPage.tsx
472
- var import_react4 = require("react");
473
- var import_lucide_react = require("lucide-react");
474
- var import_jsx_runtime4 = require("react/jsx-runtime");
475
- function SubscriptionPage() {
476
- const { subscription, loading, config } = useSubscription();
477
- const [actionLoading, setActionLoading] = (0, import_react4.useState)(null);
478
- const status = subscription?.subscriptionStatus || "inactive";
479
- const isValid = subscription?.valid ?? false;
480
- const handleSubscribe = () => {
481
- if (!subscription?.stripePaymentLink) {
482
- alert("No payment link found. Please contact support.");
483
- return;
484
- }
485
- const raw = subscription.stripePaymentLink;
486
- const url = raw.startsWith("http") ? raw : `https://buy.stripe.com/${raw}`;
487
- window.open(url, "_blank");
488
- };
489
- const handleManageBilling = async () => {
490
- if (!subscription?.stripeCustomerId) {
491
- alert("No customer ID available. Please contact support.");
492
- return;
493
- }
494
- setActionLoading("billing");
495
- try {
496
- const returnUrl = window.location.href;
497
- const apiUrl = config.apiUrl || "https://dev-soft-admin-sigma.vercel.app";
498
- const res = await fetch(`${apiUrl}/api/create-billing-session`, {
499
- method: "POST",
500
- headers: { "Content-Type": "application/json" },
501
- body: JSON.stringify({
502
- customerId: subscription.stripeCustomerId,
503
- returnUrl
504
- })
505
- });
506
- if (!res.ok) throw new Error(`Server error: ${res.status}`);
507
- const data = await res.json();
508
- if (data.url) {
509
- window.open(data.url, "_blank");
510
- } else {
511
- alert("Could not create billing session.");
512
- }
513
- } catch (err) {
514
- alert(`Portal failed: ${err.message}`);
515
- } finally {
516
- setActionLoading(null);
517
- }
518
- };
519
- if (loading && !subscription) {
520
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex h-full min-h-[500px] w-full items-center justify-center bg-slate-50", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col items-center gap-3 text-slate-500", children: [
521
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-indigo-200 border-t-indigo-600" }),
522
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-sm font-medium", children: "Verifying subscription..." })
523
- ] }) });
524
- }
525
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex min-h-screen w-full flex-col items-center justify-center bg-slate-50 p-6", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "w-full max-w-md overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-xl", children: [
526
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `p-8 text-center ${isValid ? "bg-emerald-50" : "bg-rose-50"}`, children: [
527
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white shadow-sm", children: isValid ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.CheckCircle2, { className: "h-8 w-8 text-emerald-500" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.AlertTriangle, { className: "h-8 w-8 text-rose-500" }) }),
528
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: isValid ? "Subscription Active" : "Subscription Inactive" }),
529
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "mt-2 text-sm text-slate-600", children: isValid ? "Your subscription is currently active and in good standing." : "Your project requires an active subscription to access the administration panel." })
530
- ] }),
531
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "p-8", children: [
532
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "space-y-4", children: [
533
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
534
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Status" }),
535
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: `inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold capitalize ${isValid ? "bg-emerald-100 text-emerald-700" : "bg-rose-100 text-rose-700"}`, children: status })
536
- ] }),
537
- subscription?.currentPeriodEnd && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
538
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Next Billing Date" }),
539
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-semibold text-slate-900", children: new Date(subscription.currentPeriodEnd).toLocaleDateString() })
540
- ] })
541
- ] }),
542
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mt-8 space-y-3", children: [
543
- !isValid && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
544
- "button",
545
- {
546
- onClick: handleSubscribe,
547
- className: "group flex w-full items-center justify-center gap-2 rounded-xl bg-indigo-600 px-4 py-3.5 text-sm font-semibold text-white shadow-sm transition-all hover:bg-indigo-700 hover:shadow",
548
- children: [
549
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.CreditCard, { className: "h-4 w-4" }),
550
- "Pay Now to Restore Access",
551
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.ExternalLink, { className: "h-3.5 w-3.5 opacity-70 transition-transform group-hover:translate-x-0.5" })
552
- ]
553
- }
554
- ),
555
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
556
- "button",
557
- {
558
- onClick: handleManageBilling,
559
- disabled: actionLoading === "billing",
560
- className: "group flex w-full items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-3.5 text-sm font-semibold text-slate-700 shadow-sm transition-all hover:bg-slate-50 hover:text-slate-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50",
561
- children: [
562
- actionLoading === "billing" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-slate-300 border-t-slate-600" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.Settings, { className: "h-4 w-4 text-slate-400 group-hover:text-slate-600" }),
563
- "Manage Billing & Invoices"
564
- ]
565
- }
566
- )
567
- ] })
568
- ] })
569
- ] }) });
570
- }
571
-
572
- // src/admin/AdminApp.tsx
573
611
  var import_jsx_runtime5 = require("react/jsx-runtime");
574
612
  async function handleImageFile(file, onUrl, uploadImage) {
575
613
  if (uploadImage) {
@@ -600,106 +638,111 @@ function AdminAppContent() {
600
638
  } catch (e) {
601
639
  }
602
640
  const isSubscriptionActive = subscriptionCtx?.isSubscriptionActive ?? true;
641
+ const daysOverdue = subscriptionCtx?.daysOverdue ?? 0;
603
642
  if (!isSubscriptionActive) {
604
643
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-col lg:flex-row h-screen w-full overflow-hidden bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {}) });
605
644
  }
606
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row h-screen w-full overflow-hidden bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900", children: [
607
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg:hidden flex items-center justify-between bg-white/80 backdrop-blur-xl border-b border-slate-200 px-4 py-3 shrink-0 z-20 relative", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
608
- ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
609
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-bold text-slate-900 tracking-tight", children: "Admin CMS" })
610
- ] }) }),
611
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { className: "flex w-full lg:w-64 shrink-0 flex-col border-b lg:border-b-0 lg:border-r border-slate-200 bg-white/80 backdrop-blur-xl shadow-sm z-10 overflow-hidden", children: [
612
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hidden lg:block border-b border-slate-200 px-6 py-5 bg-white/50", children: [
613
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 mb-1", children: [
614
- ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
615
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: "Admin CMS" })
645
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-screen w-full bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900 overflow-hidden", children: [
646
+ daysOverdue > 0 && daysOverdue <= 15 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-amber-400 text-amber-950 px-4 py-2.5 text-center text-sm font-semibold shadow-sm z-50", children: "Your account has an overdue balance. Please update your payment." }),
647
+ daysOverdue > 15 && daysOverdue < 30 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-rose-600 text-white px-4 py-2.5 text-center text-sm font-bold shadow-sm z-50", children: "Attention: If you do not settle your balance, your account will be suspended soon." }),
648
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
649
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg:hidden flex items-center justify-between bg-white/80 backdrop-blur-xl border-b border-slate-200 px-4 py-3 shrink-0 z-20 relative", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
650
+ ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
651
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-bold text-slate-900 tracking-tight", children: "Admin CMS" })
652
+ ] }) }),
653
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { className: "flex w-full lg:w-64 shrink-0 flex-col border-b lg:border-b-0 lg:border-r border-slate-200 bg-white/80 backdrop-blur-xl shadow-sm z-10 overflow-hidden", children: [
654
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hidden lg:block border-b border-slate-200 px-6 py-5 bg-white/50", children: [
655
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 mb-1", children: [
656
+ ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
657
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: "Admin CMS" })
658
+ ] }),
659
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
616
660
  ] }),
617
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
618
- ] }),
619
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("nav", { className: "flex flex-row lg:flex-col overflow-x-auto lg:overflow-visible space-x-2 lg:space-x-0 lg:space-y-1.5 p-3 lg:p-4 text-sm font-medium hide-scrollbar", children: [
620
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
621
- SideItem,
622
- {
623
- active: section === "pages",
624
- onClick: () => setSection("pages"),
625
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileText, { className: "h-4 w-4 shrink-0" }),
626
- children: "Pages"
627
- }
628
- ),
629
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
630
- SideItem,
631
- {
632
- active: section === "collections",
633
- onClick: () => setSection("collections"),
634
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
635
- children: "Collections"
636
- }
637
- ),
638
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
639
- SideItem,
640
- {
641
- active: section === "submissions",
642
- onClick: () => setSection("submissions"),
643
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-4 w-4 shrink-0" }),
644
- children: "Data"
645
- }
646
- ),
647
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
648
- SideItem,
649
- {
650
- active: section === "config",
651
- onClick: () => setSection("config"),
652
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
653
- children: "Config"
654
- }
655
- ),
656
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
657
- SideItem,
658
- {
659
- active: section === "settings",
660
- onClick: () => setSection("settings"),
661
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Settings, { className: "h-4 w-4 shrink-0" }),
662
- children: "Settings"
663
- }
664
- ),
665
- subscriptionCtx && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
666
- SideItem,
667
- {
668
- active: section === "subscription",
669
- onClick: () => setSection("subscription"),
670
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CreditCard, { className: "h-4 w-4 shrink-0" }),
671
- children: "Subscription"
672
- }
673
- )
674
- ] }),
675
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: [
676
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between text-xs text-slate-500 mb-4", children: [
677
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Storage Adapter" }),
678
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-semibold px-2 py-0.5 rounded-full bg-slate-200 text-slate-700", children: ctx.adapter.name })
661
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("nav", { className: "flex flex-row lg:flex-col overflow-x-auto lg:overflow-visible space-x-2 lg:space-x-0 lg:space-y-1.5 p-3 lg:p-4 text-sm font-medium hide-scrollbar", children: [
662
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
663
+ SideItem,
664
+ {
665
+ active: section === "pages",
666
+ onClick: () => setSection("pages"),
667
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileText, { className: "h-4 w-4 shrink-0" }),
668
+ children: "Pages"
669
+ }
670
+ ),
671
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
672
+ SideItem,
673
+ {
674
+ active: section === "collections",
675
+ onClick: () => setSection("collections"),
676
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
677
+ children: "Collections"
678
+ }
679
+ ),
680
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
681
+ SideItem,
682
+ {
683
+ active: section === "submissions",
684
+ onClick: () => setSection("submissions"),
685
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-4 w-4 shrink-0" }),
686
+ children: "Data"
687
+ }
688
+ ),
689
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
690
+ SideItem,
691
+ {
692
+ active: section === "config",
693
+ onClick: () => setSection("config"),
694
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
695
+ children: "Config"
696
+ }
697
+ ),
698
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
699
+ SideItem,
700
+ {
701
+ active: section === "settings",
702
+ onClick: () => setSection("settings"),
703
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Settings, { className: "h-4 w-4 shrink-0" }),
704
+ children: "Settings"
705
+ }
706
+ ),
707
+ subscriptionCtx && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
708
+ SideItem,
709
+ {
710
+ active: section === "subscription",
711
+ onClick: () => setSection("subscription"),
712
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CreditCard, { className: "h-4 w-4 shrink-0" }),
713
+ children: "Subscription"
714
+ }
715
+ )
679
716
  ] }),
680
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
681
- "button",
682
- {
683
- onClick: async () => {
684
- await fetch("/api/admin/auth?action=logout", { method: "POST" });
685
- window.location.href = "/admin/login";
686
- },
687
- className: "flex items-center justify-center gap-2 w-full px-3 py-2 text-sm font-medium text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",
688
- children: [
689
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.LogOut, { className: "w-4 h-4" }),
690
- "Logout"
691
- ]
692
- }
693
- )
717
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: [
718
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between text-xs text-slate-500 mb-4", children: [
719
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Storage Adapter" }),
720
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-semibold px-2 py-0.5 rounded-full bg-slate-200 text-slate-700", children: ctx.adapter.name })
721
+ ] }),
722
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
723
+ "button",
724
+ {
725
+ onClick: async () => {
726
+ await fetch("/api/admin/auth?action=logout", { method: "POST" });
727
+ window.location.href = "/admin/login";
728
+ },
729
+ className: "flex items-center justify-center gap-2 w-full px-3 py-2 text-sm font-medium text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",
730
+ children: [
731
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.LogOut, { className: "w-4 h-4" }),
732
+ "Logout"
733
+ ]
734
+ }
735
+ )
736
+ ] })
737
+ ] }),
738
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("main", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
739
+ section === "pages" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PagesSection, {}),
740
+ section === "collections" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollectionsSection, {}),
741
+ section === "submissions" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubmissionsSection, {}),
742
+ section === "config" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ConfigSection, {}),
743
+ section === "settings" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SettingsSection, {}),
744
+ section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {})
694
745
  ] })
695
- ] }),
696
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("main", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
697
- section === "pages" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PagesSection, {}),
698
- section === "collections" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollectionsSection, {}),
699
- section === "submissions" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubmissionsSection, {}),
700
- section === "config" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ConfigSection, {}),
701
- section === "settings" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SettingsSection, {}),
702
- section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {})
703
746
  ] })
704
747
  ] });
705
748
  }