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.mjs
CHANGED
|
@@ -7,38 +7,263 @@ import {
|
|
|
7
7
|
|
|
8
8
|
// src/provider.tsx
|
|
9
9
|
import {
|
|
10
|
-
createContext,
|
|
11
|
-
useCallback,
|
|
12
|
-
useContext,
|
|
13
|
-
useEffect,
|
|
10
|
+
createContext as createContext2,
|
|
11
|
+
useCallback as useCallback2,
|
|
12
|
+
useContext as useContext2,
|
|
13
|
+
useEffect as useEffect2,
|
|
14
14
|
useMemo,
|
|
15
15
|
useRef,
|
|
16
|
-
useState
|
|
16
|
+
useState as useState3
|
|
17
17
|
} from "react";
|
|
18
|
+
|
|
19
|
+
// src/subscription/SubscriptionProvider.tsx
|
|
20
|
+
import { createContext, useContext, useState, useCallback, useEffect } from "react";
|
|
18
21
|
import { jsx } from "react/jsx-runtime";
|
|
19
|
-
var
|
|
22
|
+
var SubscriptionContext = createContext(void 0);
|
|
23
|
+
function useSubscriptionContext() {
|
|
24
|
+
const ctx = useContext(SubscriptionContext);
|
|
25
|
+
if (!ctx) {
|
|
26
|
+
throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
|
|
27
|
+
}
|
|
28
|
+
return ctx;
|
|
29
|
+
}
|
|
30
|
+
function useSubscription() {
|
|
31
|
+
return useSubscriptionContext();
|
|
32
|
+
}
|
|
33
|
+
function SubscriptionProvider({
|
|
34
|
+
children,
|
|
35
|
+
apiUrl,
|
|
36
|
+
projectId,
|
|
37
|
+
email,
|
|
38
|
+
validateSubscriptionUrl
|
|
39
|
+
}) {
|
|
40
|
+
const [subscription, setSubscription] = useState(null);
|
|
41
|
+
const [loading, setLoading] = useState(true);
|
|
42
|
+
const [error, setError] = useState(null);
|
|
43
|
+
const fetchSubscription = useCallback(
|
|
44
|
+
async (silent = false) => {
|
|
45
|
+
if (!apiUrl || !projectId) {
|
|
46
|
+
setLoading(false);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (!silent) setLoading(true);
|
|
50
|
+
setError(null);
|
|
51
|
+
try {
|
|
52
|
+
const endpoint = validateSubscriptionUrl || `${apiUrl}/api/validate-subscription`;
|
|
53
|
+
const res = await fetch(endpoint, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: { "Content-Type": "application/json" },
|
|
56
|
+
body: JSON.stringify({ projectId })
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
59
|
+
const data = await res.json();
|
|
60
|
+
setSubscription({
|
|
61
|
+
subscriptionStatus: data.valid ? data.status : "inactive",
|
|
62
|
+
currentPeriodEnd: data.expiryDate,
|
|
63
|
+
customerEmail: email,
|
|
64
|
+
subscriptionId: data._id,
|
|
65
|
+
stripeCustomerId: data.stripeCustomerId,
|
|
66
|
+
stripePaymentLink: data.stripePaymentLink,
|
|
67
|
+
valid: data.valid
|
|
68
|
+
});
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.error("SubscriptionProvider Error:", err);
|
|
71
|
+
setError(err.message || "Failed to fetch subscription");
|
|
72
|
+
setSubscription({ subscriptionStatus: "active", valid: true });
|
|
73
|
+
} finally {
|
|
74
|
+
setLoading(false);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
[apiUrl, projectId, email]
|
|
78
|
+
);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
fetchSubscription();
|
|
81
|
+
const handleFocus = () => {
|
|
82
|
+
fetchSubscription(true);
|
|
83
|
+
};
|
|
84
|
+
window.addEventListener("focus", handleFocus);
|
|
85
|
+
let intervalId;
|
|
86
|
+
if (subscription && !subscription.valid) {
|
|
87
|
+
intervalId = setInterval(() => {
|
|
88
|
+
fetchSubscription(true);
|
|
89
|
+
}, 1e4);
|
|
90
|
+
}
|
|
91
|
+
return () => {
|
|
92
|
+
window.removeEventListener("focus", handleFocus);
|
|
93
|
+
if (intervalId) clearInterval(intervalId);
|
|
94
|
+
};
|
|
95
|
+
}, [fetchSubscription, subscription?.valid]);
|
|
96
|
+
let daysOverdue = 0;
|
|
97
|
+
if (subscription && !subscription.valid && subscription.currentPeriodEnd) {
|
|
98
|
+
const diffTime = Date.now() - new Date(subscription.currentPeriodEnd).getTime();
|
|
99
|
+
if (diffTime > 0) {
|
|
100
|
+
daysOverdue = Math.floor(diffTime / (1e3 * 60 * 60 * 24));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const isSubscriptionActive = subscription ? subscription.valid || daysOverdue < 30 : true;
|
|
104
|
+
const value = {
|
|
105
|
+
subscription,
|
|
106
|
+
loading,
|
|
107
|
+
error,
|
|
108
|
+
refetch: fetchSubscription,
|
|
109
|
+
isSubscriptionActive,
|
|
110
|
+
daysOverdue,
|
|
111
|
+
config: { apiUrl, projectId }
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */ jsx(SubscriptionContext.Provider, { value, children });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/subscription/SubscriptionPage.tsx
|
|
117
|
+
import { useState as useState2 } from "react";
|
|
118
|
+
import { CreditCard, ExternalLink, Settings, AlertTriangle, CheckCircle2 } from "lucide-react";
|
|
119
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
120
|
+
function SubscriptionPage() {
|
|
121
|
+
const { subscription, loading, config } = useSubscription();
|
|
122
|
+
const [actionLoading, setActionLoading] = useState2(null);
|
|
123
|
+
const status = subscription?.subscriptionStatus || "inactive";
|
|
124
|
+
const isValid = subscription?.valid ?? false;
|
|
125
|
+
const handleSubscribe = () => {
|
|
126
|
+
if (!subscription?.stripePaymentLink) {
|
|
127
|
+
alert("No payment link found. Please contact support.");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const raw = subscription.stripePaymentLink;
|
|
131
|
+
const url = raw.startsWith("http") ? raw : `https://buy.stripe.com/${raw}`;
|
|
132
|
+
window.open(url, "_blank");
|
|
133
|
+
};
|
|
134
|
+
const handleManageBilling = async () => {
|
|
135
|
+
if (!subscription?.stripeCustomerId) {
|
|
136
|
+
alert("No customer ID available. Please contact support.");
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
setActionLoading("billing");
|
|
140
|
+
try {
|
|
141
|
+
const returnUrl = window.location.href;
|
|
142
|
+
const apiUrl = config.apiUrl || "https://dev-soft-admin-sigma.vercel.app";
|
|
143
|
+
const res = await fetch(`${apiUrl}/api/create-billing-session`, {
|
|
144
|
+
method: "POST",
|
|
145
|
+
headers: { "Content-Type": "application/json" },
|
|
146
|
+
body: JSON.stringify({
|
|
147
|
+
customerId: subscription.stripeCustomerId,
|
|
148
|
+
returnUrl
|
|
149
|
+
})
|
|
150
|
+
});
|
|
151
|
+
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
152
|
+
const data = await res.json();
|
|
153
|
+
if (data.url) {
|
|
154
|
+
window.open(data.url, "_blank");
|
|
155
|
+
} else {
|
|
156
|
+
alert("Could not create billing session.");
|
|
157
|
+
}
|
|
158
|
+
} catch (err) {
|
|
159
|
+
alert(`Portal failed: ${err.message}`);
|
|
160
|
+
} finally {
|
|
161
|
+
setActionLoading(null);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
if (loading && !subscription) {
|
|
165
|
+
return /* @__PURE__ */ jsx2("div", { className: "flex h-full min-h-[500px] w-full items-center justify-center bg-slate-50", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 text-slate-500", children: [
|
|
166
|
+
/* @__PURE__ */ jsx2("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-indigo-200 border-t-indigo-600" }),
|
|
167
|
+
/* @__PURE__ */ jsx2("p", { className: "text-sm font-medium", children: "Verifying subscription..." })
|
|
168
|
+
] }) });
|
|
169
|
+
}
|
|
170
|
+
return /* @__PURE__ */ jsx2("div", { className: "flex min-h-screen w-full flex-col items-center justify-center bg-slate-50 p-6", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-md overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-xl", children: [
|
|
171
|
+
/* @__PURE__ */ jsxs("div", { className: `p-8 text-center ${isValid ? "bg-emerald-50" : "bg-rose-50"}`, children: [
|
|
172
|
+
/* @__PURE__ */ jsx2("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white shadow-sm", children: isValid ? /* @__PURE__ */ jsx2(CheckCircle2, { className: "h-8 w-8 text-emerald-500" }) : /* @__PURE__ */ jsx2(AlertTriangle, { className: "h-8 w-8 text-rose-500" }) }),
|
|
173
|
+
/* @__PURE__ */ jsx2("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: isValid ? "Subscription Active" : "Subscription Inactive" }),
|
|
174
|
+
/* @__PURE__ */ jsx2("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." })
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ jsxs("div", { className: "p-8", children: [
|
|
177
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
178
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
179
|
+
/* @__PURE__ */ jsx2("span", { className: "text-sm font-medium text-slate-500", children: "Status" }),
|
|
180
|
+
/* @__PURE__ */ jsx2("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 })
|
|
181
|
+
] }),
|
|
182
|
+
subscription?.currentPeriodEnd && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
183
|
+
/* @__PURE__ */ jsx2("span", { className: "text-sm font-medium text-slate-500", children: "Next Billing Date" }),
|
|
184
|
+
/* @__PURE__ */ jsx2("span", { className: "text-sm font-semibold text-slate-900", children: new Date(subscription.currentPeriodEnd).toLocaleDateString() })
|
|
185
|
+
] })
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-8 space-y-3", children: [
|
|
188
|
+
!isValid && /* @__PURE__ */ jsxs(
|
|
189
|
+
"button",
|
|
190
|
+
{
|
|
191
|
+
onClick: handleSubscribe,
|
|
192
|
+
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",
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ jsx2(CreditCard, { className: "h-4 w-4" }),
|
|
195
|
+
"Pay Now to Restore Access",
|
|
196
|
+
/* @__PURE__ */ jsx2(ExternalLink, { className: "h-3.5 w-3.5 opacity-70 transition-transform group-hover:translate-x-0.5" })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ jsxs(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
onClick: handleManageBilling,
|
|
204
|
+
disabled: actionLoading === "billing",
|
|
205
|
+
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",
|
|
206
|
+
children: [
|
|
207
|
+
actionLoading === "billing" ? /* @__PURE__ */ jsx2("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-slate-300 border-t-slate-600" }) : /* @__PURE__ */ jsx2(Settings, { className: "h-4 w-4 text-slate-400 group-hover:text-slate-600" }),
|
|
208
|
+
"Manage Billing & Invoices"
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
] })
|
|
213
|
+
] })
|
|
214
|
+
] }) });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/provider.tsx
|
|
218
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
219
|
+
var CmsContext = createContext2(null);
|
|
20
220
|
function useCmsContext() {
|
|
21
|
-
const ctx =
|
|
221
|
+
const ctx = useContext2(CmsContext);
|
|
22
222
|
if (!ctx) throw new Error("useCms must be used inside <CmsProvider>");
|
|
23
223
|
return ctx;
|
|
24
224
|
}
|
|
25
225
|
function useCmsOptional() {
|
|
26
|
-
return
|
|
226
|
+
return useContext2(CmsContext);
|
|
227
|
+
}
|
|
228
|
+
function CmsProvider(props) {
|
|
229
|
+
if (props.projectId) {
|
|
230
|
+
return /* @__PURE__ */ jsx3(
|
|
231
|
+
SubscriptionProvider,
|
|
232
|
+
{
|
|
233
|
+
apiUrl: props.apiUrl,
|
|
234
|
+
projectId: props.projectId,
|
|
235
|
+
email: props.email,
|
|
236
|
+
validateSubscriptionUrl: props.validateSubscriptionUrl,
|
|
237
|
+
children: /* @__PURE__ */ jsx3(CmsProviderInner, { ...props, children: /* @__PURE__ */ jsx3(SiteGuard, { children: props.children }) })
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
return /* @__PURE__ */ jsx3(CmsProviderInner, { ...props, children: props.children });
|
|
242
|
+
}
|
|
243
|
+
function SiteGuard({ children }) {
|
|
244
|
+
const { daysOverdue, isSubscriptionActive } = useSubscription();
|
|
245
|
+
if (!isSubscriptionActive && daysOverdue >= 60) {
|
|
246
|
+
return /* @__PURE__ */ jsx3("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__ */ jsxs2("div", { style: { textAlign: "center", padding: "2rem", maxWidth: "32rem" }, children: [
|
|
247
|
+
/* @__PURE__ */ jsx3("h1", { style: { fontSize: "1.5rem", fontWeight: 600, marginBottom: "0.5rem" }, children: "This website is temporarily unavailable" }),
|
|
248
|
+
/* @__PURE__ */ jsx3("p", { style: { color: "#64748b" }, children: "Please contact the site administrator if you believe this is an error." })
|
|
249
|
+
] }) });
|
|
250
|
+
}
|
|
251
|
+
return /* @__PURE__ */ jsx3(Fragment, { children });
|
|
27
252
|
}
|
|
28
|
-
function
|
|
29
|
-
const [overrides, setOverrides] =
|
|
30
|
-
const [savedOverrides, setSavedOverrides] =
|
|
31
|
-
const [selectedId, setSelectedIdRaw] =
|
|
32
|
-
const [editMode, setEditMode] =
|
|
33
|
-
const [collectionChangedAt, setCollectionChangedAt] =
|
|
253
|
+
function CmsProviderInner({ config, adapter, children, iconMap, initialOverrides }) {
|
|
254
|
+
const [overrides, setOverrides] = useState3(initialOverrides || {});
|
|
255
|
+
const [savedOverrides, setSavedOverrides] = useState3(initialOverrides || {});
|
|
256
|
+
const [selectedId, setSelectedIdRaw] = useState3(null);
|
|
257
|
+
const [editMode, setEditMode] = useState3(false);
|
|
258
|
+
const [collectionChangedAt, setCollectionChangedAt] = useState3(0);
|
|
34
259
|
const registryRef = useRef(/* @__PURE__ */ new Map());
|
|
35
|
-
|
|
260
|
+
useEffect2(() => {
|
|
36
261
|
if (typeof window === "undefined" || typeof BroadcastChannel === "undefined") return;
|
|
37
262
|
const bc = new BroadcastChannel("admin-cms:collection-changed");
|
|
38
263
|
bc.onmessage = () => setCollectionChangedAt(Date.now());
|
|
39
264
|
return () => bc.close();
|
|
40
265
|
}, []);
|
|
41
|
-
const notifyCollectionChanged =
|
|
266
|
+
const notifyCollectionChanged = useCallback2(() => {
|
|
42
267
|
setCollectionChangedAt(Date.now());
|
|
43
268
|
if (typeof BroadcastChannel !== "undefined") {
|
|
44
269
|
const bc = new BroadcastChannel("admin-cms:collection-changed");
|
|
@@ -46,12 +271,12 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
46
271
|
bc.close();
|
|
47
272
|
}
|
|
48
273
|
}, []);
|
|
49
|
-
|
|
274
|
+
useEffect2(() => {
|
|
50
275
|
if (typeof window === "undefined") return;
|
|
51
276
|
const params = new URLSearchParams(window.location.search);
|
|
52
277
|
if (params.get("__cms") === "edit") setEditMode(true);
|
|
53
278
|
}, []);
|
|
54
|
-
|
|
279
|
+
useEffect2(() => {
|
|
55
280
|
let cancelled = false;
|
|
56
281
|
adapter.getOverrides().then((o) => {
|
|
57
282
|
if (cancelled) return;
|
|
@@ -62,7 +287,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
62
287
|
cancelled = true;
|
|
63
288
|
};
|
|
64
289
|
}, [adapter]);
|
|
65
|
-
|
|
290
|
+
useEffect2(() => {
|
|
66
291
|
if (!editMode || typeof window === "undefined") return;
|
|
67
292
|
const parent = window.parent;
|
|
68
293
|
if (!parent || parent === window) return;
|
|
@@ -80,7 +305,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
80
305
|
window.addEventListener("message", onMsg);
|
|
81
306
|
return () => window.removeEventListener("message", onMsg);
|
|
82
307
|
}, [editMode]);
|
|
83
|
-
const setSelectedId =
|
|
308
|
+
const setSelectedId = useCallback2(
|
|
84
309
|
(id) => {
|
|
85
310
|
setSelectedIdRaw(id);
|
|
86
311
|
if (editMode && typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
@@ -92,7 +317,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
92
317
|
},
|
|
93
318
|
[editMode]
|
|
94
319
|
);
|
|
95
|
-
const registerEditable =
|
|
320
|
+
const registerEditable = useCallback2((meta) => {
|
|
96
321
|
registryRef.current.set(meta.id, meta);
|
|
97
322
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
98
323
|
window.parent.postMessage(
|
|
@@ -105,7 +330,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
105
330
|
);
|
|
106
331
|
}
|
|
107
332
|
}, []);
|
|
108
|
-
const unregisterEditable =
|
|
333
|
+
const unregisterEditable = useCallback2((id) => {
|
|
109
334
|
registryRef.current.delete(id);
|
|
110
335
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
111
336
|
window.parent.postMessage(
|
|
@@ -118,14 +343,14 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
118
343
|
);
|
|
119
344
|
}
|
|
120
345
|
}, []);
|
|
121
|
-
const setOverride =
|
|
346
|
+
const setOverride = useCallback2((id, value2) => {
|
|
122
347
|
setOverrides((prev) => ({ ...prev, [id]: value2 }));
|
|
123
348
|
}, []);
|
|
124
|
-
const save =
|
|
349
|
+
const save = useCallback2(async () => {
|
|
125
350
|
await adapter.setOverrides(overrides);
|
|
126
351
|
setSavedOverrides(overrides);
|
|
127
352
|
}, [adapter, overrides]);
|
|
128
|
-
const reset =
|
|
353
|
+
const reset = useCallback2(
|
|
129
354
|
async (id) => {
|
|
130
355
|
if (id) {
|
|
131
356
|
setOverrides((prev) => {
|
|
@@ -143,7 +368,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
143
368
|
() => JSON.stringify(overrides) !== JSON.stringify(savedOverrides),
|
|
144
369
|
[overrides, savedOverrides]
|
|
145
370
|
);
|
|
146
|
-
const getRegistered =
|
|
371
|
+
const getRegistered = useCallback2(
|
|
147
372
|
() => Array.from(registryRef.current.values()),
|
|
148
373
|
[]
|
|
149
374
|
);
|
|
@@ -166,10 +391,10 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
166
391
|
collectionChangedAt,
|
|
167
392
|
notifyCollectionChanged
|
|
168
393
|
}), [config, adapter, overrides, editMode, selectedId, setSelectedId, setOverride, registerEditable, unregisterEditable, getRegistered, save, reset, isDirty, iconMap, collectionChangedAt, notifyCollectionChanged]);
|
|
169
|
-
return /* @__PURE__ */
|
|
394
|
+
return /* @__PURE__ */ jsx3(CmsContext.Provider, { value, children });
|
|
170
395
|
}
|
|
171
396
|
function useSubmit(formId) {
|
|
172
|
-
const ctx =
|
|
397
|
+
const ctx = useContext2(CmsContext);
|
|
173
398
|
return async (data) => {
|
|
174
399
|
const submission = {
|
|
175
400
|
id: crypto.randomUUID(),
|
|
@@ -196,11 +421,11 @@ function useSubmit(formId) {
|
|
|
196
421
|
}
|
|
197
422
|
|
|
198
423
|
// src/editable.tsx
|
|
199
|
-
import { createElement, useEffect as
|
|
200
|
-
import { jsx as
|
|
424
|
+
import { createElement, useEffect as useEffect3 } from "react";
|
|
425
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
201
426
|
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength) {
|
|
202
427
|
const ctx = useCmsOptional();
|
|
203
|
-
|
|
428
|
+
useEffect3(() => {
|
|
204
429
|
if (!ctx) return;
|
|
205
430
|
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength });
|
|
206
431
|
return () => ctx.unregisterEditable(id);
|
|
@@ -264,7 +489,7 @@ function EditableImage({
|
|
|
264
489
|
e.stopPropagation();
|
|
265
490
|
ctx.setSelectedId(id);
|
|
266
491
|
};
|
|
267
|
-
return /* @__PURE__ */
|
|
492
|
+
return /* @__PURE__ */ jsx4(
|
|
268
493
|
"img",
|
|
269
494
|
{
|
|
270
495
|
src: value,
|
|
@@ -304,7 +529,7 @@ function EditableLink({
|
|
|
304
529
|
const isExternal = hrefValue.startsWith("http");
|
|
305
530
|
const computedTarget = target || (isExternal ? "_blank" : void 0);
|
|
306
531
|
const computedRel = computedTarget === "_blank" ? "noopener noreferrer" : void 0;
|
|
307
|
-
return /* @__PURE__ */
|
|
532
|
+
return /* @__PURE__ */ jsx4(
|
|
308
533
|
"a",
|
|
309
534
|
{
|
|
310
535
|
href: hrefValue,
|
|
@@ -341,13 +566,13 @@ function EditableList({
|
|
|
341
566
|
e.stopPropagation();
|
|
342
567
|
ctx.setSelectedId(id);
|
|
343
568
|
};
|
|
344
|
-
return /* @__PURE__ */
|
|
569
|
+
return /* @__PURE__ */ jsx4(
|
|
345
570
|
"div",
|
|
346
571
|
{
|
|
347
572
|
"data-cms-id": id,
|
|
348
573
|
onClick: active ? onClick : void 0,
|
|
349
574
|
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
350
|
-
children: renderList ? renderList(value) : /* @__PURE__ */
|
|
575
|
+
children: renderList ? renderList(value) : /* @__PURE__ */ jsx4("div", { className: listClassName, children: renderItem && value.map(renderItem) })
|
|
351
576
|
}
|
|
352
577
|
);
|
|
353
578
|
}
|
|
@@ -382,196 +607,7 @@ import {
|
|
|
382
607
|
LogOut
|
|
383
608
|
} from "lucide-react";
|
|
384
609
|
import { CreditCard as CreditCard2 } from "lucide-react";
|
|
385
|
-
|
|
386
|
-
// src/subscription/SubscriptionProvider.tsx
|
|
387
|
-
import { createContext as createContext2, useContext as useContext2, useState as useState2, useCallback as useCallback2, useEffect as useEffect3 } from "react";
|
|
388
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
389
|
-
var SubscriptionContext = createContext2(void 0);
|
|
390
|
-
function useSubscriptionContext() {
|
|
391
|
-
const ctx = useContext2(SubscriptionContext);
|
|
392
|
-
if (!ctx) {
|
|
393
|
-
throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
|
|
394
|
-
}
|
|
395
|
-
return ctx;
|
|
396
|
-
}
|
|
397
|
-
function useSubscription() {
|
|
398
|
-
return useSubscriptionContext();
|
|
399
|
-
}
|
|
400
|
-
function SubscriptionProvider({
|
|
401
|
-
children,
|
|
402
|
-
apiUrl,
|
|
403
|
-
projectId,
|
|
404
|
-
email
|
|
405
|
-
}) {
|
|
406
|
-
const [subscription, setSubscription] = useState2(null);
|
|
407
|
-
const [loading, setLoading] = useState2(true);
|
|
408
|
-
const [error, setError] = useState2(null);
|
|
409
|
-
const fetchSubscription = useCallback2(
|
|
410
|
-
async (silent = false) => {
|
|
411
|
-
if (!apiUrl || !projectId) {
|
|
412
|
-
setLoading(false);
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
if (!silent) setLoading(true);
|
|
416
|
-
setError(null);
|
|
417
|
-
try {
|
|
418
|
-
const res = await fetch(`${apiUrl}/api/validate-subscription`, {
|
|
419
|
-
method: "POST",
|
|
420
|
-
headers: { "Content-Type": "application/json" },
|
|
421
|
-
body: JSON.stringify({ projectId })
|
|
422
|
-
});
|
|
423
|
-
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
424
|
-
const data = await res.json();
|
|
425
|
-
setSubscription({
|
|
426
|
-
subscriptionStatus: data.valid ? data.status : "inactive",
|
|
427
|
-
currentPeriodEnd: data.expiryDate,
|
|
428
|
-
customerEmail: email,
|
|
429
|
-
subscriptionId: data._id,
|
|
430
|
-
stripeCustomerId: data.stripeCustomerId,
|
|
431
|
-
stripePaymentLink: data.stripePaymentLink,
|
|
432
|
-
valid: data.valid
|
|
433
|
-
});
|
|
434
|
-
} catch (err) {
|
|
435
|
-
console.error("SubscriptionProvider Error:", err);
|
|
436
|
-
setError(err.message || "Failed to fetch subscription");
|
|
437
|
-
setSubscription({ subscriptionStatus: "active", valid: true });
|
|
438
|
-
} finally {
|
|
439
|
-
setLoading(false);
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
[apiUrl, projectId, email]
|
|
443
|
-
);
|
|
444
|
-
useEffect3(() => {
|
|
445
|
-
fetchSubscription();
|
|
446
|
-
const handleFocus = () => {
|
|
447
|
-
fetchSubscription(true);
|
|
448
|
-
};
|
|
449
|
-
window.addEventListener("focus", handleFocus);
|
|
450
|
-
let intervalId;
|
|
451
|
-
if (subscription && !subscription.valid) {
|
|
452
|
-
intervalId = setInterval(() => {
|
|
453
|
-
fetchSubscription(true);
|
|
454
|
-
}, 1e4);
|
|
455
|
-
}
|
|
456
|
-
return () => {
|
|
457
|
-
window.removeEventListener("focus", handleFocus);
|
|
458
|
-
if (intervalId) clearInterval(intervalId);
|
|
459
|
-
};
|
|
460
|
-
}, [fetchSubscription, subscription?.valid]);
|
|
461
|
-
const value = {
|
|
462
|
-
subscription,
|
|
463
|
-
loading,
|
|
464
|
-
error,
|
|
465
|
-
refetch: fetchSubscription,
|
|
466
|
-
isSubscriptionActive: subscription?.valid ?? true,
|
|
467
|
-
config: { apiUrl, projectId }
|
|
468
|
-
};
|
|
469
|
-
return /* @__PURE__ */ jsx3(SubscriptionContext.Provider, { value, children });
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// src/subscription/SubscriptionPage.tsx
|
|
473
|
-
import { useState as useState3 } from "react";
|
|
474
|
-
import { CreditCard, ExternalLink, Settings, AlertTriangle, CheckCircle2 } from "lucide-react";
|
|
475
|
-
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
476
|
-
function SubscriptionPage() {
|
|
477
|
-
const { subscription, loading, config } = useSubscription();
|
|
478
|
-
const [actionLoading, setActionLoading] = useState3(null);
|
|
479
|
-
const status = subscription?.subscriptionStatus || "inactive";
|
|
480
|
-
const isValid = subscription?.valid ?? false;
|
|
481
|
-
const handleSubscribe = () => {
|
|
482
|
-
if (!subscription?.stripePaymentLink) {
|
|
483
|
-
alert("No payment link found. Please contact support.");
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
const raw = subscription.stripePaymentLink;
|
|
487
|
-
const url = raw.startsWith("http") ? raw : `https://buy.stripe.com/${raw}`;
|
|
488
|
-
window.open(url, "_blank");
|
|
489
|
-
};
|
|
490
|
-
const handleManageBilling = async () => {
|
|
491
|
-
if (!subscription?.stripeCustomerId) {
|
|
492
|
-
alert("No customer ID available. Please contact support.");
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
setActionLoading("billing");
|
|
496
|
-
try {
|
|
497
|
-
const returnUrl = window.location.href;
|
|
498
|
-
const apiUrl = config.apiUrl || "https://dev-soft-admin-sigma.vercel.app";
|
|
499
|
-
const res = await fetch(`${apiUrl}/api/create-billing-session`, {
|
|
500
|
-
method: "POST",
|
|
501
|
-
headers: { "Content-Type": "application/json" },
|
|
502
|
-
body: JSON.stringify({
|
|
503
|
-
customerId: subscription.stripeCustomerId,
|
|
504
|
-
returnUrl
|
|
505
|
-
})
|
|
506
|
-
});
|
|
507
|
-
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
508
|
-
const data = await res.json();
|
|
509
|
-
if (data.url) {
|
|
510
|
-
window.open(data.url, "_blank");
|
|
511
|
-
} else {
|
|
512
|
-
alert("Could not create billing session.");
|
|
513
|
-
}
|
|
514
|
-
} catch (err) {
|
|
515
|
-
alert(`Portal failed: ${err.message}`);
|
|
516
|
-
} finally {
|
|
517
|
-
setActionLoading(null);
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
if (loading && !subscription) {
|
|
521
|
-
return /* @__PURE__ */ jsx4("div", { className: "flex h-full min-h-[500px] w-full items-center justify-center bg-slate-50", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 text-slate-500", children: [
|
|
522
|
-
/* @__PURE__ */ jsx4("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-indigo-200 border-t-indigo-600" }),
|
|
523
|
-
/* @__PURE__ */ jsx4("p", { className: "text-sm font-medium", children: "Verifying subscription..." })
|
|
524
|
-
] }) });
|
|
525
|
-
}
|
|
526
|
-
return /* @__PURE__ */ jsx4("div", { className: "flex min-h-screen w-full flex-col items-center justify-center bg-slate-50 p-6", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-md overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-xl", children: [
|
|
527
|
-
/* @__PURE__ */ jsxs("div", { className: `p-8 text-center ${isValid ? "bg-emerald-50" : "bg-rose-50"}`, children: [
|
|
528
|
-
/* @__PURE__ */ jsx4("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white shadow-sm", children: isValid ? /* @__PURE__ */ jsx4(CheckCircle2, { className: "h-8 w-8 text-emerald-500" }) : /* @__PURE__ */ jsx4(AlertTriangle, { className: "h-8 w-8 text-rose-500" }) }),
|
|
529
|
-
/* @__PURE__ */ jsx4("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: isValid ? "Subscription Active" : "Subscription Inactive" }),
|
|
530
|
-
/* @__PURE__ */ jsx4("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." })
|
|
531
|
-
] }),
|
|
532
|
-
/* @__PURE__ */ jsxs("div", { className: "p-8", children: [
|
|
533
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
534
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
535
|
-
/* @__PURE__ */ jsx4("span", { className: "text-sm font-medium text-slate-500", children: "Status" }),
|
|
536
|
-
/* @__PURE__ */ jsx4("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 })
|
|
537
|
-
] }),
|
|
538
|
-
subscription?.currentPeriodEnd && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
539
|
-
/* @__PURE__ */ jsx4("span", { className: "text-sm font-medium text-slate-500", children: "Next Billing Date" }),
|
|
540
|
-
/* @__PURE__ */ jsx4("span", { className: "text-sm font-semibold text-slate-900", children: new Date(subscription.currentPeriodEnd).toLocaleDateString() })
|
|
541
|
-
] })
|
|
542
|
-
] }),
|
|
543
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-8 space-y-3", children: [
|
|
544
|
-
!isValid && /* @__PURE__ */ jsxs(
|
|
545
|
-
"button",
|
|
546
|
-
{
|
|
547
|
-
onClick: handleSubscribe,
|
|
548
|
-
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",
|
|
549
|
-
children: [
|
|
550
|
-
/* @__PURE__ */ jsx4(CreditCard, { className: "h-4 w-4" }),
|
|
551
|
-
"Pay Now to Restore Access",
|
|
552
|
-
/* @__PURE__ */ jsx4(ExternalLink, { className: "h-3.5 w-3.5 opacity-70 transition-transform group-hover:translate-x-0.5" })
|
|
553
|
-
]
|
|
554
|
-
}
|
|
555
|
-
),
|
|
556
|
-
/* @__PURE__ */ jsxs(
|
|
557
|
-
"button",
|
|
558
|
-
{
|
|
559
|
-
onClick: handleManageBilling,
|
|
560
|
-
disabled: actionLoading === "billing",
|
|
561
|
-
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",
|
|
562
|
-
children: [
|
|
563
|
-
actionLoading === "billing" ? /* @__PURE__ */ jsx4("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-slate-300 border-t-slate-600" }) : /* @__PURE__ */ jsx4(Settings, { className: "h-4 w-4 text-slate-400 group-hover:text-slate-600" }),
|
|
564
|
-
"Manage Billing & Invoices"
|
|
565
|
-
]
|
|
566
|
-
}
|
|
567
|
-
)
|
|
568
|
-
] })
|
|
569
|
-
] })
|
|
570
|
-
] }) });
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// src/admin/AdminApp.tsx
|
|
574
|
-
import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
610
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
575
611
|
async function handleImageFile(file, onUrl, uploadImage) {
|
|
576
612
|
if (uploadImage) {
|
|
577
613
|
try {
|
|
@@ -601,106 +637,111 @@ function AdminAppContent() {
|
|
|
601
637
|
} catch (e) {
|
|
602
638
|
}
|
|
603
639
|
const isSubscriptionActive = subscriptionCtx?.isSubscriptionActive ?? true;
|
|
640
|
+
const daysOverdue = subscriptionCtx?.daysOverdue ?? 0;
|
|
604
641
|
if (!isSubscriptionActive) {
|
|
605
642
|
return /* @__PURE__ */ jsx5("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__ */ jsx5(SubscriptionPage, {}) });
|
|
606
643
|
}
|
|
607
|
-
return /* @__PURE__ */
|
|
608
|
-
/* @__PURE__ */ jsx5("div", { className: "
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
644
|
+
return /* @__PURE__ */ jsxs3("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: [
|
|
645
|
+
daysOverdue > 0 && daysOverdue <= 15 && /* @__PURE__ */ jsx5("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." }),
|
|
646
|
+
daysOverdue > 15 && daysOverdue < 30 && /* @__PURE__ */ jsx5("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." }),
|
|
647
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
|
|
648
|
+
/* @__PURE__ */ jsx5("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__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
649
|
+
ctx.overrides?.["global-logo"] ? /* @__PURE__ */ jsx5("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ jsx5("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
|
|
650
|
+
/* @__PURE__ */ jsx5("div", { className: "font-bold text-slate-900 tracking-tight", children: "Admin CMS" })
|
|
651
|
+
] }) }),
|
|
652
|
+
/* @__PURE__ */ jsxs3("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: [
|
|
653
|
+
/* @__PURE__ */ jsxs3("div", { className: "hidden lg:block border-b border-slate-200 px-6 py-5 bg-white/50", children: [
|
|
654
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 mb-1", children: [
|
|
655
|
+
ctx.overrides?.["global-logo"] ? /* @__PURE__ */ jsx5("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ jsx5("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
|
|
656
|
+
/* @__PURE__ */ jsx5("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: "Admin CMS" })
|
|
657
|
+
] }),
|
|
658
|
+
/* @__PURE__ */ jsx5("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
|
|
617
659
|
] }),
|
|
618
|
-
/* @__PURE__ */
|
|
619
|
-
|
|
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
|
-
/* @__PURE__ */ jsxs2("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: [
|
|
677
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between text-xs text-slate-500 mb-4", children: [
|
|
678
|
-
/* @__PURE__ */ jsx5("span", { children: "Storage Adapter" }),
|
|
679
|
-
/* @__PURE__ */ jsx5("span", { className: "font-semibold px-2 py-0.5 rounded-full bg-slate-200 text-slate-700", children: ctx.adapter.name })
|
|
660
|
+
/* @__PURE__ */ jsxs3("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: [
|
|
661
|
+
/* @__PURE__ */ jsx5(
|
|
662
|
+
SideItem,
|
|
663
|
+
{
|
|
664
|
+
active: section === "pages",
|
|
665
|
+
onClick: () => setSection("pages"),
|
|
666
|
+
icon: /* @__PURE__ */ jsx5(FileText, { className: "h-4 w-4 shrink-0" }),
|
|
667
|
+
children: "Pages"
|
|
668
|
+
}
|
|
669
|
+
),
|
|
670
|
+
/* @__PURE__ */ jsx5(
|
|
671
|
+
SideItem,
|
|
672
|
+
{
|
|
673
|
+
active: section === "collections",
|
|
674
|
+
onClick: () => setSection("collections"),
|
|
675
|
+
icon: /* @__PURE__ */ jsx5(Boxes, { className: "h-4 w-4 shrink-0" }),
|
|
676
|
+
children: "Collections"
|
|
677
|
+
}
|
|
678
|
+
),
|
|
679
|
+
/* @__PURE__ */ jsx5(
|
|
680
|
+
SideItem,
|
|
681
|
+
{
|
|
682
|
+
active: section === "submissions",
|
|
683
|
+
onClick: () => setSection("submissions"),
|
|
684
|
+
icon: /* @__PURE__ */ jsx5(Inbox, { className: "h-4 w-4 shrink-0" }),
|
|
685
|
+
children: "Data"
|
|
686
|
+
}
|
|
687
|
+
),
|
|
688
|
+
/* @__PURE__ */ jsx5(
|
|
689
|
+
SideItem,
|
|
690
|
+
{
|
|
691
|
+
active: section === "config",
|
|
692
|
+
onClick: () => setSection("config"),
|
|
693
|
+
icon: /* @__PURE__ */ jsx5(SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
|
|
694
|
+
children: "Config"
|
|
695
|
+
}
|
|
696
|
+
),
|
|
697
|
+
/* @__PURE__ */ jsx5(
|
|
698
|
+
SideItem,
|
|
699
|
+
{
|
|
700
|
+
active: section === "settings",
|
|
701
|
+
onClick: () => setSection("settings"),
|
|
702
|
+
icon: /* @__PURE__ */ jsx5(SettingsIcon, { className: "h-4 w-4 shrink-0" }),
|
|
703
|
+
children: "Settings"
|
|
704
|
+
}
|
|
705
|
+
),
|
|
706
|
+
subscriptionCtx && /* @__PURE__ */ jsx5(
|
|
707
|
+
SideItem,
|
|
708
|
+
{
|
|
709
|
+
active: section === "subscription",
|
|
710
|
+
onClick: () => setSection("subscription"),
|
|
711
|
+
icon: /* @__PURE__ */ jsx5(CreditCard2, { className: "h-4 w-4 shrink-0" }),
|
|
712
|
+
children: "Subscription"
|
|
713
|
+
}
|
|
714
|
+
)
|
|
680
715
|
] }),
|
|
681
|
-
/* @__PURE__ */
|
|
682
|
-
"
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
716
|
+
/* @__PURE__ */ jsxs3("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: [
|
|
717
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between text-xs text-slate-500 mb-4", children: [
|
|
718
|
+
/* @__PURE__ */ jsx5("span", { children: "Storage Adapter" }),
|
|
719
|
+
/* @__PURE__ */ jsx5("span", { className: "font-semibold px-2 py-0.5 rounded-full bg-slate-200 text-slate-700", children: ctx.adapter.name })
|
|
720
|
+
] }),
|
|
721
|
+
/* @__PURE__ */ jsxs3(
|
|
722
|
+
"button",
|
|
723
|
+
{
|
|
724
|
+
onClick: async () => {
|
|
725
|
+
await fetch("/api/admin/auth?action=logout", { method: "POST" });
|
|
726
|
+
window.location.href = "/admin/login";
|
|
727
|
+
},
|
|
728
|
+
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",
|
|
729
|
+
children: [
|
|
730
|
+
/* @__PURE__ */ jsx5(LogOut, { className: "w-4 h-4" }),
|
|
731
|
+
"Logout"
|
|
732
|
+
]
|
|
733
|
+
}
|
|
734
|
+
)
|
|
735
|
+
] })
|
|
736
|
+
] }),
|
|
737
|
+
/* @__PURE__ */ jsxs3("main", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
|
|
738
|
+
section === "pages" && /* @__PURE__ */ jsx5(PagesSection, {}),
|
|
739
|
+
section === "collections" && /* @__PURE__ */ jsx5(CollectionsSection, {}),
|
|
740
|
+
section === "submissions" && /* @__PURE__ */ jsx5(SubmissionsSection, {}),
|
|
741
|
+
section === "config" && /* @__PURE__ */ jsx5(ConfigSection, {}),
|
|
742
|
+
section === "settings" && /* @__PURE__ */ jsx5(SettingsSection, {}),
|
|
743
|
+
section === "subscription" && /* @__PURE__ */ jsx5(SubscriptionPage, {})
|
|
695
744
|
] })
|
|
696
|
-
] }),
|
|
697
|
-
/* @__PURE__ */ jsxs2("main", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
|
|
698
|
-
section === "pages" && /* @__PURE__ */ jsx5(PagesSection, {}),
|
|
699
|
-
section === "collections" && /* @__PURE__ */ jsx5(CollectionsSection, {}),
|
|
700
|
-
section === "submissions" && /* @__PURE__ */ jsx5(SubmissionsSection, {}),
|
|
701
|
-
section === "config" && /* @__PURE__ */ jsx5(ConfigSection, {}),
|
|
702
|
-
section === "settings" && /* @__PURE__ */ jsx5(SettingsSection, {}),
|
|
703
|
-
section === "subscription" && /* @__PURE__ */ jsx5(SubscriptionPage, {})
|
|
704
745
|
] })
|
|
705
746
|
] });
|
|
706
747
|
}
|
|
@@ -710,7 +751,7 @@ function SideItem({
|
|
|
710
751
|
icon,
|
|
711
752
|
children
|
|
712
753
|
}) {
|
|
713
|
-
return /* @__PURE__ */
|
|
754
|
+
return /* @__PURE__ */ jsxs3(
|
|
714
755
|
"button",
|
|
715
756
|
{
|
|
716
757
|
onClick,
|
|
@@ -728,10 +769,10 @@ function PagesSection() {
|
|
|
728
769
|
ctx.config.pages[0] ?? null
|
|
729
770
|
);
|
|
730
771
|
const [showList, setShowList] = useState4(true);
|
|
731
|
-
return /* @__PURE__ */
|
|
732
|
-
showList && /* @__PURE__ */
|
|
772
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col lg:flex-row h-full", children: [
|
|
773
|
+
showList && /* @__PURE__ */ jsxs3("div", { className: "w-full lg:w-72 shrink-0 border-b lg:border-b-0 lg:border-r border-slate-200 bg-white/50 p-3 lg:p-4 overflow-x-auto lg:overflow-y-auto hide-scrollbar", children: [
|
|
733
774
|
/* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500 hidden lg:block", children: "Pages" }),
|
|
734
|
-
/* @__PURE__ */
|
|
775
|
+
/* @__PURE__ */ jsxs3("ul", { className: "flex flex-row lg:flex-col space-x-2 lg:space-x-0 lg:space-y-1", children: [
|
|
735
776
|
ctx.config.pages.map((p) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 w-32 lg:w-full", children: /* @__PURE__ */ jsx5(
|
|
736
777
|
"button",
|
|
737
778
|
{
|
|
@@ -802,21 +843,21 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
802
843
|
);
|
|
803
844
|
const selectedMeta = registered.find((r) => r.id === selectedId) ?? null;
|
|
804
845
|
const [viewMode, setViewMode] = useState4("desktop");
|
|
805
|
-
return /* @__PURE__ */
|
|
806
|
-
/* @__PURE__ */
|
|
807
|
-
/* @__PURE__ */
|
|
846
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex h-full flex-col", children: [
|
|
847
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 border-b border-slate-200 bg-white/80 backdrop-blur px-4 py-3 shadow-sm z-10 shrink-0", children: [
|
|
848
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 text-sm shrink-0", children: [
|
|
808
849
|
/* @__PURE__ */ jsx5("button", { onClick: onToggleList, className: "text-slate-400 hover:text-slate-700 p-1 hidden lg:block", title: "Toggle Pages Menu", children: showList ? /* @__PURE__ */ jsx5(PanelLeftClose, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx5(PanelLeftOpen, { className: "w-5 h-5" }) }),
|
|
809
850
|
/* @__PURE__ */ jsx5("span", { className: "font-bold text-slate-800 text-sm md:text-base", children: page.name }),
|
|
810
851
|
/* @__PURE__ */ jsx5("span", { className: "text-slate-300 hidden sm:inline", children: "|" }),
|
|
811
852
|
/* @__PURE__ */ jsx5("span", { className: "text-slate-500 font-mono text-[10px] md:text-xs bg-slate-100 px-2 py-1 rounded hidden sm:inline-block", children: page.path })
|
|
812
853
|
] }),
|
|
813
|
-
/* @__PURE__ */
|
|
814
|
-
/* @__PURE__ */
|
|
854
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 overflow-x-auto w-full sm:w-auto pb-1 sm:pb-0 hide-scrollbar shrink-0", children: [
|
|
855
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex bg-slate-100/80 p-0.5 rounded-lg mr-2 shrink-0", children: [
|
|
815
856
|
/* @__PURE__ */ jsx5("button", { onClick: () => setViewMode("desktop"), className: `p-1.5 rounded-md transition-all ${viewMode === "desktop" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`, title: "Desktop View", children: /* @__PURE__ */ jsx5(Monitor, { className: "w-4 h-4" }) }),
|
|
816
857
|
/* @__PURE__ */ jsx5("button", { onClick: () => setViewMode("tablet"), className: `p-1.5 rounded-md transition-all ${viewMode === "tablet" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`, title: "Tablet View", children: /* @__PURE__ */ jsx5(Tablet, { className: "w-4 h-4" }) }),
|
|
817
858
|
/* @__PURE__ */ jsx5("button", { onClick: () => setViewMode("mobile"), className: `p-1.5 rounded-md transition-all ${viewMode === "mobile" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`, title: "Mobile View", children: /* @__PURE__ */ jsx5(Smartphone, { className: "w-4 h-4" }) })
|
|
818
859
|
] }),
|
|
819
|
-
/* @__PURE__ */
|
|
860
|
+
/* @__PURE__ */ jsxs3(
|
|
820
861
|
"button",
|
|
821
862
|
{
|
|
822
863
|
onClick: () => setPreview((v) => !v),
|
|
@@ -827,7 +868,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
827
868
|
]
|
|
828
869
|
}
|
|
829
870
|
),
|
|
830
|
-
/* @__PURE__ */
|
|
871
|
+
/* @__PURE__ */ jsxs3(
|
|
831
872
|
"a",
|
|
832
873
|
{
|
|
833
874
|
href: page.path,
|
|
@@ -840,7 +881,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
840
881
|
]
|
|
841
882
|
}
|
|
842
883
|
),
|
|
843
|
-
/* @__PURE__ */
|
|
884
|
+
/* @__PURE__ */ jsxs3(
|
|
844
885
|
"button",
|
|
845
886
|
{
|
|
846
887
|
onClick: () => ctx.reset(),
|
|
@@ -852,7 +893,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
852
893
|
]
|
|
853
894
|
}
|
|
854
895
|
),
|
|
855
|
-
/* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ jsxs3(
|
|
856
897
|
"button",
|
|
857
898
|
{
|
|
858
899
|
onClick: () => ctx.save(),
|
|
@@ -866,7 +907,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
866
907
|
)
|
|
867
908
|
] })
|
|
868
909
|
] }),
|
|
869
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col sm:flex-row flex-1 overflow-hidden", children: [
|
|
870
911
|
/* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 sm:p-4 flex flex-col items-center", children: /* @__PURE__ */ jsx5("div", { className: `flex-1 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-lg ring-1 ring-slate-900/5 min-h-[300px] transition-all duration-300 w-full ${viewMode === "mobile" ? "max-w-[375px]" : viewMode === "tablet" ? "max-w-[768px]" : "w-full"}`, children: /* @__PURE__ */ jsx5(
|
|
871
912
|
"iframe",
|
|
872
913
|
{
|
|
@@ -877,11 +918,11 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
877
918
|
},
|
|
878
919
|
src
|
|
879
920
|
) }) }),
|
|
880
|
-
/* @__PURE__ */
|
|
881
|
-
/* @__PURE__ */
|
|
921
|
+
/* @__PURE__ */ jsxs3("aside", { className: `w-full sm:w-[320px] lg:w-[360px] shrink-0 overflow-y-auto border-t sm:border-t-0 sm:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 hide-scrollbar transition-all duration-300 ${drawerState === "min" ? "max-h-[52px] sm:max-h-none" : drawerState === "full" ? "max-h-[85vh] sm:max-h-none" : "max-h-[50vh] sm:max-h-none"}`, children: [
|
|
922
|
+
/* @__PURE__ */ jsxs3("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10 flex items-center justify-between", children: [
|
|
882
923
|
/* @__PURE__ */ jsx5("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
|
|
883
|
-
/* @__PURE__ */
|
|
884
|
-
/* @__PURE__ */
|
|
924
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
|
|
925
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1 sm:hidden", children: [
|
|
885
926
|
/* @__PURE__ */ jsx5(
|
|
886
927
|
"button",
|
|
887
928
|
{
|
|
@@ -904,7 +945,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
904
945
|
selectedMeta && /* @__PURE__ */ jsx5("button", { onClick: () => setSelectedId(null), className: "sm:hidden text-slate-400 hover:text-slate-700 text-xs font-bold uppercase tracking-widest", children: "Close" })
|
|
905
946
|
] })
|
|
906
947
|
] }),
|
|
907
|
-
/* @__PURE__ */
|
|
948
|
+
/* @__PURE__ */ jsxs3("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
|
|
908
949
|
!selectedMeta && /* @__PURE__ */ jsx5("div", { className: "px-5 mt-1 mb-2", children: /* @__PURE__ */ jsx5("p", { className: "text-[10px] md:text-xs text-slate-400", children: "Select an element on the left to edit it." }) }),
|
|
909
950
|
selectedMeta ? /* @__PURE__ */ jsx5(
|
|
910
951
|
FieldEditor,
|
|
@@ -951,7 +992,7 @@ function SectionAccordion({
|
|
|
951
992
|
}) {
|
|
952
993
|
const [expanded, setExpanded] = useState4({});
|
|
953
994
|
if (registered.length === 0) {
|
|
954
|
-
return /* @__PURE__ */
|
|
995
|
+
return /* @__PURE__ */ jsxs3("div", { className: "px-4 py-8 text-center text-sm text-slate-500", children: [
|
|
955
996
|
/* @__PURE__ */ jsx5("div", { className: "w-12 h-12 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-3", children: /* @__PURE__ */ jsx5(Pencil, { className: "h-5 w-5 text-slate-400" }) }),
|
|
956
997
|
"No editable fields detected on this page."
|
|
957
998
|
] });
|
|
@@ -965,19 +1006,19 @@ function SectionAccordion({
|
|
|
965
1006
|
const sectionNames = Object.keys(groups).filter((n) => n !== "Unsectioned");
|
|
966
1007
|
const unsectionedFields = groups["Unsectioned"] || [];
|
|
967
1008
|
const toggle = (name) => setExpanded((prev) => ({ ...prev, [name]: !prev[name] }));
|
|
968
|
-
return /* @__PURE__ */
|
|
1009
|
+
return /* @__PURE__ */ jsxs3("div", { className: "p-2 space-y-3", children: [
|
|
969
1010
|
unsectionedFields.length > 0 && /* @__PURE__ */ jsx5("ul", { className: "divide-y divide-slate-100 bg-white rounded-lg border border-slate-200 overflow-hidden shadow-sm", children: unsectionedFields.map((m) => /* @__PURE__ */ jsx5(FieldListItem, { meta: m, onSelect }, m.id)) }),
|
|
970
1011
|
sectionNames.map((sectionName) => {
|
|
971
1012
|
const isOpen = expanded[sectionName] ?? false;
|
|
972
1013
|
const fields = groups[sectionName];
|
|
973
|
-
return /* @__PURE__ */
|
|
974
|
-
/* @__PURE__ */
|
|
1014
|
+
return /* @__PURE__ */ jsxs3("div", { className: "rounded-lg border border-slate-200 overflow-hidden", children: [
|
|
1015
|
+
/* @__PURE__ */ jsxs3(
|
|
975
1016
|
"button",
|
|
976
1017
|
{
|
|
977
1018
|
onClick: () => toggle(sectionName),
|
|
978
1019
|
className: "flex w-full items-center justify-between px-3 py-2.5 bg-slate-50/80 hover:bg-slate-100 transition-colors text-left",
|
|
979
1020
|
children: [
|
|
980
|
-
/* @__PURE__ */
|
|
1021
|
+
/* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-2", children: [
|
|
981
1022
|
/* @__PURE__ */ jsx5("span", { className: "font-semibold text-sm text-slate-800", children: sectionName }),
|
|
982
1023
|
/* @__PURE__ */ jsx5("span", { className: "text-[10px] font-mono text-slate-400 bg-slate-200/70 px-1.5 py-0.5 rounded-full", children: fields.length })
|
|
983
1024
|
] }),
|
|
@@ -1001,15 +1042,15 @@ function SectionAccordion({
|
|
|
1001
1042
|
] });
|
|
1002
1043
|
}
|
|
1003
1044
|
function FieldListItem({ meta, onSelect }) {
|
|
1004
|
-
return /* @__PURE__ */ jsx5("li", { className: "p-1 list-none", children: /* @__PURE__ */
|
|
1045
|
+
return /* @__PURE__ */ jsx5("li", { className: "p-1 list-none", children: /* @__PURE__ */ jsxs3(
|
|
1005
1046
|
"button",
|
|
1006
1047
|
{
|
|
1007
1048
|
onClick: () => onSelect(meta.id),
|
|
1008
1049
|
className: "flex w-full items-center justify-between gap-2 rounded-md px-3 py-2.5 text-left hover:bg-slate-50 group transition-colors",
|
|
1009
1050
|
children: [
|
|
1010
|
-
/* @__PURE__ */
|
|
1051
|
+
/* @__PURE__ */ jsxs3("span", { className: "overflow-hidden", children: [
|
|
1011
1052
|
/* @__PURE__ */ jsx5("span", { className: "block font-medium text-slate-800 text-sm truncate", children: meta.label ?? meta.id }),
|
|
1012
|
-
/* @__PURE__ */
|
|
1053
|
+
/* @__PURE__ */ jsxs3("span", { className: "block text-[10px] md:text-xs text-slate-400 truncate mt-0.5 font-mono", children: [
|
|
1013
1054
|
meta.type,
|
|
1014
1055
|
" ",
|
|
1015
1056
|
/* @__PURE__ */ jsx5("span", { className: "text-slate-300 mx-1", children: "\xB7" }),
|
|
@@ -1030,13 +1071,13 @@ function FieldEditor({
|
|
|
1030
1071
|
onClose
|
|
1031
1072
|
}) {
|
|
1032
1073
|
const ctx = useCmsContext();
|
|
1033
|
-
return /* @__PURE__ */
|
|
1034
|
-
/* @__PURE__ */
|
|
1074
|
+
return /* @__PURE__ */ jsxs3("div", { className: "p-5 animate-in slide-in-from-right-4 duration-200", children: [
|
|
1075
|
+
/* @__PURE__ */ jsxs3("div", { className: "mb-5", children: [
|
|
1035
1076
|
/* @__PURE__ */ jsx5("div", { className: "inline-flex items-center gap-1.5 px-2 py-1 rounded bg-indigo-50 text-indigo-700 text-[10px] font-bold uppercase tracking-wider mb-2", children: meta.type }),
|
|
1036
1077
|
/* @__PURE__ */ jsx5("div", { className: "font-bold text-slate-900 text-lg leading-tight", children: meta.label ?? meta.id }),
|
|
1037
1078
|
/* @__PURE__ */ jsx5("div", { className: "text-xs font-mono text-slate-400 mt-1", children: meta.id })
|
|
1038
1079
|
] }),
|
|
1039
|
-
/* @__PURE__ */
|
|
1080
|
+
/* @__PURE__ */ jsxs3("div", { className: "space-y-4", children: [
|
|
1040
1081
|
meta.type === "text" && /* @__PURE__ */ jsx5(
|
|
1041
1082
|
"input",
|
|
1042
1083
|
{
|
|
@@ -1055,8 +1096,8 @@ function FieldEditor({
|
|
|
1055
1096
|
className: "w-full rounded-xl border border-slate-200 px-4 py-3 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all resize-y"
|
|
1056
1097
|
}
|
|
1057
1098
|
),
|
|
1058
|
-
meta.type === "image" && /* @__PURE__ */
|
|
1059
|
-
/* @__PURE__ */
|
|
1099
|
+
meta.type === "image" && /* @__PURE__ */ jsxs3("div", { className: "space-y-3", children: [
|
|
1100
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
|
|
1060
1101
|
/* @__PURE__ */ jsx5(
|
|
1061
1102
|
"input",
|
|
1062
1103
|
{
|
|
@@ -1067,7 +1108,7 @@ function FieldEditor({
|
|
|
1067
1108
|
className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
1068
1109
|
}
|
|
1069
1110
|
),
|
|
1070
|
-
/* @__PURE__ */
|
|
1111
|
+
/* @__PURE__ */ jsxs3("label", { className: "flex-shrink-0 cursor-pointer rounded-xl bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-200 transition-colors border border-slate-200 flex items-center justify-center", children: [
|
|
1071
1112
|
"Upload",
|
|
1072
1113
|
/* @__PURE__ */ jsx5(
|
|
1073
1114
|
"input",
|
|
@@ -1085,7 +1126,7 @@ function FieldEditor({
|
|
|
1085
1126
|
)
|
|
1086
1127
|
] })
|
|
1087
1128
|
] }),
|
|
1088
|
-
value ? /* @__PURE__ */
|
|
1129
|
+
value ? /* @__PURE__ */ jsxs3("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group", children: [
|
|
1089
1130
|
/* @__PURE__ */ jsx5(
|
|
1090
1131
|
"img",
|
|
1091
1132
|
{
|
|
@@ -1097,8 +1138,8 @@ function FieldEditor({
|
|
|
1097
1138
|
/* @__PURE__ */ jsx5("div", { className: "absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity", children: /* @__PURE__ */ jsx5("span", { className: "text-white text-xs font-medium px-2 py-1 bg-black/50 rounded backdrop-blur", children: "Preview" }) })
|
|
1098
1139
|
] }) : null
|
|
1099
1140
|
] }),
|
|
1100
|
-
meta.type === "link" && /* @__PURE__ */
|
|
1101
|
-
/* @__PURE__ */
|
|
1141
|
+
meta.type === "link" && /* @__PURE__ */ jsxs3("div", { className: "space-y-4 bg-slate-50 p-4 rounded-xl border border-slate-100", children: [
|
|
1142
|
+
/* @__PURE__ */ jsxs3("label", { className: "block", children: [
|
|
1102
1143
|
/* @__PURE__ */ jsx5("span", { className: "text-xs font-semibold text-slate-500 uppercase tracking-wide", children: "Link Text" }),
|
|
1103
1144
|
/* @__PURE__ */ jsx5(
|
|
1104
1145
|
"input",
|
|
@@ -1109,7 +1150,7 @@ function FieldEditor({
|
|
|
1109
1150
|
}
|
|
1110
1151
|
)
|
|
1111
1152
|
] }),
|
|
1112
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ jsxs3("label", { className: "block", children: [
|
|
1113
1154
|
/* @__PURE__ */ jsx5("span", { className: "text-xs font-semibold text-slate-500 uppercase tracking-wide", children: "URL Target" }),
|
|
1114
1155
|
/* @__PURE__ */ jsx5(
|
|
1115
1156
|
"input",
|
|
@@ -1122,7 +1163,7 @@ function FieldEditor({
|
|
|
1122
1163
|
)
|
|
1123
1164
|
] })
|
|
1124
1165
|
] }),
|
|
1125
|
-
meta.type === "color" && /* @__PURE__ */
|
|
1166
|
+
meta.type === "color" && /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3 bg-slate-50 p-2 rounded-xl border border-slate-100", children: [
|
|
1126
1167
|
/* @__PURE__ */ jsx5(
|
|
1127
1168
|
"input",
|
|
1128
1169
|
{
|
|
@@ -1151,9 +1192,9 @@ function FieldEditor({
|
|
|
1151
1192
|
className: "w-full rounded-xl border border-slate-200 px-4 py-3 font-mono text-xs text-slate-700 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all resize-y"
|
|
1152
1193
|
}
|
|
1153
1194
|
),
|
|
1154
|
-
meta.type === "list" && /* @__PURE__ */
|
|
1155
|
-
(Array.isArray(value) ? value : []).map((item, idx) => /* @__PURE__ */
|
|
1156
|
-
/* @__PURE__ */ jsx5("div", { className: "flex-1 space-y-3 w-full", children: meta.itemSchema ? meta.itemSchema.map((schemaField) => /* @__PURE__ */
|
|
1195
|
+
meta.type === "list" && /* @__PURE__ */ jsxs3("div", { className: "space-y-4", children: [
|
|
1196
|
+
(Array.isArray(value) ? value : []).map((item, idx) => /* @__PURE__ */ jsxs3("div", { className: "flex gap-3 items-start bg-slate-50 p-3 rounded-xl border border-slate-100 relative group", children: [
|
|
1197
|
+
/* @__PURE__ */ jsx5("div", { className: "flex-1 space-y-3 w-full", children: meta.itemSchema ? meta.itemSchema.map((schemaField) => /* @__PURE__ */ jsxs3("div", { children: [
|
|
1157
1198
|
/* @__PURE__ */ jsx5("label", { className: "block text-[10px] font-bold text-slate-500 uppercase mb-1", children: schemaField.label || schemaField.key }),
|
|
1158
1199
|
schemaField.type === "icon" ? /* @__PURE__ */ jsx5(
|
|
1159
1200
|
SearchableSelect,
|
|
@@ -1180,7 +1221,7 @@ function FieldEditor({
|
|
|
1180
1221
|
},
|
|
1181
1222
|
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
1182
1223
|
}
|
|
1183
|
-
) : schemaField.type === "boolean" ? /* @__PURE__ */
|
|
1224
|
+
) : schemaField.type === "boolean" ? /* @__PURE__ */ jsxs3("label", { className: "flex items-center gap-2 mt-1 cursor-pointer", children: [
|
|
1184
1225
|
/* @__PURE__ */ jsx5(
|
|
1185
1226
|
"input",
|
|
1186
1227
|
{
|
|
@@ -1195,8 +1236,8 @@ function FieldEditor({
|
|
|
1195
1236
|
}
|
|
1196
1237
|
),
|
|
1197
1238
|
/* @__PURE__ */ jsx5("span", { className: "text-sm text-slate-700", children: schemaField.label || schemaField.key })
|
|
1198
|
-
] }) : schemaField.type === "image" ? /* @__PURE__ */
|
|
1199
|
-
/* @__PURE__ */
|
|
1239
|
+
] }) : schemaField.type === "image" ? /* @__PURE__ */ jsxs3("div", { className: "space-y-3 mt-1", children: [
|
|
1240
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
|
|
1200
1241
|
/* @__PURE__ */ jsx5(
|
|
1201
1242
|
"input",
|
|
1202
1243
|
{
|
|
@@ -1211,7 +1252,7 @@ function FieldEditor({
|
|
|
1211
1252
|
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
1212
1253
|
}
|
|
1213
1254
|
),
|
|
1214
|
-
/* @__PURE__ */
|
|
1255
|
+
/* @__PURE__ */ jsxs3("label", { className: "flex-shrink-0 cursor-pointer rounded-lg bg-slate-100 px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200 transition-colors border border-slate-200 flex items-center justify-center", children: [
|
|
1215
1256
|
"Upload",
|
|
1216
1257
|
/* @__PURE__ */ jsx5(
|
|
1217
1258
|
"input",
|
|
@@ -1284,7 +1325,7 @@ function FieldEditor({
|
|
|
1284
1325
|
}
|
|
1285
1326
|
)
|
|
1286
1327
|
] }, idx)),
|
|
1287
|
-
!meta.fixedLength && /* @__PURE__ */
|
|
1328
|
+
!meta.fixedLength && /* @__PURE__ */ jsxs3(
|
|
1288
1329
|
"button",
|
|
1289
1330
|
{
|
|
1290
1331
|
onClick: () => {
|
|
@@ -1310,8 +1351,8 @@ function FieldEditor({
|
|
|
1310
1351
|
] }),
|
|
1311
1352
|
" "
|
|
1312
1353
|
] }),
|
|
1313
|
-
/* @__PURE__ */
|
|
1314
|
-
/* @__PURE__ */
|
|
1354
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between pt-6 mt-6 border-t border-slate-100", children: [
|
|
1355
|
+
/* @__PURE__ */ jsxs3(
|
|
1315
1356
|
"button",
|
|
1316
1357
|
{
|
|
1317
1358
|
onClick: onReset,
|
|
@@ -1347,18 +1388,18 @@ function CollectionsSection() {
|
|
|
1347
1388
|
});
|
|
1348
1389
|
});
|
|
1349
1390
|
}, [ctx.adapter, collections]);
|
|
1350
|
-
return /* @__PURE__ */
|
|
1351
|
-
/* @__PURE__ */
|
|
1391
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
|
|
1392
|
+
/* @__PURE__ */ jsxs3("div", { className: "w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-slate-200 bg-white/50 p-4", children: [
|
|
1352
1393
|
/* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
|
|
1353
|
-
/* @__PURE__ */
|
|
1354
|
-
collections.map((c) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */
|
|
1394
|
+
/* @__PURE__ */ jsxs3("ul", { className: "flex overflow-x-auto gap-2 pb-2 md:block md:space-x-0 md:space-y-1 md:pb-0 md:overflow-visible", children: [
|
|
1395
|
+
collections.map((c) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */ jsxs3(
|
|
1355
1396
|
"button",
|
|
1356
1397
|
{
|
|
1357
1398
|
onClick: () => setSelected(c),
|
|
1358
1399
|
className: `w-full rounded-lg px-3 py-2.5 text-left text-sm transition-all duration-200 ${selected?.id === c.id ? "bg-white shadow-sm ring-1 ring-slate-200 font-semibold" : "hover:bg-slate-100"}`,
|
|
1359
1400
|
children: [
|
|
1360
1401
|
/* @__PURE__ */ jsx5("div", { className: selected?.id === c.id ? "text-slate-900" : "text-slate-700", children: c.name }),
|
|
1361
|
-
/* @__PURE__ */
|
|
1402
|
+
/* @__PURE__ */ jsxs3("div", { className: `text-xs mt-0.5 ${selected?.id === c.id ? "text-indigo-500" : "text-slate-400"}`, children: [
|
|
1362
1403
|
counts[c.id] ?? 0,
|
|
1363
1404
|
" items"
|
|
1364
1405
|
] })
|
|
@@ -1368,7 +1409,7 @@ function CollectionsSection() {
|
|
|
1368
1409
|
collections.length === 0 && /* @__PURE__ */ jsx5("li", { className: "px-3 py-6 text-center text-sm text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-200", children: "No collections registered." })
|
|
1369
1410
|
] })
|
|
1370
1411
|
] }),
|
|
1371
|
-
/* @__PURE__ */
|
|
1412
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex-1 overflow-auto p-4 md:p-8 relative", children: [
|
|
1372
1413
|
/* @__PURE__ */ jsx5("div", { className: "absolute inset-0 bg-grid-slate-100 [mask-image:linear-gradient(0deg,white,rgba(255,255,255,0.6))] -z-10 pointer-events-none" }),
|
|
1373
1414
|
selected ? /* @__PURE__ */ jsx5(CollectionEditor, { collection: selected }, selected.id) : /* @__PURE__ */ jsx5("div", { className: "grid h-full place-items-center text-sm text-slate-500", children: "Select a collection to manage its entries." })
|
|
1374
1415
|
] })
|
|
@@ -1469,13 +1510,13 @@ function CollectionEditor({ collection }) {
|
|
|
1469
1510
|
setDragOverIdx(null);
|
|
1470
1511
|
};
|
|
1471
1512
|
const visibleFields = collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order").slice(0, 5);
|
|
1472
|
-
return /* @__PURE__ */
|
|
1473
|
-
/* @__PURE__ */
|
|
1474
|
-
/* @__PURE__ */
|
|
1513
|
+
return /* @__PURE__ */ jsxs3("div", { className: "mx-auto max-w-5xl", children: [
|
|
1514
|
+
/* @__PURE__ */ jsxs3("div", { className: "mb-8 flex items-center justify-between", children: [
|
|
1515
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
1475
1516
|
/* @__PURE__ */ jsx5("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: collection.name }),
|
|
1476
1517
|
collection.description && /* @__PURE__ */ jsx5("p", { className: "text-sm text-slate-500 mt-1", children: collection.description })
|
|
1477
1518
|
] }),
|
|
1478
|
-
/* @__PURE__ */
|
|
1519
|
+
/* @__PURE__ */ jsxs3(
|
|
1479
1520
|
"button",
|
|
1480
1521
|
{
|
|
1481
1522
|
onClick: startNew,
|
|
@@ -1487,13 +1528,13 @@ function CollectionEditor({ collection }) {
|
|
|
1487
1528
|
}
|
|
1488
1529
|
)
|
|
1489
1530
|
] }),
|
|
1490
|
-
editing && /* @__PURE__ */
|
|
1491
|
-
/* @__PURE__ */
|
|
1531
|
+
editing && /* @__PURE__ */ jsxs3("div", { className: "mb-8 rounded-2xl border border-indigo-100 bg-white p-6 shadow-xl shadow-indigo-100/50 animate-in fade-in slide-in-from-top-4", children: [
|
|
1532
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 mb-6", children: [
|
|
1492
1533
|
/* @__PURE__ */ jsx5("div", { className: "w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600", children: /* @__PURE__ */ jsx5(Pencil, { className: "w-4 h-4" }) }),
|
|
1493
1534
|
/* @__PURE__ */ jsx5("h3", { className: "text-lg font-bold text-slate-900", children: "Edit Entry" })
|
|
1494
1535
|
] }),
|
|
1495
|
-
/* @__PURE__ */ jsx5("div", { className: "grid gap-5 md:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order").map((f) => /* @__PURE__ */
|
|
1496
|
-
/* @__PURE__ */
|
|
1536
|
+
/* @__PURE__ */ jsx5("div", { className: "grid gap-5 md:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order").map((f) => /* @__PURE__ */ jsxs3("label", { className: `block ${f.type === "richtext" ? "md:col-span-2" : ""}`, children: [
|
|
1537
|
+
/* @__PURE__ */ jsxs3("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
|
|
1497
1538
|
f.label,
|
|
1498
1539
|
/* @__PURE__ */ jsx5("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
|
|
1499
1540
|
] }),
|
|
@@ -1530,7 +1571,7 @@ function CollectionEditor({ collection }) {
|
|
|
1530
1571
|
placeholder: `Search ${f.label.toLowerCase()}...`,
|
|
1531
1572
|
iconMap: ctx.iconMap
|
|
1532
1573
|
}
|
|
1533
|
-
) : f.type === "slug" ? /* @__PURE__ */
|
|
1574
|
+
) : f.type === "slug" ? /* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
|
|
1534
1575
|
/* @__PURE__ */ jsx5(
|
|
1535
1576
|
"input",
|
|
1536
1577
|
{
|
|
@@ -1554,7 +1595,7 @@ function CollectionEditor({ collection }) {
|
|
|
1554
1595
|
children: "Generate"
|
|
1555
1596
|
}
|
|
1556
1597
|
)
|
|
1557
|
-
] }) : f.type === "select" ? /* @__PURE__ */
|
|
1598
|
+
] }) : f.type === "select" ? /* @__PURE__ */ jsxs3("div", { children: [
|
|
1558
1599
|
/* @__PURE__ */ jsx5(
|
|
1559
1600
|
"input",
|
|
1560
1601
|
{
|
|
@@ -1569,8 +1610,8 @@ function CollectionEditor({ collection }) {
|
|
|
1569
1610
|
const lab = typeof opt === "string" ? opt : opt.label;
|
|
1570
1611
|
return /* @__PURE__ */ jsx5("option", { value: val, children: lab }, val);
|
|
1571
1612
|
}) })
|
|
1572
|
-
] }) : f.type === "image" ? /* @__PURE__ */
|
|
1573
|
-
/* @__PURE__ */
|
|
1613
|
+
] }) : f.type === "image" ? /* @__PURE__ */ jsxs3("div", { className: "space-y-3", children: [
|
|
1614
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
|
|
1574
1615
|
/* @__PURE__ */ jsx5(
|
|
1575
1616
|
"input",
|
|
1576
1617
|
{
|
|
@@ -1581,7 +1622,7 @@ function CollectionEditor({ collection }) {
|
|
|
1581
1622
|
className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
1582
1623
|
}
|
|
1583
1624
|
),
|
|
1584
|
-
/* @__PURE__ */
|
|
1625
|
+
/* @__PURE__ */ jsxs3("label", { className: "flex-shrink-0 cursor-pointer rounded-xl bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-200 transition-colors border border-slate-200 flex items-center justify-center", children: [
|
|
1585
1626
|
"Upload",
|
|
1586
1627
|
/* @__PURE__ */ jsx5(
|
|
1587
1628
|
"input",
|
|
@@ -1626,7 +1667,7 @@ function CollectionEditor({ collection }) {
|
|
|
1626
1667
|
}
|
|
1627
1668
|
)
|
|
1628
1669
|
] }, f.id)) }),
|
|
1629
|
-
/* @__PURE__ */
|
|
1670
|
+
/* @__PURE__ */ jsxs3("div", { className: "mt-8 flex justify-end gap-3 pt-5 border-t border-slate-100", children: [
|
|
1630
1671
|
/* @__PURE__ */ jsx5(
|
|
1631
1672
|
"button",
|
|
1632
1673
|
{
|
|
@@ -1642,8 +1683,8 @@ function CollectionEditor({ collection }) {
|
|
|
1642
1683
|
onClick: save,
|
|
1643
1684
|
disabled: saving,
|
|
1644
1685
|
className: "inline-flex items-center gap-2 rounded-xl bg-slate-900 px-6 py-2.5 text-sm font-bold text-white shadow-sm hover:bg-slate-800 hover:shadow transition-all disabled:opacity-60",
|
|
1645
|
-
children: saving ? /* @__PURE__ */
|
|
1646
|
-
/* @__PURE__ */
|
|
1686
|
+
children: saving ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1687
|
+
/* @__PURE__ */ jsxs3("svg", { className: "animate-spin h-4 w-4 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
1647
1688
|
/* @__PURE__ */ jsx5("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
1648
1689
|
/* @__PURE__ */ jsx5("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
1649
1690
|
] }),
|
|
@@ -1653,19 +1694,19 @@ function CollectionEditor({ collection }) {
|
|
|
1653
1694
|
)
|
|
1654
1695
|
] })
|
|
1655
1696
|
] }),
|
|
1656
|
-
/* @__PURE__ */ jsx5("div", { className: "overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */
|
|
1657
|
-
/* @__PURE__ */ jsx5("thead", { className: "bg-slate-50/80 border-b border-slate-200", children: /* @__PURE__ */
|
|
1697
|
+
/* @__PURE__ */ jsx5("div", { className: "overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */ jsxs3("table", { className: "w-full text-sm text-left", children: [
|
|
1698
|
+
/* @__PURE__ */ jsx5("thead", { className: "bg-slate-50/80 border-b border-slate-200", children: /* @__PURE__ */ jsxs3("tr", { children: [
|
|
1658
1699
|
visibleFields.map((f) => /* @__PURE__ */ jsx5("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: f.label }, f.id)),
|
|
1659
1700
|
/* @__PURE__ */ jsx5("th", { className: "px-6 py-4 text-right text-xs font-bold text-slate-500 uppercase tracking-wider sticky right-0 bg-slate-50 border-l border-slate-200 z-10", children: "Actions" })
|
|
1660
1701
|
] }) }),
|
|
1661
1702
|
/* @__PURE__ */ jsx5("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
|
|
1662
1703
|
// Loading skeleton rows
|
|
1663
|
-
Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */
|
|
1704
|
+
Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxs3("tr", { children: [
|
|
1664
1705
|
visibleFields.map((f) => /* @__PURE__ */ jsx5("td", { className: "px-6 py-4", children: /* @__PURE__ */ jsx5("div", { className: "h-4 bg-slate-100 rounded animate-pulse", style: { width: `${60 + i * 13 % 30}%` } }) }, f.id)),
|
|
1665
1706
|
/* @__PURE__ */ jsx5("td", { className: "px-6 py-4 sticky right-0 bg-white border-l border-slate-100", children: /* @__PURE__ */ jsx5("div", { className: "h-4 w-16 bg-slate-100 rounded animate-pulse ml-auto" }) })
|
|
1666
1707
|
] }, i))
|
|
1667
|
-
) : /* @__PURE__ */
|
|
1668
|
-
entries.map((e, idx) => /* @__PURE__ */
|
|
1708
|
+
) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1709
|
+
entries.map((e, idx) => /* @__PURE__ */ jsxs3(
|
|
1669
1710
|
"tr",
|
|
1670
1711
|
{
|
|
1671
1712
|
draggable: true,
|
|
@@ -1676,7 +1717,7 @@ function CollectionEditor({ collection }) {
|
|
|
1676
1717
|
className: `hover:bg-slate-50/50 transition-colors group cursor-grab active:cursor-grabbing ${deletingId === e.id ? "opacity-50" : ""} ${dragOverIdx === idx ? "border-t-2 border-t-indigo-500" : ""}`,
|
|
1677
1718
|
children: [
|
|
1678
1719
|
visibleFields.map((f) => /* @__PURE__ */ jsx5("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ jsx5("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ jsx5("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && e[f.id] ? /* @__PURE__ */ jsx5("img", { src: String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ jsx5("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ jsx5("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx5("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : String(e[f.id] ?? "") }, f.id)),
|
|
1679
|
-
/* @__PURE__ */ jsx5("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */
|
|
1720
|
+
/* @__PURE__ */ jsx5("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-2", children: [
|
|
1680
1721
|
/* @__PURE__ */ jsx5("div", { className: "p-2 text-slate-300 cursor-grab active:cursor-grabbing", title: "Drag to reorder", children: /* @__PURE__ */ jsx5("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "w-4 h-4", children: /* @__PURE__ */ jsx5("path", { d: "M5.5 3C6.32843 3 7 3.67157 7 4.5C7 5.32843 6.32843 6 5.5 6C4.67157 6 4 5.32843 4 4.5C4 3.67157 4.67157 3 5.5 3ZM9.5 3C10.3284 3 11 3.67157 11 4.5C11 5.32843 10.3284 6 9.5 6C8.67157 6 8 5.32843 8 4.5C8 3.67157 8.67157 3 9.5 3ZM5.5 7.5C6.32843 7.5 7 8.17157 7 9C7 9.82843 6.32843 10.5 5.5 10.5C4.67157 10.5 4 9.82843 4 9C4 8.17157 4.67157 7.5 5.5 7.5ZM9.5 7.5C10.3284 7.5 11 8.17157 11 9C11 9.82843 10.3284 10.5 9.5 10.5C8.67157 10.5 8 9.82843 8 9C8 8.17157 8.67157 7.5 9.5 7.5ZM5.5 12C6.32843 12 7 12.6716 7 13.5C7 14.3284 6.32843 15 5.5 15C4.67157 15 4 14.3284 4 13.5C4 12.6716 4.67157 12 5.5 12ZM9.5 12C10.3284 12 11 12.6716 11 13.5C11 14.3284 10.3284 15 9.5 15C8.67157 15 8 14.3284 8 13.5C8 12.6716 8.67157 12 9.5 12Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) }),
|
|
1681
1722
|
/* @__PURE__ */ jsx5(
|
|
1682
1723
|
"button",
|
|
@@ -1694,7 +1735,7 @@ function CollectionEditor({ collection }) {
|
|
|
1694
1735
|
disabled: deletingId === e.id,
|
|
1695
1736
|
className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
|
|
1696
1737
|
title: "Delete",
|
|
1697
|
-
children: deletingId === e.id ? /* @__PURE__ */
|
|
1738
|
+
children: deletingId === e.id ? /* @__PURE__ */ jsxs3("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
1698
1739
|
/* @__PURE__ */ jsx5("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
1699
1740
|
/* @__PURE__ */ jsx5("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
1700
1741
|
] }) : /* @__PURE__ */ jsx5(Trash2, { className: "h-4 w-4" })
|
|
@@ -1710,7 +1751,7 @@ function CollectionEditor({ collection }) {
|
|
|
1710
1751
|
{
|
|
1711
1752
|
colSpan: visibleFields.length + 1,
|
|
1712
1753
|
className: "px-6 py-12 text-center text-slate-500",
|
|
1713
|
-
children: /* @__PURE__ */
|
|
1754
|
+
children: /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center justify-center", children: [
|
|
1714
1755
|
/* @__PURE__ */ jsx5(Boxes, { className: "h-10 w-10 text-slate-300 mb-3" }),
|
|
1715
1756
|
/* @__PURE__ */ jsx5("p", { children: 'No entries yet. Click "New Entry" to create one.' })
|
|
1716
1757
|
] })
|
|
@@ -1741,18 +1782,18 @@ function SubmissionsSection() {
|
|
|
1741
1782
|
setSelectedFormId(formIds[0]);
|
|
1742
1783
|
}
|
|
1743
1784
|
}, [formIds, selectedFormId]);
|
|
1744
|
-
return /* @__PURE__ */
|
|
1745
|
-
/* @__PURE__ */
|
|
1785
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
|
|
1786
|
+
/* @__PURE__ */ jsxs3("div", { className: "w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-slate-200 bg-white/50 p-4", children: [
|
|
1746
1787
|
/* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Data Collections" }),
|
|
1747
|
-
/* @__PURE__ */
|
|
1748
|
-
formIds.map((id) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */
|
|
1788
|
+
/* @__PURE__ */ jsxs3("ul", { className: "flex overflow-x-auto gap-2 pb-2 md:block md:space-x-0 md:space-y-1 md:pb-0 md:overflow-visible", children: [
|
|
1789
|
+
formIds.map((id) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */ jsxs3(
|
|
1749
1790
|
"button",
|
|
1750
1791
|
{
|
|
1751
1792
|
onClick: () => setSelectedFormId(id),
|
|
1752
1793
|
className: `w-full rounded-lg px-3 py-2.5 text-left text-sm transition-all duration-200 ${selectedFormId === id ? "bg-white shadow-sm ring-1 ring-slate-200 font-semibold" : "hover:bg-slate-100"}`,
|
|
1753
1794
|
children: [
|
|
1754
1795
|
/* @__PURE__ */ jsx5("div", { className: selectedFormId === id ? "text-slate-900" : "text-slate-700 capitalize", children: id }),
|
|
1755
|
-
/* @__PURE__ */
|
|
1796
|
+
/* @__PURE__ */ jsxs3("div", { className: `text-xs mt-0.5 ${selectedFormId === id ? "text-indigo-500" : "text-slate-400"}`, children: [
|
|
1756
1797
|
submissions.filter((s) => s.formId === id).length,
|
|
1757
1798
|
" items"
|
|
1758
1799
|
] })
|
|
@@ -1762,7 +1803,7 @@ function SubmissionsSection() {
|
|
|
1762
1803
|
formIds.length === 0 && /* @__PURE__ */ jsx5("li", { className: "px-3 py-6 text-center text-sm text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-200", children: "No data collected." })
|
|
1763
1804
|
] })
|
|
1764
1805
|
] }),
|
|
1765
|
-
/* @__PURE__ */
|
|
1806
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex-1 overflow-auto p-4 md:p-8 relative", children: [
|
|
1766
1807
|
/* @__PURE__ */ jsx5("div", { className: "absolute inset-0 bg-grid-slate-100 [mask-image:linear-gradient(0deg,white,rgba(255,255,255,0.6))] -z-10 pointer-events-none" }),
|
|
1767
1808
|
selectedFormId ? /* @__PURE__ */ jsx5(
|
|
1768
1809
|
SubmissionsList,
|
|
@@ -1811,8 +1852,8 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1811
1852
|
}
|
|
1812
1853
|
};
|
|
1813
1854
|
if (detail) {
|
|
1814
|
-
return /* @__PURE__ */
|
|
1815
|
-
/* @__PURE__ */
|
|
1855
|
+
return /* @__PURE__ */ jsxs3("div", { className: "mx-auto w-full max-w-2xl", children: [
|
|
1856
|
+
/* @__PURE__ */ jsxs3(
|
|
1816
1857
|
"button",
|
|
1817
1858
|
{
|
|
1818
1859
|
onClick: () => setDetail(null),
|
|
@@ -1823,9 +1864,9 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1823
1864
|
]
|
|
1824
1865
|
}
|
|
1825
1866
|
),
|
|
1826
|
-
/* @__PURE__ */
|
|
1827
|
-
/* @__PURE__ */ jsx5("div", { className: "px-8 py-6 border-b border-slate-100 bg-slate-50/50", children: /* @__PURE__ */
|
|
1828
|
-
/* @__PURE__ */
|
|
1867
|
+
/* @__PURE__ */ jsxs3("div", { className: "rounded-2xl border border-slate-200 bg-white shadow-sm overflow-hidden", children: [
|
|
1868
|
+
/* @__PURE__ */ jsx5("div", { className: "px-8 py-6 border-b border-slate-100 bg-slate-50/50", children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between", children: [
|
|
1869
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
1829
1870
|
/* @__PURE__ */ jsx5("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-indigo-100 px-3 py-1 text-xs font-bold text-indigo-700 mb-2 capitalize", children: detail.formId }),
|
|
1830
1871
|
/* @__PURE__ */ jsx5("p", { className: "text-xs text-slate-400", children: formatDate(detail.submittedAt) })
|
|
1831
1872
|
] }),
|
|
@@ -1839,23 +1880,23 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1839
1880
|
}
|
|
1840
1881
|
)
|
|
1841
1882
|
] }) }),
|
|
1842
|
-
/* @__PURE__ */ jsx5("div", { className: "px-8 py-6 divide-y divide-slate-100", children: Object.entries(detail.data).map(([key, val]) => /* @__PURE__ */
|
|
1883
|
+
/* @__PURE__ */ jsx5("div", { className: "px-8 py-6 divide-y divide-slate-100", children: Object.entries(detail.data).map(([key, val]) => /* @__PURE__ */ jsxs3("div", { className: "py-4 grid grid-cols-[160px_1fr] gap-4", children: [
|
|
1843
1884
|
/* @__PURE__ */ jsx5("dt", { className: "text-xs font-bold uppercase tracking-wide text-slate-400 pt-0.5", children: key }),
|
|
1844
1885
|
/* @__PURE__ */ jsx5("dd", { className: "text-sm text-slate-800 whitespace-pre-wrap", children: String(val ?? "\u2014") })
|
|
1845
1886
|
] }, key)) })
|
|
1846
1887
|
] })
|
|
1847
1888
|
] });
|
|
1848
1889
|
}
|
|
1849
|
-
return /* @__PURE__ */
|
|
1850
|
-
/* @__PURE__ */
|
|
1851
|
-
/* @__PURE__ */
|
|
1852
|
-
/* @__PURE__ */
|
|
1890
|
+
return /* @__PURE__ */ jsxs3("div", { className: "mx-auto w-full max-w-5xl flex flex-col h-full gap-6", children: [
|
|
1891
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between", children: [
|
|
1892
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
1893
|
+
/* @__PURE__ */ jsxs3("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight flex items-center gap-3 capitalize", children: [
|
|
1853
1894
|
formId,
|
|
1854
1895
|
unreadCount > 0 && /* @__PURE__ */ jsx5("span", { className: "inline-flex h-6 min-w-[24px] items-center justify-center rounded-full bg-indigo-600 px-2 text-xs font-bold text-white", children: unreadCount })
|
|
1855
1896
|
] }),
|
|
1856
1897
|
/* @__PURE__ */ jsx5("p", { className: "text-sm text-slate-500 mt-1", children: "Data received for this collection." })
|
|
1857
1898
|
] }),
|
|
1858
|
-
/* @__PURE__ */
|
|
1899
|
+
/* @__PURE__ */ jsxs3(
|
|
1859
1900
|
"button",
|
|
1860
1901
|
{
|
|
1861
1902
|
onClick: onLoad,
|
|
@@ -1868,7 +1909,7 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1868
1909
|
}
|
|
1869
1910
|
)
|
|
1870
1911
|
] }),
|
|
1871
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ jsxs3("div", { className: "relative", children: [
|
|
1872
1913
|
/* @__PURE__ */ jsx5(Search, { className: "absolute left-4 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" }),
|
|
1873
1914
|
/* @__PURE__ */ jsx5(
|
|
1874
1915
|
"input",
|
|
@@ -1883,28 +1924,28 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1883
1924
|
}
|
|
1884
1925
|
)
|
|
1885
1926
|
] }),
|
|
1886
|
-
/* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */
|
|
1887
|
-
/* @__PURE__ */ jsx5("thead", { className: "bg-slate-50/80 border-b border-slate-200 sticky top-0", children: /* @__PURE__ */
|
|
1927
|
+
/* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */ jsxs3("table", { className: "w-full text-sm text-left", children: [
|
|
1928
|
+
/* @__PURE__ */ jsx5("thead", { className: "bg-slate-50/80 border-b border-slate-200 sticky top-0", children: /* @__PURE__ */ jsxs3("tr", { children: [
|
|
1888
1929
|
/* @__PURE__ */ jsx5("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: "Summary" }),
|
|
1889
1930
|
/* @__PURE__ */ jsx5("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: "Received" }),
|
|
1890
1931
|
/* @__PURE__ */ jsx5("th", { className: "px-6 py-4 text-right text-xs font-bold text-slate-500 uppercase tracking-wider sticky right-0 bg-slate-50 border-l border-slate-200 z-10", children: "Actions" })
|
|
1891
1932
|
] }) }),
|
|
1892
|
-
/* @__PURE__ */
|
|
1933
|
+
/* @__PURE__ */ jsxs3("tbody", { className: "divide-y divide-slate-100", children: [
|
|
1893
1934
|
paginated.map((s) => {
|
|
1894
1935
|
const firstVal = Object.values(s.data)[0];
|
|
1895
1936
|
const preview = firstVal ? String(firstVal).slice(0, 60) : "\u2014";
|
|
1896
|
-
return /* @__PURE__ */
|
|
1937
|
+
return /* @__PURE__ */ jsxs3(
|
|
1897
1938
|
"tr",
|
|
1898
1939
|
{
|
|
1899
1940
|
className: `hover:bg-slate-50/50 transition-colors group cursor-pointer ${!s.read ? "bg-indigo-50/40" : ""}`,
|
|
1900
1941
|
onClick: () => openDetail(s),
|
|
1901
1942
|
children: [
|
|
1902
|
-
/* @__PURE__ */
|
|
1943
|
+
/* @__PURE__ */ jsxs3("td", { className: "px-6 py-4", children: [
|
|
1903
1944
|
/* @__PURE__ */ jsx5("span", { className: "text-slate-600 max-w-[400px] truncate block", children: preview }),
|
|
1904
1945
|
!s.read && /* @__PURE__ */ jsx5("span", { className: "ml-2 inline-block h-2 w-2 rounded-full bg-indigo-500" })
|
|
1905
1946
|
] }),
|
|
1906
1947
|
/* @__PURE__ */ jsx5("td", { className: "px-6 py-4 text-slate-500 whitespace-nowrap", children: formatDate(s.submittedAt) }),
|
|
1907
|
-
/* @__PURE__ */ jsx5("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */
|
|
1948
|
+
/* @__PURE__ */ jsx5("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-1", children: [
|
|
1908
1949
|
/* @__PURE__ */ jsx5(
|
|
1909
1950
|
"button",
|
|
1910
1951
|
{
|
|
@@ -1929,19 +1970,19 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1929
1970
|
s.id
|
|
1930
1971
|
);
|
|
1931
1972
|
}),
|
|
1932
|
-
paginated.length === 0 && /* @__PURE__ */ jsx5("tr", { children: /* @__PURE__ */ jsx5("td", { colSpan: 3, className: "px-6 py-16 text-center", children: /* @__PURE__ */
|
|
1973
|
+
paginated.length === 0 && /* @__PURE__ */ jsx5("tr", { children: /* @__PURE__ */ jsx5("td", { colSpan: 3, className: "px-6 py-16 text-center", children: /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center gap-3 text-slate-400", children: [
|
|
1933
1974
|
/* @__PURE__ */ jsx5(Inbox, { className: "h-12 w-12 text-slate-200" }),
|
|
1934
1975
|
/* @__PURE__ */ jsx5("p", { className: "text-sm font-medium", children: search ? "No matches." : "No data yet." })
|
|
1935
1976
|
] }) }) })
|
|
1936
1977
|
] })
|
|
1937
1978
|
] }) }),
|
|
1938
|
-
totalPages > 1 && /* @__PURE__ */
|
|
1939
|
-
/* @__PURE__ */
|
|
1979
|
+
totalPages > 1 && /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between text-sm text-slate-500", children: [
|
|
1980
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
1940
1981
|
filtered.length,
|
|
1941
1982
|
" item",
|
|
1942
1983
|
filtered.length !== 1 ? "s" : ""
|
|
1943
1984
|
] }),
|
|
1944
|
-
/* @__PURE__ */
|
|
1985
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
1945
1986
|
/* @__PURE__ */ jsx5(
|
|
1946
1987
|
"button",
|
|
1947
1988
|
{
|
|
@@ -1951,7 +1992,7 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1951
1992
|
children: /* @__PURE__ */ jsx5(ChevronLeft, { className: "h-4 w-4" })
|
|
1952
1993
|
}
|
|
1953
1994
|
),
|
|
1954
|
-
/* @__PURE__ */
|
|
1995
|
+
/* @__PURE__ */ jsxs3("span", { className: "font-medium text-slate-700", children: [
|
|
1955
1996
|
"Page ",
|
|
1956
1997
|
page,
|
|
1957
1998
|
" of ",
|
|
@@ -1972,14 +2013,14 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1972
2013
|
}
|
|
1973
2014
|
function SettingsSection() {
|
|
1974
2015
|
const ctx = useCmsContext();
|
|
1975
|
-
return /* @__PURE__ */ jsx5("div", { className: "flex h-full bg-slate-50 p-8 overflow-y-auto", children: /* @__PURE__ */
|
|
1976
|
-
/* @__PURE__ */
|
|
2016
|
+
return /* @__PURE__ */ jsx5("div", { className: "flex h-full bg-slate-50 p-8 overflow-y-auto", children: /* @__PURE__ */ jsxs3("div", { className: "mx-auto w-full max-w-2xl space-y-8", children: [
|
|
2017
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
1977
2018
|
/* @__PURE__ */ jsx5("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: "System Settings" }),
|
|
1978
2019
|
/* @__PURE__ */ jsx5("p", { className: "text-sm text-slate-500 mt-1", children: "Current configuration and statistics for your CMS instance." })
|
|
1979
2020
|
] }),
|
|
1980
|
-
/* @__PURE__ */
|
|
2021
|
+
/* @__PURE__ */ jsxs3("div", { className: "rounded-2xl border border-slate-200 bg-white shadow-sm overflow-hidden", children: [
|
|
1981
2022
|
/* @__PURE__ */ jsx5("div", { className: "px-6 py-4 border-b border-slate-100 bg-slate-50/50", children: /* @__PURE__ */ jsx5("h3", { className: "font-bold text-slate-800", children: "Configuration Snapshot" }) }),
|
|
1982
|
-
/* @__PURE__ */
|
|
2023
|
+
/* @__PURE__ */ jsxs3("dl", { className: "divide-y divide-slate-100 text-sm", children: [
|
|
1983
2024
|
/* @__PURE__ */ jsx5(Row, { label: "Site Name", value: ctx.config.siteName ?? "\u2014" }),
|
|
1984
2025
|
/* @__PURE__ */ jsx5(Row, { label: "Active Storage Adapter", value: ctx.adapter.name, highlight: true }),
|
|
1985
2026
|
/* @__PURE__ */ jsx5(Row, { label: "Registered Pages", value: String(ctx.config.pages.length) }),
|
|
@@ -2022,10 +2063,10 @@ function ConfigSection() {
|
|
|
2022
2063
|
},
|
|
2023
2064
|
[ctx]
|
|
2024
2065
|
);
|
|
2025
|
-
return /* @__PURE__ */
|
|
2026
|
-
/* @__PURE__ */
|
|
2066
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col lg:flex-row h-full", children: [
|
|
2067
|
+
/* @__PURE__ */ jsxs3("div", { className: "w-full lg:w-72 shrink-0 border-b lg:border-b-0 lg:border-r border-slate-200 bg-white/50 p-3 lg:p-4 overflow-x-auto lg:overflow-y-auto hide-scrollbar", children: [
|
|
2027
2068
|
/* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500 hidden lg:block", children: "Configuration Groups" }),
|
|
2028
|
-
/* @__PURE__ */
|
|
2069
|
+
/* @__PURE__ */ jsxs3("ul", { className: "flex flex-row lg:flex-col space-x-2 lg:space-x-0 lg:space-y-1", children: [
|
|
2029
2070
|
globals.map((g) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 w-32 lg:w-full", children: /* @__PURE__ */ jsx5(
|
|
2030
2071
|
"button",
|
|
2031
2072
|
{
|
|
@@ -2037,14 +2078,14 @@ function ConfigSection() {
|
|
|
2037
2078
|
globals.length === 0 && /* @__PURE__ */ jsx5("li", { className: "px-3 py-6 text-center text-sm text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-200 w-full", children: "No global configurations." })
|
|
2038
2079
|
] })
|
|
2039
2080
|
] }),
|
|
2040
|
-
/* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-auto bg-slate-50 p-6 lg:p-10 relative", children: /* @__PURE__ */
|
|
2041
|
-
/* @__PURE__ */
|
|
2042
|
-
/* @__PURE__ */
|
|
2081
|
+
/* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-auto bg-slate-50 p-6 lg:p-10 relative", children: /* @__PURE__ */ jsxs3("div", { className: "mx-auto w-full max-w-2xl", children: [
|
|
2082
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between mb-8", children: [
|
|
2083
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
2043
2084
|
/* @__PURE__ */ jsx5("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: "Configuration" }),
|
|
2044
2085
|
/* @__PURE__ */ jsx5("p", { className: "text-sm text-slate-500 mt-1", children: "Edit global content like headers and footers." })
|
|
2045
2086
|
] }),
|
|
2046
|
-
/* @__PURE__ */
|
|
2047
|
-
/* @__PURE__ */
|
|
2087
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
2088
|
+
/* @__PURE__ */ jsxs3(
|
|
2048
2089
|
"button",
|
|
2049
2090
|
{
|
|
2050
2091
|
onClick: () => ctx.reset(),
|
|
@@ -2056,7 +2097,7 @@ function ConfigSection() {
|
|
|
2056
2097
|
]
|
|
2057
2098
|
}
|
|
2058
2099
|
),
|
|
2059
|
-
/* @__PURE__ */
|
|
2100
|
+
/* @__PURE__ */ jsxs3(
|
|
2060
2101
|
"button",
|
|
2061
2102
|
{
|
|
2062
2103
|
onClick: () => ctx.save(),
|
|
@@ -2070,7 +2111,7 @@ function ConfigSection() {
|
|
|
2070
2111
|
)
|
|
2071
2112
|
] })
|
|
2072
2113
|
] }),
|
|
2073
|
-
selectedGroup ? /* @__PURE__ */
|
|
2114
|
+
selectedGroup ? /* @__PURE__ */ jsxs3("div", { className: "space-y-4", children: [
|
|
2074
2115
|
/* @__PURE__ */ jsx5("h3", { className: "font-bold text-slate-800 text-lg", children: selectedGroup.label }),
|
|
2075
2116
|
/* @__PURE__ */ jsx5("div", { className: "rounded-2xl border border-slate-200 bg-white shadow-sm overflow-hidden divide-y divide-slate-100", children: selectedGroup.fields.map((field) => /* @__PURE__ */ jsx5("div", { className: "p-4", children: /* @__PURE__ */ jsx5(
|
|
2076
2117
|
FieldEditor,
|
|
@@ -2083,7 +2124,7 @@ function ConfigSection() {
|
|
|
2083
2124
|
}
|
|
2084
2125
|
}
|
|
2085
2126
|
) }, field.id)) })
|
|
2086
|
-
] }) : /* @__PURE__ */
|
|
2127
|
+
] }) : /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center justify-center p-16 text-center border-2 border-dashed border-slate-200 rounded-2xl bg-white/50", children: [
|
|
2087
2128
|
/* @__PURE__ */ jsx5(SettingsIcon, { className: "w-12 h-12 text-slate-300 mb-4" }),
|
|
2088
2129
|
/* @__PURE__ */ jsx5("p", { className: "text-slate-500 font-medium", children: "Select a setting group on the left to edit." })
|
|
2089
2130
|
] })
|
|
@@ -2096,7 +2137,7 @@ function Row({
|
|
|
2096
2137
|
highlight,
|
|
2097
2138
|
status
|
|
2098
2139
|
}) {
|
|
2099
|
-
return /* @__PURE__ */
|
|
2140
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between px-6 py-4 hover:bg-slate-50/50 transition-colors", children: [
|
|
2100
2141
|
/* @__PURE__ */ jsx5("dt", { className: "text-slate-500 font-medium", children: label }),
|
|
2101
2142
|
/* @__PURE__ */ jsx5("dd", { className: `font-semibold ${highlight ? "text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded" : status === "warning" ? "text-amber-600" : status === "success" ? "text-emerald-600" : "text-slate-900"}`, children: value })
|
|
2102
2143
|
] });
|
|
@@ -2107,8 +2148,8 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2107
2148
|
const filtered = options.filter((o) => o.toLowerCase().includes(search.toLowerCase()));
|
|
2108
2149
|
const capped = filtered.slice(0, 80);
|
|
2109
2150
|
const SelectedIcon = iconMap && value ? iconMap[value] : null;
|
|
2110
|
-
return /* @__PURE__ */
|
|
2111
|
-
/* @__PURE__ */
|
|
2151
|
+
return /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
|
|
2152
|
+
/* @__PURE__ */ jsxs3(
|
|
2112
2153
|
"button",
|
|
2113
2154
|
{
|
|
2114
2155
|
type: "button",
|
|
@@ -2118,7 +2159,7 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2118
2159
|
},
|
|
2119
2160
|
className: "w-full flex items-center justify-between rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm hover:border-slate-300 focus:border-indigo-500 bg-white transition-colors",
|
|
2120
2161
|
children: [
|
|
2121
|
-
/* @__PURE__ */
|
|
2162
|
+
/* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-2 truncate", children: [
|
|
2122
2163
|
SelectedIcon && /* @__PURE__ */ jsx5(SelectedIcon, { className: "w-4 h-4 text-indigo-600 shrink-0" }),
|
|
2123
2164
|
/* @__PURE__ */ jsx5("span", { className: "truncate", children: value || placeholder || "Select..." })
|
|
2124
2165
|
] }),
|
|
@@ -2126,10 +2167,10 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2126
2167
|
]
|
|
2127
2168
|
}
|
|
2128
2169
|
),
|
|
2129
|
-
open && /* @__PURE__ */
|
|
2170
|
+
open && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2130
2171
|
/* @__PURE__ */ jsx5("div", { className: "fixed inset-0 z-[100]", onClick: () => setOpen(false) }),
|
|
2131
|
-
/* @__PURE__ */
|
|
2132
|
-
/* @__PURE__ */
|
|
2172
|
+
/* @__PURE__ */ jsxs3("div", { className: "absolute z-[101] mt-1 w-full rounded-xl border border-slate-200 bg-white shadow-2xl max-h-72 flex flex-col overflow-hidden animate-in fade-in slide-in-from-top-1 duration-150", children: [
|
|
2173
|
+
/* @__PURE__ */ jsxs3("div", { className: "p-2 border-b border-slate-100 flex items-center gap-2", children: [
|
|
2133
2174
|
/* @__PURE__ */ jsx5(Search, { className: "w-4 h-4 text-slate-400 shrink-0" }),
|
|
2134
2175
|
/* @__PURE__ */ jsx5(
|
|
2135
2176
|
"input",
|
|
@@ -2144,15 +2185,15 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2144
2185
|
),
|
|
2145
2186
|
search && /* @__PURE__ */ jsx5("span", { className: "text-[10px] font-bold text-slate-400 bg-slate-100 px-1.5 py-0.5 rounded-full shrink-0 tabular-nums", children: filtered.length })
|
|
2146
2187
|
] }),
|
|
2147
|
-
/* @__PURE__ */
|
|
2148
|
-
filtered.length === 0 && /* @__PURE__ */
|
|
2188
|
+
/* @__PURE__ */ jsxs3("div", { className: "overflow-y-auto flex-1 p-1", children: [
|
|
2189
|
+
filtered.length === 0 && /* @__PURE__ */ jsxs3("div", { className: "p-4 text-xs text-slate-500 text-center", children: [
|
|
2149
2190
|
'No results for "',
|
|
2150
2191
|
search,
|
|
2151
2192
|
'"'
|
|
2152
2193
|
] }),
|
|
2153
2194
|
capped.map((opt) => {
|
|
2154
2195
|
const OptIcon = iconMap ? iconMap[opt] : null;
|
|
2155
|
-
return /* @__PURE__ */
|
|
2196
|
+
return /* @__PURE__ */ jsxs3(
|
|
2156
2197
|
"button",
|
|
2157
2198
|
{
|
|
2158
2199
|
type: "button",
|
|
@@ -2169,7 +2210,7 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2169
2210
|
opt
|
|
2170
2211
|
);
|
|
2171
2212
|
}),
|
|
2172
|
-
filtered.length > 80 && /* @__PURE__ */
|
|
2213
|
+
filtered.length > 80 && /* @__PURE__ */ jsxs3("div", { className: "px-3 py-2 text-[10px] text-slate-400 text-center border-t border-slate-100 mt-1", children: [
|
|
2173
2214
|
"Showing 80 of ",
|
|
2174
2215
|
filtered.length,
|
|
2175
2216
|
" \u2014 type to narrow results"
|
|
@@ -2184,7 +2225,7 @@ function PasswordField({ value, onChange }) {
|
|
|
2184
2225
|
const isHash = value.startsWith("$2a$") || value.startsWith("$2b$");
|
|
2185
2226
|
const [displayValue, setDisplayValue] = useState4(isHash ? "" : value);
|
|
2186
2227
|
const [pristine, setPristine] = useState4(isHash);
|
|
2187
|
-
return /* @__PURE__ */
|
|
2228
|
+
return /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
|
|
2188
2229
|
/* @__PURE__ */ jsx5(
|
|
2189
2230
|
"input",
|
|
2190
2231
|
{
|
|
@@ -2214,7 +2255,7 @@ function PasswordField({ value, onChange }) {
|
|
|
2214
2255
|
// src/admin/AdminLogin.tsx
|
|
2215
2256
|
import { useState as useState5, useEffect as useEffect5 } from "react";
|
|
2216
2257
|
import { Lock, UserPlus } from "lucide-react";
|
|
2217
|
-
import { jsx as jsx6, jsxs as
|
|
2258
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2218
2259
|
function AdminLogin({
|
|
2219
2260
|
authApiRoute = "/api/admin/auth",
|
|
2220
2261
|
redirectRoute = "/admin"
|
|
@@ -2260,19 +2301,19 @@ function AdminLogin({
|
|
|
2260
2301
|
}
|
|
2261
2302
|
};
|
|
2262
2303
|
if (view === "checking") {
|
|
2263
|
-
return /* @__PURE__ */ jsx6("div", { className: "min-h-screen flex items-center justify-center bg-slate-50 p-4", children: /* @__PURE__ */
|
|
2304
|
+
return /* @__PURE__ */ jsx6("div", { className: "min-h-screen flex items-center justify-center bg-slate-50 p-4", children: /* @__PURE__ */ jsxs4("svg", { className: "animate-spin h-8 w-8 text-indigo-600", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2264
2305
|
/* @__PURE__ */ jsx6("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2265
2306
|
/* @__PURE__ */ jsx6("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
2266
2307
|
] }) });
|
|
2267
2308
|
}
|
|
2268
|
-
return /* @__PURE__ */ jsx6("div", { className: "min-h-screen flex items-center justify-center bg-slate-50 p-4", children: /* @__PURE__ */
|
|
2269
|
-
/* @__PURE__ */
|
|
2309
|
+
return /* @__PURE__ */ jsx6("div", { className: "min-h-screen flex items-center justify-center bg-slate-50 p-4", children: /* @__PURE__ */ jsxs4("div", { className: "max-w-md w-full bg-white rounded-2xl shadow-xl border border-slate-100 overflow-hidden", children: [
|
|
2310
|
+
/* @__PURE__ */ jsxs4("div", { className: "p-8", children: [
|
|
2270
2311
|
/* @__PURE__ */ jsx6("div", { className: "w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mx-auto mb-6", children: view === "register" ? /* @__PURE__ */ jsx6(UserPlus, { className: "w-6 h-6 text-indigo-600" }) : /* @__PURE__ */ jsx6(Lock, { className: "w-6 h-6 text-indigo-600" }) }),
|
|
2271
2312
|
/* @__PURE__ */ jsx6("h1", { className: "text-2xl font-bold text-slate-900 text-center mb-2", children: view === "register" ? "Create Admin Account" : "Admin Login" }),
|
|
2272
2313
|
/* @__PURE__ */ jsx6("p", { className: "text-sm text-slate-500 text-center mb-8", children: view === "register" ? "No admin users found. Create the first admin account to get started." : "Sign in to manage your content." }),
|
|
2273
2314
|
error && /* @__PURE__ */ jsx6("div", { className: "mb-6 bg-red-50 text-red-700 p-3 rounded-lg text-sm border border-red-100", children: error }),
|
|
2274
|
-
/* @__PURE__ */
|
|
2275
|
-
/* @__PURE__ */
|
|
2315
|
+
/* @__PURE__ */ jsxs4("form", { onSubmit: handleSubmit, className: "space-y-5", children: [
|
|
2316
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
2276
2317
|
/* @__PURE__ */ jsx6("label", { className: "block text-sm font-medium text-slate-700 mb-1.5", children: "Email Address" }),
|
|
2277
2318
|
/* @__PURE__ */ jsx6(
|
|
2278
2319
|
"input",
|
|
@@ -2286,7 +2327,7 @@ function AdminLogin({
|
|
|
2286
2327
|
}
|
|
2287
2328
|
)
|
|
2288
2329
|
] }),
|
|
2289
|
-
/* @__PURE__ */
|
|
2330
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
2290
2331
|
/* @__PURE__ */ jsx6("label", { className: "block text-sm font-medium text-slate-700 mb-1.5", children: "Password" }),
|
|
2291
2332
|
/* @__PURE__ */ jsx6(
|
|
2292
2333
|
"input",
|
|
@@ -2306,7 +2347,7 @@ function AdminLogin({
|
|
|
2306
2347
|
type: "submit",
|
|
2307
2348
|
disabled: loading,
|
|
2308
2349
|
className: "w-full bg-indigo-600 text-white font-semibold rounded-xl px-4 py-3 hover:bg-indigo-700 focus:outline-none focus:ring-4 focus:ring-indigo-500/20 transition-all shadow-md disabled:opacity-70 flex justify-center items-center",
|
|
2309
|
-
children: loading ? /* @__PURE__ */
|
|
2350
|
+
children: loading ? /* @__PURE__ */ jsxs4("svg", { className: "animate-spin h-5 w-5 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2310
2351
|
/* @__PURE__ */ jsx6("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2311
2352
|
/* @__PURE__ */ jsx6("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
2312
2353
|
] }) : view === "register" ? "Create Account" : "Sign In"
|