admin-lib-cms 1.1.6 → 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/README.md +46 -4
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +358 -317
- package/dist/index.mjs +502 -461
- package/package.json +1 -1
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
|
|
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,
|
|
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,
|
|
253
|
+
return (0, import_react3.useContext)(CmsContext);
|
|
54
254
|
}
|
|
55
|
-
function CmsProvider(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
373
|
+
const setOverride = (0, import_react3.useCallback)((id, value2) => {
|
|
149
374
|
setOverrides((prev) => ({ ...prev, [id]: value2 }));
|
|
150
375
|
}, []);
|
|
151
|
-
const save = (0,
|
|
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,
|
|
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,
|
|
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,
|
|
398
|
+
const getRegistered = (0, import_react3.useCallback)(
|
|
174
399
|
() => Array.from(registryRef.current.values()),
|
|
175
400
|
[]
|
|
176
401
|
);
|
|
177
|
-
const value = (0,
|
|
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,
|
|
421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CmsContext.Provider, { value, children });
|
|
197
422
|
}
|
|
198
423
|
function useSubmit(formId) {
|
|
199
|
-
const ctx = (0,
|
|
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
|
|
227
|
-
var
|
|
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,
|
|
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,
|
|
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,
|
|
519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
295
520
|
"img",
|
|
296
521
|
{
|
|
297
522
|
src: value,
|
|
@@ -331,7 +556,7 @@ function EditableLink({
|
|
|
331
556
|
const isExternal = hrefValue.startsWith("http");
|
|
332
557
|
const computedTarget = target || (isExternal ? "_blank" : void 0);
|
|
333
558
|
const computedRel = computedTarget === "_blank" ? "noopener noreferrer" : void 0;
|
|
334
|
-
return /* @__PURE__ */ (0,
|
|
559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
335
560
|
"a",
|
|
336
561
|
{
|
|
337
562
|
href: hrefValue,
|
|
@@ -368,13 +593,13 @@ function EditableList({
|
|
|
368
593
|
e.stopPropagation();
|
|
369
594
|
ctx.setSelectedId(id);
|
|
370
595
|
};
|
|
371
|
-
return /* @__PURE__ */ (0,
|
|
596
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
372
597
|
"div",
|
|
373
598
|
{
|
|
374
599
|
"data-cms-id": id,
|
|
375
600
|
onClick: active ? onClick : void 0,
|
|
376
601
|
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
377
|
-
children: renderList ? renderList(value) : /* @__PURE__ */ (0,
|
|
602
|
+
children: renderList ? renderList(value) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: listClassName, children: renderItem && value.map(renderItem) })
|
|
378
603
|
}
|
|
379
604
|
);
|
|
380
605
|
}
|
|
@@ -383,195 +608,6 @@ function EditableList({
|
|
|
383
608
|
var import_react5 = require("react");
|
|
384
609
|
var import_lucide_react2 = require("lucide-react");
|
|
385
610
|
var import_lucide_react3 = require("lucide-react");
|
|
386
|
-
|
|
387
|
-
// src/subscription/SubscriptionProvider.tsx
|
|
388
|
-
var import_react3 = require("react");
|
|
389
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
390
|
-
var SubscriptionContext = (0, import_react3.createContext)(void 0);
|
|
391
|
-
function useSubscriptionContext() {
|
|
392
|
-
const ctx = (0, import_react3.useContext)(SubscriptionContext);
|
|
393
|
-
if (!ctx) {
|
|
394
|
-
throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
|
|
395
|
-
}
|
|
396
|
-
return ctx;
|
|
397
|
-
}
|
|
398
|
-
function useSubscription() {
|
|
399
|
-
return useSubscriptionContext();
|
|
400
|
-
}
|
|
401
|
-
function SubscriptionProvider({
|
|
402
|
-
children,
|
|
403
|
-
apiUrl,
|
|
404
|
-
projectId,
|
|
405
|
-
email
|
|
406
|
-
}) {
|
|
407
|
-
const [subscription, setSubscription] = (0, import_react3.useState)(null);
|
|
408
|
-
const [loading, setLoading] = (0, import_react3.useState)(true);
|
|
409
|
-
const [error, setError] = (0, import_react3.useState)(null);
|
|
410
|
-
const fetchSubscription = (0, import_react3.useCallback)(
|
|
411
|
-
async (silent = false) => {
|
|
412
|
-
if (!apiUrl || !projectId) {
|
|
413
|
-
setLoading(false);
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
if (!silent) setLoading(true);
|
|
417
|
-
setError(null);
|
|
418
|
-
try {
|
|
419
|
-
const res = await fetch(`${apiUrl}/api/validate-subscription`, {
|
|
420
|
-
method: "POST",
|
|
421
|
-
headers: { "Content-Type": "application/json" },
|
|
422
|
-
body: JSON.stringify({ projectId })
|
|
423
|
-
});
|
|
424
|
-
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
425
|
-
const data = await res.json();
|
|
426
|
-
setSubscription({
|
|
427
|
-
subscriptionStatus: data.valid ? data.status : "inactive",
|
|
428
|
-
currentPeriodEnd: data.expiryDate,
|
|
429
|
-
customerEmail: email,
|
|
430
|
-
subscriptionId: data._id,
|
|
431
|
-
stripeCustomerId: data.stripeCustomerId,
|
|
432
|
-
stripePaymentLink: data.stripePaymentLink,
|
|
433
|
-
valid: data.valid
|
|
434
|
-
});
|
|
435
|
-
} catch (err) {
|
|
436
|
-
console.error("SubscriptionProvider Error:", err);
|
|
437
|
-
setError(err.message || "Failed to fetch subscription");
|
|
438
|
-
setSubscription({ subscriptionStatus: "active", valid: true });
|
|
439
|
-
} finally {
|
|
440
|
-
setLoading(false);
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
[apiUrl, projectId, email]
|
|
444
|
-
);
|
|
445
|
-
(0, import_react3.useEffect)(() => {
|
|
446
|
-
fetchSubscription();
|
|
447
|
-
const handleFocus = () => {
|
|
448
|
-
fetchSubscription(true);
|
|
449
|
-
};
|
|
450
|
-
window.addEventListener("focus", handleFocus);
|
|
451
|
-
let intervalId;
|
|
452
|
-
if (subscription && !subscription.valid) {
|
|
453
|
-
intervalId = setInterval(() => {
|
|
454
|
-
fetchSubscription(true);
|
|
455
|
-
}, 1e4);
|
|
456
|
-
}
|
|
457
|
-
return () => {
|
|
458
|
-
window.removeEventListener("focus", handleFocus);
|
|
459
|
-
if (intervalId) clearInterval(intervalId);
|
|
460
|
-
};
|
|
461
|
-
}, [fetchSubscription, subscription?.valid]);
|
|
462
|
-
const value = {
|
|
463
|
-
subscription,
|
|
464
|
-
loading,
|
|
465
|
-
error,
|
|
466
|
-
refetch: fetchSubscription,
|
|
467
|
-
isSubscriptionActive: subscription?.valid ?? true,
|
|
468
|
-
config: { apiUrl, projectId }
|
|
469
|
-
};
|
|
470
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SubscriptionContext.Provider, { value, children });
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// src/subscription/SubscriptionPage.tsx
|
|
474
|
-
var import_react4 = require("react");
|
|
475
|
-
var import_lucide_react = require("lucide-react");
|
|
476
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
477
|
-
function SubscriptionPage() {
|
|
478
|
-
const { subscription, loading, config } = useSubscription();
|
|
479
|
-
const [actionLoading, setActionLoading] = (0, import_react4.useState)(null);
|
|
480
|
-
const status = subscription?.subscriptionStatus || "inactive";
|
|
481
|
-
const isValid = subscription?.valid ?? false;
|
|
482
|
-
const handleSubscribe = () => {
|
|
483
|
-
if (!subscription?.stripePaymentLink) {
|
|
484
|
-
alert("No payment link found. Please contact support.");
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
const raw = subscription.stripePaymentLink;
|
|
488
|
-
const url = raw.startsWith("http") ? raw : `https://buy.stripe.com/${raw}`;
|
|
489
|
-
window.open(url, "_blank");
|
|
490
|
-
};
|
|
491
|
-
const handleManageBilling = async () => {
|
|
492
|
-
if (!subscription?.stripeCustomerId) {
|
|
493
|
-
alert("No customer ID available. Please contact support.");
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
setActionLoading("billing");
|
|
497
|
-
try {
|
|
498
|
-
const returnUrl = window.location.href;
|
|
499
|
-
const apiUrl = config.apiUrl || "https://dev-soft-admin-sigma.vercel.app";
|
|
500
|
-
const res = await fetch(`${apiUrl}/api/create-billing-session`, {
|
|
501
|
-
method: "POST",
|
|
502
|
-
headers: { "Content-Type": "application/json" },
|
|
503
|
-
body: JSON.stringify({
|
|
504
|
-
customerId: subscription.stripeCustomerId,
|
|
505
|
-
returnUrl
|
|
506
|
-
})
|
|
507
|
-
});
|
|
508
|
-
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
509
|
-
const data = await res.json();
|
|
510
|
-
if (data.url) {
|
|
511
|
-
window.open(data.url, "_blank");
|
|
512
|
-
} else {
|
|
513
|
-
alert("Could not create billing session.");
|
|
514
|
-
}
|
|
515
|
-
} catch (err) {
|
|
516
|
-
alert(`Portal failed: ${err.message}`);
|
|
517
|
-
} finally {
|
|
518
|
-
setActionLoading(null);
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
if (loading && !subscription) {
|
|
522
|
-
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: [
|
|
523
|
-
/* @__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" }),
|
|
524
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-sm font-medium", children: "Verifying subscription..." })
|
|
525
|
-
] }) });
|
|
526
|
-
}
|
|
527
|
-
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: [
|
|
528
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `p-8 text-center ${isValid ? "bg-emerald-50" : "bg-rose-50"}`, children: [
|
|
529
|
-
/* @__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" }) }),
|
|
530
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: isValid ? "Subscription Active" : "Subscription Inactive" }),
|
|
531
|
-
/* @__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." })
|
|
532
|
-
] }),
|
|
533
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "p-8", children: [
|
|
534
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "space-y-4", children: [
|
|
535
|
-
/* @__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: [
|
|
536
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Status" }),
|
|
537
|
-
/* @__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 })
|
|
538
|
-
] }),
|
|
539
|
-
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: [
|
|
540
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Next Billing Date" }),
|
|
541
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-semibold text-slate-900", children: new Date(subscription.currentPeriodEnd).toLocaleDateString() })
|
|
542
|
-
] })
|
|
543
|
-
] }),
|
|
544
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mt-8 space-y-3", children: [
|
|
545
|
-
!isValid && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
546
|
-
"button",
|
|
547
|
-
{
|
|
548
|
-
onClick: handleSubscribe,
|
|
549
|
-
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",
|
|
550
|
-
children: [
|
|
551
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.CreditCard, { className: "h-4 w-4" }),
|
|
552
|
-
"Pay Now to Restore Access",
|
|
553
|
-
/* @__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" })
|
|
554
|
-
]
|
|
555
|
-
}
|
|
556
|
-
),
|
|
557
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
558
|
-
"button",
|
|
559
|
-
{
|
|
560
|
-
onClick: handleManageBilling,
|
|
561
|
-
disabled: actionLoading === "billing",
|
|
562
|
-
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",
|
|
563
|
-
children: [
|
|
564
|
-
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" }),
|
|
565
|
-
"Manage Billing & Invoices"
|
|
566
|
-
]
|
|
567
|
-
}
|
|
568
|
-
)
|
|
569
|
-
] })
|
|
570
|
-
] })
|
|
571
|
-
] }) });
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// src/admin/AdminApp.tsx
|
|
575
611
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
576
612
|
async function handleImageFile(file, onUrl, uploadImage) {
|
|
577
613
|
if (uploadImage) {
|
|
@@ -602,106 +638,111 @@ function AdminAppContent() {
|
|
|
602
638
|
} catch (e) {
|
|
603
639
|
}
|
|
604
640
|
const isSubscriptionActive = subscriptionCtx?.isSubscriptionActive ?? true;
|
|
641
|
+
const daysOverdue = subscriptionCtx?.daysOverdue ?? 0;
|
|
605
642
|
if (!isSubscriptionActive) {
|
|
606
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, {}) });
|
|
607
644
|
}
|
|
608
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col
|
|
609
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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" })
|
|
618
660
|
] }),
|
|
619
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
)
|
|
676
|
-
] }),
|
|
677
|
-
/* @__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: [
|
|
678
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between text-xs text-slate-500 mb-4", children: [
|
|
679
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Storage Adapter" }),
|
|
680
|
-
/* @__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
|
+
)
|
|
681
716
|
] }),
|
|
682
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
683
|
-
"
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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, {})
|
|
696
745
|
] })
|
|
697
|
-
] }),
|
|
698
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("main", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
|
|
699
|
-
section === "pages" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PagesSection, {}),
|
|
700
|
-
section === "collections" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollectionsSection, {}),
|
|
701
|
-
section === "submissions" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubmissionsSection, {}),
|
|
702
|
-
section === "config" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ConfigSection, {}),
|
|
703
|
-
section === "settings" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SettingsSection, {}),
|
|
704
|
-
section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {})
|
|
705
746
|
] })
|
|
706
747
|
] });
|
|
707
748
|
}
|