admin-lib-cms 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -4
- package/dist/chunk-WBQAMGXK.mjs +0 -0
- package/dist/index.d.mts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +363 -320
- package/dist/index.mjs +508 -464
- package/dist/types.mjs +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import "./chunk-WBQAMGXK.mjs";
|
|
2
3
|
import {
|
|
3
4
|
generateDefaultTemplate,
|
|
4
5
|
sendEmailNotification
|
|
@@ -6,38 +7,263 @@ import {
|
|
|
6
7
|
|
|
7
8
|
// src/provider.tsx
|
|
8
9
|
import {
|
|
9
|
-
createContext,
|
|
10
|
-
useCallback,
|
|
11
|
-
useContext,
|
|
12
|
-
useEffect,
|
|
10
|
+
createContext as createContext2,
|
|
11
|
+
useCallback as useCallback2,
|
|
12
|
+
useContext as useContext2,
|
|
13
|
+
useEffect as useEffect2,
|
|
13
14
|
useMemo,
|
|
14
15
|
useRef,
|
|
15
|
-
useState
|
|
16
|
+
useState as useState3
|
|
16
17
|
} from "react";
|
|
18
|
+
|
|
19
|
+
// src/subscription/SubscriptionProvider.tsx
|
|
20
|
+
import { createContext, useContext, useState, useCallback, useEffect } from "react";
|
|
17
21
|
import { jsx } from "react/jsx-runtime";
|
|
18
|
-
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);
|
|
19
220
|
function useCmsContext() {
|
|
20
|
-
const ctx =
|
|
221
|
+
const ctx = useContext2(CmsContext);
|
|
21
222
|
if (!ctx) throw new Error("useCms must be used inside <CmsProvider>");
|
|
22
223
|
return ctx;
|
|
23
224
|
}
|
|
24
225
|
function useCmsOptional() {
|
|
25
|
-
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 });
|
|
26
252
|
}
|
|
27
|
-
function
|
|
28
|
-
const [overrides, setOverrides] =
|
|
29
|
-
const [savedOverrides, setSavedOverrides] =
|
|
30
|
-
const [selectedId, setSelectedIdRaw] =
|
|
31
|
-
const [editMode, setEditMode] =
|
|
32
|
-
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);
|
|
33
259
|
const registryRef = useRef(/* @__PURE__ */ new Map());
|
|
34
|
-
|
|
260
|
+
useEffect2(() => {
|
|
35
261
|
if (typeof window === "undefined" || typeof BroadcastChannel === "undefined") return;
|
|
36
262
|
const bc = new BroadcastChannel("admin-cms:collection-changed");
|
|
37
263
|
bc.onmessage = () => setCollectionChangedAt(Date.now());
|
|
38
264
|
return () => bc.close();
|
|
39
265
|
}, []);
|
|
40
|
-
const notifyCollectionChanged =
|
|
266
|
+
const notifyCollectionChanged = useCallback2(() => {
|
|
41
267
|
setCollectionChangedAt(Date.now());
|
|
42
268
|
if (typeof BroadcastChannel !== "undefined") {
|
|
43
269
|
const bc = new BroadcastChannel("admin-cms:collection-changed");
|
|
@@ -45,12 +271,12 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
45
271
|
bc.close();
|
|
46
272
|
}
|
|
47
273
|
}, []);
|
|
48
|
-
|
|
274
|
+
useEffect2(() => {
|
|
49
275
|
if (typeof window === "undefined") return;
|
|
50
276
|
const params = new URLSearchParams(window.location.search);
|
|
51
277
|
if (params.get("__cms") === "edit") setEditMode(true);
|
|
52
278
|
}, []);
|
|
53
|
-
|
|
279
|
+
useEffect2(() => {
|
|
54
280
|
let cancelled = false;
|
|
55
281
|
adapter.getOverrides().then((o) => {
|
|
56
282
|
if (cancelled) return;
|
|
@@ -61,7 +287,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
61
287
|
cancelled = true;
|
|
62
288
|
};
|
|
63
289
|
}, [adapter]);
|
|
64
|
-
|
|
290
|
+
useEffect2(() => {
|
|
65
291
|
if (!editMode || typeof window === "undefined") return;
|
|
66
292
|
const parent = window.parent;
|
|
67
293
|
if (!parent || parent === window) return;
|
|
@@ -79,7 +305,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
79
305
|
window.addEventListener("message", onMsg);
|
|
80
306
|
return () => window.removeEventListener("message", onMsg);
|
|
81
307
|
}, [editMode]);
|
|
82
|
-
const setSelectedId =
|
|
308
|
+
const setSelectedId = useCallback2(
|
|
83
309
|
(id) => {
|
|
84
310
|
setSelectedIdRaw(id);
|
|
85
311
|
if (editMode && typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
@@ -91,7 +317,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
91
317
|
},
|
|
92
318
|
[editMode]
|
|
93
319
|
);
|
|
94
|
-
const registerEditable =
|
|
320
|
+
const registerEditable = useCallback2((meta) => {
|
|
95
321
|
registryRef.current.set(meta.id, meta);
|
|
96
322
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
97
323
|
window.parent.postMessage(
|
|
@@ -104,7 +330,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
104
330
|
);
|
|
105
331
|
}
|
|
106
332
|
}, []);
|
|
107
|
-
const unregisterEditable =
|
|
333
|
+
const unregisterEditable = useCallback2((id) => {
|
|
108
334
|
registryRef.current.delete(id);
|
|
109
335
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
110
336
|
window.parent.postMessage(
|
|
@@ -117,14 +343,14 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
117
343
|
);
|
|
118
344
|
}
|
|
119
345
|
}, []);
|
|
120
|
-
const setOverride =
|
|
346
|
+
const setOverride = useCallback2((id, value2) => {
|
|
121
347
|
setOverrides((prev) => ({ ...prev, [id]: value2 }));
|
|
122
348
|
}, []);
|
|
123
|
-
const save =
|
|
349
|
+
const save = useCallback2(async () => {
|
|
124
350
|
await adapter.setOverrides(overrides);
|
|
125
351
|
setSavedOverrides(overrides);
|
|
126
352
|
}, [adapter, overrides]);
|
|
127
|
-
const reset =
|
|
353
|
+
const reset = useCallback2(
|
|
128
354
|
async (id) => {
|
|
129
355
|
if (id) {
|
|
130
356
|
setOverrides((prev) => {
|
|
@@ -142,7 +368,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
142
368
|
() => JSON.stringify(overrides) !== JSON.stringify(savedOverrides),
|
|
143
369
|
[overrides, savedOverrides]
|
|
144
370
|
);
|
|
145
|
-
const getRegistered =
|
|
371
|
+
const getRegistered = useCallback2(
|
|
146
372
|
() => Array.from(registryRef.current.values()),
|
|
147
373
|
[]
|
|
148
374
|
);
|
|
@@ -165,10 +391,10 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
165
391
|
collectionChangedAt,
|
|
166
392
|
notifyCollectionChanged
|
|
167
393
|
}), [config, adapter, overrides, editMode, selectedId, setSelectedId, setOverride, registerEditable, unregisterEditable, getRegistered, save, reset, isDirty, iconMap, collectionChangedAt, notifyCollectionChanged]);
|
|
168
|
-
return /* @__PURE__ */
|
|
394
|
+
return /* @__PURE__ */ jsx3(CmsContext.Provider, { value, children });
|
|
169
395
|
}
|
|
170
396
|
function useSubmit(formId) {
|
|
171
|
-
const ctx =
|
|
397
|
+
const ctx = useContext2(CmsContext);
|
|
172
398
|
return async (data) => {
|
|
173
399
|
const submission = {
|
|
174
400
|
id: crypto.randomUUID(),
|
|
@@ -195,11 +421,11 @@ function useSubmit(formId) {
|
|
|
195
421
|
}
|
|
196
422
|
|
|
197
423
|
// src/editable.tsx
|
|
198
|
-
import { createElement, useEffect as
|
|
199
|
-
import { jsx as
|
|
424
|
+
import { createElement, useEffect as useEffect3 } from "react";
|
|
425
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
200
426
|
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength) {
|
|
201
427
|
const ctx = useCmsOptional();
|
|
202
|
-
|
|
428
|
+
useEffect3(() => {
|
|
203
429
|
if (!ctx) return;
|
|
204
430
|
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength });
|
|
205
431
|
return () => ctx.unregisterEditable(id);
|
|
@@ -263,7 +489,7 @@ function EditableImage({
|
|
|
263
489
|
e.stopPropagation();
|
|
264
490
|
ctx.setSelectedId(id);
|
|
265
491
|
};
|
|
266
|
-
return /* @__PURE__ */
|
|
492
|
+
return /* @__PURE__ */ jsx4(
|
|
267
493
|
"img",
|
|
268
494
|
{
|
|
269
495
|
src: value,
|
|
@@ -283,13 +509,15 @@ function EditableLink({
|
|
|
283
509
|
pageId,
|
|
284
510
|
href,
|
|
285
511
|
children,
|
|
512
|
+
text,
|
|
286
513
|
className,
|
|
287
514
|
target
|
|
288
515
|
}) {
|
|
289
|
-
const
|
|
516
|
+
const defaultText = text ?? (typeof children === "string" ? children : "");
|
|
517
|
+
const ctx = useRegister(id, "link", label, section, pageId, { href, text: defaultText });
|
|
290
518
|
const override = ctx?.overrides[id];
|
|
291
519
|
const hrefValue = override?.href ?? href;
|
|
292
|
-
const textValue = override?.text ??
|
|
520
|
+
const textValue = override?.text ?? defaultText;
|
|
293
521
|
const active = !!ctx?.editMode;
|
|
294
522
|
const selected = ctx?.selectedId === id;
|
|
295
523
|
const onClick = (e) => {
|
|
@@ -301,7 +529,7 @@ function EditableLink({
|
|
|
301
529
|
const isExternal = hrefValue.startsWith("http");
|
|
302
530
|
const computedTarget = target || (isExternal ? "_blank" : void 0);
|
|
303
531
|
const computedRel = computedTarget === "_blank" ? "noopener noreferrer" : void 0;
|
|
304
|
-
return /* @__PURE__ */
|
|
532
|
+
return /* @__PURE__ */ jsx4(
|
|
305
533
|
"a",
|
|
306
534
|
{
|
|
307
535
|
href: hrefValue,
|
|
@@ -310,7 +538,7 @@ function EditableLink({
|
|
|
310
538
|
"data-cms-id": id,
|
|
311
539
|
onClick: active ? onClick : void 0,
|
|
312
540
|
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
313
|
-
children: textValue
|
|
541
|
+
children: typeof children !== "undefined" ? children : textValue
|
|
314
542
|
}
|
|
315
543
|
);
|
|
316
544
|
}
|
|
@@ -338,13 +566,13 @@ function EditableList({
|
|
|
338
566
|
e.stopPropagation();
|
|
339
567
|
ctx.setSelectedId(id);
|
|
340
568
|
};
|
|
341
|
-
return /* @__PURE__ */
|
|
569
|
+
return /* @__PURE__ */ jsx4(
|
|
342
570
|
"div",
|
|
343
571
|
{
|
|
344
572
|
"data-cms-id": id,
|
|
345
573
|
onClick: active ? onClick : void 0,
|
|
346
574
|
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
347
|
-
children: renderList ? renderList(value) : /* @__PURE__ */
|
|
575
|
+
children: renderList ? renderList(value) : /* @__PURE__ */ jsx4("div", { className: listClassName, children: renderItem && value.map(renderItem) })
|
|
348
576
|
}
|
|
349
577
|
);
|
|
350
578
|
}
|
|
@@ -379,196 +607,7 @@ import {
|
|
|
379
607
|
LogOut
|
|
380
608
|
} from "lucide-react";
|
|
381
609
|
import { CreditCard as CreditCard2 } from "lucide-react";
|
|
382
|
-
|
|
383
|
-
// src/subscription/SubscriptionProvider.tsx
|
|
384
|
-
import { createContext as createContext2, useContext as useContext2, useState as useState2, useCallback as useCallback2, useEffect as useEffect3 } from "react";
|
|
385
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
386
|
-
var SubscriptionContext = createContext2(void 0);
|
|
387
|
-
function useSubscriptionContext() {
|
|
388
|
-
const ctx = useContext2(SubscriptionContext);
|
|
389
|
-
if (!ctx) {
|
|
390
|
-
throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
|
|
391
|
-
}
|
|
392
|
-
return ctx;
|
|
393
|
-
}
|
|
394
|
-
function useSubscription() {
|
|
395
|
-
return useSubscriptionContext();
|
|
396
|
-
}
|
|
397
|
-
function SubscriptionProvider({
|
|
398
|
-
children,
|
|
399
|
-
apiUrl,
|
|
400
|
-
projectId,
|
|
401
|
-
email
|
|
402
|
-
}) {
|
|
403
|
-
const [subscription, setSubscription] = useState2(null);
|
|
404
|
-
const [loading, setLoading] = useState2(true);
|
|
405
|
-
const [error, setError] = useState2(null);
|
|
406
|
-
const fetchSubscription = useCallback2(
|
|
407
|
-
async (silent = false) => {
|
|
408
|
-
if (!apiUrl || !projectId) {
|
|
409
|
-
setLoading(false);
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
if (!silent) setLoading(true);
|
|
413
|
-
setError(null);
|
|
414
|
-
try {
|
|
415
|
-
const res = await fetch(`${apiUrl}/api/validate-subscription`, {
|
|
416
|
-
method: "POST",
|
|
417
|
-
headers: { "Content-Type": "application/json" },
|
|
418
|
-
body: JSON.stringify({ projectId })
|
|
419
|
-
});
|
|
420
|
-
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
421
|
-
const data = await res.json();
|
|
422
|
-
setSubscription({
|
|
423
|
-
subscriptionStatus: data.valid ? data.status : "inactive",
|
|
424
|
-
currentPeriodEnd: data.expiryDate,
|
|
425
|
-
customerEmail: email,
|
|
426
|
-
subscriptionId: data._id,
|
|
427
|
-
stripeCustomerId: data.stripeCustomerId,
|
|
428
|
-
stripePaymentLink: data.stripePaymentLink,
|
|
429
|
-
valid: data.valid
|
|
430
|
-
});
|
|
431
|
-
} catch (err) {
|
|
432
|
-
console.error("SubscriptionProvider Error:", err);
|
|
433
|
-
setError(err.message || "Failed to fetch subscription");
|
|
434
|
-
setSubscription({ subscriptionStatus: "active", valid: true });
|
|
435
|
-
} finally {
|
|
436
|
-
setLoading(false);
|
|
437
|
-
}
|
|
438
|
-
},
|
|
439
|
-
[apiUrl, projectId, email]
|
|
440
|
-
);
|
|
441
|
-
useEffect3(() => {
|
|
442
|
-
fetchSubscription();
|
|
443
|
-
const handleFocus = () => {
|
|
444
|
-
fetchSubscription(true);
|
|
445
|
-
};
|
|
446
|
-
window.addEventListener("focus", handleFocus);
|
|
447
|
-
let intervalId;
|
|
448
|
-
if (subscription && !subscription.valid) {
|
|
449
|
-
intervalId = setInterval(() => {
|
|
450
|
-
fetchSubscription(true);
|
|
451
|
-
}, 1e4);
|
|
452
|
-
}
|
|
453
|
-
return () => {
|
|
454
|
-
window.removeEventListener("focus", handleFocus);
|
|
455
|
-
if (intervalId) clearInterval(intervalId);
|
|
456
|
-
};
|
|
457
|
-
}, [fetchSubscription, subscription?.valid]);
|
|
458
|
-
const value = {
|
|
459
|
-
subscription,
|
|
460
|
-
loading,
|
|
461
|
-
error,
|
|
462
|
-
refetch: fetchSubscription,
|
|
463
|
-
isSubscriptionActive: subscription?.valid ?? true,
|
|
464
|
-
config: { apiUrl, projectId }
|
|
465
|
-
};
|
|
466
|
-
return /* @__PURE__ */ jsx3(SubscriptionContext.Provider, { value, children });
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// src/subscription/SubscriptionPage.tsx
|
|
470
|
-
import { useState as useState3 } from "react";
|
|
471
|
-
import { CreditCard, ExternalLink, Settings, AlertTriangle, CheckCircle2 } from "lucide-react";
|
|
472
|
-
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
473
|
-
function SubscriptionPage() {
|
|
474
|
-
const { subscription, loading, config } = useSubscription();
|
|
475
|
-
const [actionLoading, setActionLoading] = useState3(null);
|
|
476
|
-
const status = subscription?.subscriptionStatus || "inactive";
|
|
477
|
-
const isValid = subscription?.valid ?? false;
|
|
478
|
-
const handleSubscribe = () => {
|
|
479
|
-
if (!subscription?.stripePaymentLink) {
|
|
480
|
-
alert("No payment link found. Please contact support.");
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
const raw = subscription.stripePaymentLink;
|
|
484
|
-
const url = raw.startsWith("http") ? raw : `https://buy.stripe.com/${raw}`;
|
|
485
|
-
window.open(url, "_blank");
|
|
486
|
-
};
|
|
487
|
-
const handleManageBilling = async () => {
|
|
488
|
-
if (!subscription?.stripeCustomerId) {
|
|
489
|
-
alert("No customer ID available. Please contact support.");
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
setActionLoading("billing");
|
|
493
|
-
try {
|
|
494
|
-
const returnUrl = window.location.href;
|
|
495
|
-
const apiUrl = config.apiUrl || "https://dev-soft-admin-sigma.vercel.app";
|
|
496
|
-
const res = await fetch(`${apiUrl}/api/create-billing-session`, {
|
|
497
|
-
method: "POST",
|
|
498
|
-
headers: { "Content-Type": "application/json" },
|
|
499
|
-
body: JSON.stringify({
|
|
500
|
-
customerId: subscription.stripeCustomerId,
|
|
501
|
-
returnUrl
|
|
502
|
-
})
|
|
503
|
-
});
|
|
504
|
-
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
505
|
-
const data = await res.json();
|
|
506
|
-
if (data.url) {
|
|
507
|
-
window.open(data.url, "_blank");
|
|
508
|
-
} else {
|
|
509
|
-
alert("Could not create billing session.");
|
|
510
|
-
}
|
|
511
|
-
} catch (err) {
|
|
512
|
-
alert(`Portal failed: ${err.message}`);
|
|
513
|
-
} finally {
|
|
514
|
-
setActionLoading(null);
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
if (loading && !subscription) {
|
|
518
|
-
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: [
|
|
519
|
-
/* @__PURE__ */ jsx4("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-indigo-200 border-t-indigo-600" }),
|
|
520
|
-
/* @__PURE__ */ jsx4("p", { className: "text-sm font-medium", children: "Verifying subscription..." })
|
|
521
|
-
] }) });
|
|
522
|
-
}
|
|
523
|
-
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: [
|
|
524
|
-
/* @__PURE__ */ jsxs("div", { className: `p-8 text-center ${isValid ? "bg-emerald-50" : "bg-rose-50"}`, children: [
|
|
525
|
-
/* @__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" }) }),
|
|
526
|
-
/* @__PURE__ */ jsx4("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: isValid ? "Subscription Active" : "Subscription Inactive" }),
|
|
527
|
-
/* @__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." })
|
|
528
|
-
] }),
|
|
529
|
-
/* @__PURE__ */ jsxs("div", { className: "p-8", children: [
|
|
530
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
531
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
532
|
-
/* @__PURE__ */ jsx4("span", { className: "text-sm font-medium text-slate-500", children: "Status" }),
|
|
533
|
-
/* @__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 })
|
|
534
|
-
] }),
|
|
535
|
-
subscription?.currentPeriodEnd && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
536
|
-
/* @__PURE__ */ jsx4("span", { className: "text-sm font-medium text-slate-500", children: "Next Billing Date" }),
|
|
537
|
-
/* @__PURE__ */ jsx4("span", { className: "text-sm font-semibold text-slate-900", children: new Date(subscription.currentPeriodEnd).toLocaleDateString() })
|
|
538
|
-
] })
|
|
539
|
-
] }),
|
|
540
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-8 space-y-3", children: [
|
|
541
|
-
!isValid && /* @__PURE__ */ jsxs(
|
|
542
|
-
"button",
|
|
543
|
-
{
|
|
544
|
-
onClick: handleSubscribe,
|
|
545
|
-
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",
|
|
546
|
-
children: [
|
|
547
|
-
/* @__PURE__ */ jsx4(CreditCard, { className: "h-4 w-4" }),
|
|
548
|
-
"Pay Now to Restore Access",
|
|
549
|
-
/* @__PURE__ */ jsx4(ExternalLink, { className: "h-3.5 w-3.5 opacity-70 transition-transform group-hover:translate-x-0.5" })
|
|
550
|
-
]
|
|
551
|
-
}
|
|
552
|
-
),
|
|
553
|
-
/* @__PURE__ */ jsxs(
|
|
554
|
-
"button",
|
|
555
|
-
{
|
|
556
|
-
onClick: handleManageBilling,
|
|
557
|
-
disabled: actionLoading === "billing",
|
|
558
|
-
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",
|
|
559
|
-
children: [
|
|
560
|
-
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" }),
|
|
561
|
-
"Manage Billing & Invoices"
|
|
562
|
-
]
|
|
563
|
-
}
|
|
564
|
-
)
|
|
565
|
-
] })
|
|
566
|
-
] })
|
|
567
|
-
] }) });
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// src/admin/AdminApp.tsx
|
|
571
|
-
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";
|
|
572
611
|
async function handleImageFile(file, onUrl, uploadImage) {
|
|
573
612
|
if (uploadImage) {
|
|
574
613
|
try {
|
|
@@ -598,106 +637,111 @@ function AdminAppContent() {
|
|
|
598
637
|
} catch (e) {
|
|
599
638
|
}
|
|
600
639
|
const isSubscriptionActive = subscriptionCtx?.isSubscriptionActive ?? true;
|
|
640
|
+
const daysOverdue = subscriptionCtx?.daysOverdue ?? 0;
|
|
601
641
|
if (!isSubscriptionActive) {
|
|
602
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, {}) });
|
|
603
643
|
}
|
|
604
|
-
return /* @__PURE__ */
|
|
605
|
-
/* @__PURE__ */ jsx5("div", { className: "
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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" })
|
|
614
659
|
] }),
|
|
615
|
-
/* @__PURE__ */
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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
|
-
/* @__PURE__ */ jsxs2("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: [
|
|
674
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between text-xs text-slate-500 mb-4", children: [
|
|
675
|
-
/* @__PURE__ */ jsx5("span", { children: "Storage Adapter" }),
|
|
676
|
-
/* @__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
|
+
)
|
|
677
715
|
] }),
|
|
678
|
-
/* @__PURE__ */
|
|
679
|
-
"
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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, {})
|
|
692
744
|
] })
|
|
693
|
-
] }),
|
|
694
|
-
/* @__PURE__ */ jsxs2("main", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
|
|
695
|
-
section === "pages" && /* @__PURE__ */ jsx5(PagesSection, {}),
|
|
696
|
-
section === "collections" && /* @__PURE__ */ jsx5(CollectionsSection, {}),
|
|
697
|
-
section === "submissions" && /* @__PURE__ */ jsx5(SubmissionsSection, {}),
|
|
698
|
-
section === "config" && /* @__PURE__ */ jsx5(ConfigSection, {}),
|
|
699
|
-
section === "settings" && /* @__PURE__ */ jsx5(SettingsSection, {}),
|
|
700
|
-
section === "subscription" && /* @__PURE__ */ jsx5(SubscriptionPage, {})
|
|
701
745
|
] })
|
|
702
746
|
] });
|
|
703
747
|
}
|
|
@@ -707,7 +751,7 @@ function SideItem({
|
|
|
707
751
|
icon,
|
|
708
752
|
children
|
|
709
753
|
}) {
|
|
710
|
-
return /* @__PURE__ */
|
|
754
|
+
return /* @__PURE__ */ jsxs3(
|
|
711
755
|
"button",
|
|
712
756
|
{
|
|
713
757
|
onClick,
|
|
@@ -725,10 +769,10 @@ function PagesSection() {
|
|
|
725
769
|
ctx.config.pages[0] ?? null
|
|
726
770
|
);
|
|
727
771
|
const [showList, setShowList] = useState4(true);
|
|
728
|
-
return /* @__PURE__ */
|
|
729
|
-
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: [
|
|
730
774
|
/* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500 hidden lg:block", children: "Pages" }),
|
|
731
|
-
/* @__PURE__ */
|
|
775
|
+
/* @__PURE__ */ jsxs3("ul", { className: "flex flex-row lg:flex-col space-x-2 lg:space-x-0 lg:space-y-1", children: [
|
|
732
776
|
ctx.config.pages.map((p) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 w-32 lg:w-full", children: /* @__PURE__ */ jsx5(
|
|
733
777
|
"button",
|
|
734
778
|
{
|
|
@@ -799,21 +843,21 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
799
843
|
);
|
|
800
844
|
const selectedMeta = registered.find((r) => r.id === selectedId) ?? null;
|
|
801
845
|
const [viewMode, setViewMode] = useState4("desktop");
|
|
802
|
-
return /* @__PURE__ */
|
|
803
|
-
/* @__PURE__ */
|
|
804
|
-
/* @__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: [
|
|
805
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" }) }),
|
|
806
850
|
/* @__PURE__ */ jsx5("span", { className: "font-bold text-slate-800 text-sm md:text-base", children: page.name }),
|
|
807
851
|
/* @__PURE__ */ jsx5("span", { className: "text-slate-300 hidden sm:inline", children: "|" }),
|
|
808
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 })
|
|
809
853
|
] }),
|
|
810
|
-
/* @__PURE__ */
|
|
811
|
-
/* @__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: [
|
|
812
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" }) }),
|
|
813
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" }) }),
|
|
814
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" }) })
|
|
815
859
|
] }),
|
|
816
|
-
/* @__PURE__ */
|
|
860
|
+
/* @__PURE__ */ jsxs3(
|
|
817
861
|
"button",
|
|
818
862
|
{
|
|
819
863
|
onClick: () => setPreview((v) => !v),
|
|
@@ -824,7 +868,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
824
868
|
]
|
|
825
869
|
}
|
|
826
870
|
),
|
|
827
|
-
/* @__PURE__ */
|
|
871
|
+
/* @__PURE__ */ jsxs3(
|
|
828
872
|
"a",
|
|
829
873
|
{
|
|
830
874
|
href: page.path,
|
|
@@ -837,7 +881,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
837
881
|
]
|
|
838
882
|
}
|
|
839
883
|
),
|
|
840
|
-
/* @__PURE__ */
|
|
884
|
+
/* @__PURE__ */ jsxs3(
|
|
841
885
|
"button",
|
|
842
886
|
{
|
|
843
887
|
onClick: () => ctx.reset(),
|
|
@@ -849,7 +893,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
849
893
|
]
|
|
850
894
|
}
|
|
851
895
|
),
|
|
852
|
-
/* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ jsxs3(
|
|
853
897
|
"button",
|
|
854
898
|
{
|
|
855
899
|
onClick: () => ctx.save(),
|
|
@@ -863,7 +907,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
863
907
|
)
|
|
864
908
|
] })
|
|
865
909
|
] }),
|
|
866
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col sm:flex-row flex-1 overflow-hidden", children: [
|
|
867
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(
|
|
868
912
|
"iframe",
|
|
869
913
|
{
|
|
@@ -874,11 +918,11 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
874
918
|
},
|
|
875
919
|
src
|
|
876
920
|
) }) }),
|
|
877
|
-
/* @__PURE__ */
|
|
878
|
-
/* @__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: [
|
|
879
923
|
/* @__PURE__ */ jsx5("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
|
|
880
|
-
/* @__PURE__ */
|
|
881
|
-
/* @__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: [
|
|
882
926
|
/* @__PURE__ */ jsx5(
|
|
883
927
|
"button",
|
|
884
928
|
{
|
|
@@ -901,7 +945,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
901
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" })
|
|
902
946
|
] })
|
|
903
947
|
] }),
|
|
904
|
-
/* @__PURE__ */
|
|
948
|
+
/* @__PURE__ */ jsxs3("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
|
|
905
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." }) }),
|
|
906
950
|
selectedMeta ? /* @__PURE__ */ jsx5(
|
|
907
951
|
FieldEditor,
|
|
@@ -948,7 +992,7 @@ function SectionAccordion({
|
|
|
948
992
|
}) {
|
|
949
993
|
const [expanded, setExpanded] = useState4({});
|
|
950
994
|
if (registered.length === 0) {
|
|
951
|
-
return /* @__PURE__ */
|
|
995
|
+
return /* @__PURE__ */ jsxs3("div", { className: "px-4 py-8 text-center text-sm text-slate-500", children: [
|
|
952
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" }) }),
|
|
953
997
|
"No editable fields detected on this page."
|
|
954
998
|
] });
|
|
@@ -962,19 +1006,19 @@ function SectionAccordion({
|
|
|
962
1006
|
const sectionNames = Object.keys(groups).filter((n) => n !== "Unsectioned");
|
|
963
1007
|
const unsectionedFields = groups["Unsectioned"] || [];
|
|
964
1008
|
const toggle = (name) => setExpanded((prev) => ({ ...prev, [name]: !prev[name] }));
|
|
965
|
-
return /* @__PURE__ */
|
|
1009
|
+
return /* @__PURE__ */ jsxs3("div", { className: "p-2 space-y-3", children: [
|
|
966
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)) }),
|
|
967
1011
|
sectionNames.map((sectionName) => {
|
|
968
1012
|
const isOpen = expanded[sectionName] ?? false;
|
|
969
1013
|
const fields = groups[sectionName];
|
|
970
|
-
return /* @__PURE__ */
|
|
971
|
-
/* @__PURE__ */
|
|
1014
|
+
return /* @__PURE__ */ jsxs3("div", { className: "rounded-lg border border-slate-200 overflow-hidden", children: [
|
|
1015
|
+
/* @__PURE__ */ jsxs3(
|
|
972
1016
|
"button",
|
|
973
1017
|
{
|
|
974
1018
|
onClick: () => toggle(sectionName),
|
|
975
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",
|
|
976
1020
|
children: [
|
|
977
|
-
/* @__PURE__ */
|
|
1021
|
+
/* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-2", children: [
|
|
978
1022
|
/* @__PURE__ */ jsx5("span", { className: "font-semibold text-sm text-slate-800", children: sectionName }),
|
|
979
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 })
|
|
980
1024
|
] }),
|
|
@@ -998,15 +1042,15 @@ function SectionAccordion({
|
|
|
998
1042
|
] });
|
|
999
1043
|
}
|
|
1000
1044
|
function FieldListItem({ meta, onSelect }) {
|
|
1001
|
-
return /* @__PURE__ */ jsx5("li", { className: "p-1 list-none", children: /* @__PURE__ */
|
|
1045
|
+
return /* @__PURE__ */ jsx5("li", { className: "p-1 list-none", children: /* @__PURE__ */ jsxs3(
|
|
1002
1046
|
"button",
|
|
1003
1047
|
{
|
|
1004
1048
|
onClick: () => onSelect(meta.id),
|
|
1005
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",
|
|
1006
1050
|
children: [
|
|
1007
|
-
/* @__PURE__ */
|
|
1051
|
+
/* @__PURE__ */ jsxs3("span", { className: "overflow-hidden", children: [
|
|
1008
1052
|
/* @__PURE__ */ jsx5("span", { className: "block font-medium text-slate-800 text-sm truncate", children: meta.label ?? meta.id }),
|
|
1009
|
-
/* @__PURE__ */
|
|
1053
|
+
/* @__PURE__ */ jsxs3("span", { className: "block text-[10px] md:text-xs text-slate-400 truncate mt-0.5 font-mono", children: [
|
|
1010
1054
|
meta.type,
|
|
1011
1055
|
" ",
|
|
1012
1056
|
/* @__PURE__ */ jsx5("span", { className: "text-slate-300 mx-1", children: "\xB7" }),
|
|
@@ -1027,13 +1071,13 @@ function FieldEditor({
|
|
|
1027
1071
|
onClose
|
|
1028
1072
|
}) {
|
|
1029
1073
|
const ctx = useCmsContext();
|
|
1030
|
-
return /* @__PURE__ */
|
|
1031
|
-
/* @__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: [
|
|
1032
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 }),
|
|
1033
1077
|
/* @__PURE__ */ jsx5("div", { className: "font-bold text-slate-900 text-lg leading-tight", children: meta.label ?? meta.id }),
|
|
1034
1078
|
/* @__PURE__ */ jsx5("div", { className: "text-xs font-mono text-slate-400 mt-1", children: meta.id })
|
|
1035
1079
|
] }),
|
|
1036
|
-
/* @__PURE__ */
|
|
1080
|
+
/* @__PURE__ */ jsxs3("div", { className: "space-y-4", children: [
|
|
1037
1081
|
meta.type === "text" && /* @__PURE__ */ jsx5(
|
|
1038
1082
|
"input",
|
|
1039
1083
|
{
|
|
@@ -1052,8 +1096,8 @@ function FieldEditor({
|
|
|
1052
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"
|
|
1053
1097
|
}
|
|
1054
1098
|
),
|
|
1055
|
-
meta.type === "image" && /* @__PURE__ */
|
|
1056
|
-
/* @__PURE__ */
|
|
1099
|
+
meta.type === "image" && /* @__PURE__ */ jsxs3("div", { className: "space-y-3", children: [
|
|
1100
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
|
|
1057
1101
|
/* @__PURE__ */ jsx5(
|
|
1058
1102
|
"input",
|
|
1059
1103
|
{
|
|
@@ -1064,7 +1108,7 @@ function FieldEditor({
|
|
|
1064
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"
|
|
1065
1109
|
}
|
|
1066
1110
|
),
|
|
1067
|
-
/* @__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: [
|
|
1068
1112
|
"Upload",
|
|
1069
1113
|
/* @__PURE__ */ jsx5(
|
|
1070
1114
|
"input",
|
|
@@ -1082,7 +1126,7 @@ function FieldEditor({
|
|
|
1082
1126
|
)
|
|
1083
1127
|
] })
|
|
1084
1128
|
] }),
|
|
1085
|
-
value ? /* @__PURE__ */
|
|
1129
|
+
value ? /* @__PURE__ */ jsxs3("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group", children: [
|
|
1086
1130
|
/* @__PURE__ */ jsx5(
|
|
1087
1131
|
"img",
|
|
1088
1132
|
{
|
|
@@ -1094,8 +1138,8 @@ function FieldEditor({
|
|
|
1094
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" }) })
|
|
1095
1139
|
] }) : null
|
|
1096
1140
|
] }),
|
|
1097
|
-
meta.type === "link" && /* @__PURE__ */
|
|
1098
|
-
/* @__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: [
|
|
1099
1143
|
/* @__PURE__ */ jsx5("span", { className: "text-xs font-semibold text-slate-500 uppercase tracking-wide", children: "Link Text" }),
|
|
1100
1144
|
/* @__PURE__ */ jsx5(
|
|
1101
1145
|
"input",
|
|
@@ -1106,7 +1150,7 @@ function FieldEditor({
|
|
|
1106
1150
|
}
|
|
1107
1151
|
)
|
|
1108
1152
|
] }),
|
|
1109
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ jsxs3("label", { className: "block", children: [
|
|
1110
1154
|
/* @__PURE__ */ jsx5("span", { className: "text-xs font-semibold text-slate-500 uppercase tracking-wide", children: "URL Target" }),
|
|
1111
1155
|
/* @__PURE__ */ jsx5(
|
|
1112
1156
|
"input",
|
|
@@ -1119,7 +1163,7 @@ function FieldEditor({
|
|
|
1119
1163
|
)
|
|
1120
1164
|
] })
|
|
1121
1165
|
] }),
|
|
1122
|
-
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: [
|
|
1123
1167
|
/* @__PURE__ */ jsx5(
|
|
1124
1168
|
"input",
|
|
1125
1169
|
{
|
|
@@ -1148,9 +1192,9 @@ function FieldEditor({
|
|
|
1148
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"
|
|
1149
1193
|
}
|
|
1150
1194
|
),
|
|
1151
|
-
meta.type === "list" && /* @__PURE__ */
|
|
1152
|
-
(Array.isArray(value) ? value : []).map((item, idx) => /* @__PURE__ */
|
|
1153
|
-
/* @__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: [
|
|
1154
1198
|
/* @__PURE__ */ jsx5("label", { className: "block text-[10px] font-bold text-slate-500 uppercase mb-1", children: schemaField.label || schemaField.key }),
|
|
1155
1199
|
schemaField.type === "icon" ? /* @__PURE__ */ jsx5(
|
|
1156
1200
|
SearchableSelect,
|
|
@@ -1177,7 +1221,7 @@ function FieldEditor({
|
|
|
1177
1221
|
},
|
|
1178
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"
|
|
1179
1223
|
}
|
|
1180
|
-
) : schemaField.type === "boolean" ? /* @__PURE__ */
|
|
1224
|
+
) : schemaField.type === "boolean" ? /* @__PURE__ */ jsxs3("label", { className: "flex items-center gap-2 mt-1 cursor-pointer", children: [
|
|
1181
1225
|
/* @__PURE__ */ jsx5(
|
|
1182
1226
|
"input",
|
|
1183
1227
|
{
|
|
@@ -1192,8 +1236,8 @@ function FieldEditor({
|
|
|
1192
1236
|
}
|
|
1193
1237
|
),
|
|
1194
1238
|
/* @__PURE__ */ jsx5("span", { className: "text-sm text-slate-700", children: schemaField.label || schemaField.key })
|
|
1195
|
-
] }) : schemaField.type === "image" ? /* @__PURE__ */
|
|
1196
|
-
/* @__PURE__ */
|
|
1239
|
+
] }) : schemaField.type === "image" ? /* @__PURE__ */ jsxs3("div", { className: "space-y-3 mt-1", children: [
|
|
1240
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
|
|
1197
1241
|
/* @__PURE__ */ jsx5(
|
|
1198
1242
|
"input",
|
|
1199
1243
|
{
|
|
@@ -1208,7 +1252,7 @@ function FieldEditor({
|
|
|
1208
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"
|
|
1209
1253
|
}
|
|
1210
1254
|
),
|
|
1211
|
-
/* @__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: [
|
|
1212
1256
|
"Upload",
|
|
1213
1257
|
/* @__PURE__ */ jsx5(
|
|
1214
1258
|
"input",
|
|
@@ -1281,7 +1325,7 @@ function FieldEditor({
|
|
|
1281
1325
|
}
|
|
1282
1326
|
)
|
|
1283
1327
|
] }, idx)),
|
|
1284
|
-
!meta.fixedLength && /* @__PURE__ */
|
|
1328
|
+
!meta.fixedLength && /* @__PURE__ */ jsxs3(
|
|
1285
1329
|
"button",
|
|
1286
1330
|
{
|
|
1287
1331
|
onClick: () => {
|
|
@@ -1307,8 +1351,8 @@ function FieldEditor({
|
|
|
1307
1351
|
] }),
|
|
1308
1352
|
" "
|
|
1309
1353
|
] }),
|
|
1310
|
-
/* @__PURE__ */
|
|
1311
|
-
/* @__PURE__ */
|
|
1354
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between pt-6 mt-6 border-t border-slate-100", children: [
|
|
1355
|
+
/* @__PURE__ */ jsxs3(
|
|
1312
1356
|
"button",
|
|
1313
1357
|
{
|
|
1314
1358
|
onClick: onReset,
|
|
@@ -1344,18 +1388,18 @@ function CollectionsSection() {
|
|
|
1344
1388
|
});
|
|
1345
1389
|
});
|
|
1346
1390
|
}, [ctx.adapter, collections]);
|
|
1347
|
-
return /* @__PURE__ */
|
|
1348
|
-
/* @__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: [
|
|
1349
1393
|
/* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
|
|
1350
|
-
/* @__PURE__ */
|
|
1351
|
-
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(
|
|
1352
1396
|
"button",
|
|
1353
1397
|
{
|
|
1354
1398
|
onClick: () => setSelected(c),
|
|
1355
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"}`,
|
|
1356
1400
|
children: [
|
|
1357
1401
|
/* @__PURE__ */ jsx5("div", { className: selected?.id === c.id ? "text-slate-900" : "text-slate-700", children: c.name }),
|
|
1358
|
-
/* @__PURE__ */
|
|
1402
|
+
/* @__PURE__ */ jsxs3("div", { className: `text-xs mt-0.5 ${selected?.id === c.id ? "text-indigo-500" : "text-slate-400"}`, children: [
|
|
1359
1403
|
counts[c.id] ?? 0,
|
|
1360
1404
|
" items"
|
|
1361
1405
|
] })
|
|
@@ -1365,7 +1409,7 @@ function CollectionsSection() {
|
|
|
1365
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." })
|
|
1366
1410
|
] })
|
|
1367
1411
|
] }),
|
|
1368
|
-
/* @__PURE__ */
|
|
1412
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex-1 overflow-auto p-4 md:p-8 relative", children: [
|
|
1369
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" }),
|
|
1370
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." })
|
|
1371
1415
|
] })
|
|
@@ -1466,13 +1510,13 @@ function CollectionEditor({ collection }) {
|
|
|
1466
1510
|
setDragOverIdx(null);
|
|
1467
1511
|
};
|
|
1468
1512
|
const visibleFields = collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order").slice(0, 5);
|
|
1469
|
-
return /* @__PURE__ */
|
|
1470
|
-
/* @__PURE__ */
|
|
1471
|
-
/* @__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: [
|
|
1472
1516
|
/* @__PURE__ */ jsx5("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: collection.name }),
|
|
1473
1517
|
collection.description && /* @__PURE__ */ jsx5("p", { className: "text-sm text-slate-500 mt-1", children: collection.description })
|
|
1474
1518
|
] }),
|
|
1475
|
-
/* @__PURE__ */
|
|
1519
|
+
/* @__PURE__ */ jsxs3(
|
|
1476
1520
|
"button",
|
|
1477
1521
|
{
|
|
1478
1522
|
onClick: startNew,
|
|
@@ -1484,13 +1528,13 @@ function CollectionEditor({ collection }) {
|
|
|
1484
1528
|
}
|
|
1485
1529
|
)
|
|
1486
1530
|
] }),
|
|
1487
|
-
editing && /* @__PURE__ */
|
|
1488
|
-
/* @__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: [
|
|
1489
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" }) }),
|
|
1490
1534
|
/* @__PURE__ */ jsx5("h3", { className: "text-lg font-bold text-slate-900", children: "Edit Entry" })
|
|
1491
1535
|
] }),
|
|
1492
|
-
/* @__PURE__ */ jsx5("div", { className: "grid gap-5 md:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order").map((f) => /* @__PURE__ */
|
|
1493
|
-
/* @__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: [
|
|
1494
1538
|
f.label,
|
|
1495
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 })
|
|
1496
1540
|
] }),
|
|
@@ -1527,7 +1571,7 @@ function CollectionEditor({ collection }) {
|
|
|
1527
1571
|
placeholder: `Search ${f.label.toLowerCase()}...`,
|
|
1528
1572
|
iconMap: ctx.iconMap
|
|
1529
1573
|
}
|
|
1530
|
-
) : f.type === "slug" ? /* @__PURE__ */
|
|
1574
|
+
) : f.type === "slug" ? /* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
|
|
1531
1575
|
/* @__PURE__ */ jsx5(
|
|
1532
1576
|
"input",
|
|
1533
1577
|
{
|
|
@@ -1551,7 +1595,7 @@ function CollectionEditor({ collection }) {
|
|
|
1551
1595
|
children: "Generate"
|
|
1552
1596
|
}
|
|
1553
1597
|
)
|
|
1554
|
-
] }) : f.type === "select" ? /* @__PURE__ */
|
|
1598
|
+
] }) : f.type === "select" ? /* @__PURE__ */ jsxs3("div", { children: [
|
|
1555
1599
|
/* @__PURE__ */ jsx5(
|
|
1556
1600
|
"input",
|
|
1557
1601
|
{
|
|
@@ -1566,8 +1610,8 @@ function CollectionEditor({ collection }) {
|
|
|
1566
1610
|
const lab = typeof opt === "string" ? opt : opt.label;
|
|
1567
1611
|
return /* @__PURE__ */ jsx5("option", { value: val, children: lab }, val);
|
|
1568
1612
|
}) })
|
|
1569
|
-
] }) : f.type === "image" ? /* @__PURE__ */
|
|
1570
|
-
/* @__PURE__ */
|
|
1613
|
+
] }) : f.type === "image" ? /* @__PURE__ */ jsxs3("div", { className: "space-y-3", children: [
|
|
1614
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
|
|
1571
1615
|
/* @__PURE__ */ jsx5(
|
|
1572
1616
|
"input",
|
|
1573
1617
|
{
|
|
@@ -1578,7 +1622,7 @@ function CollectionEditor({ collection }) {
|
|
|
1578
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"
|
|
1579
1623
|
}
|
|
1580
1624
|
),
|
|
1581
|
-
/* @__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: [
|
|
1582
1626
|
"Upload",
|
|
1583
1627
|
/* @__PURE__ */ jsx5(
|
|
1584
1628
|
"input",
|
|
@@ -1623,7 +1667,7 @@ function CollectionEditor({ collection }) {
|
|
|
1623
1667
|
}
|
|
1624
1668
|
)
|
|
1625
1669
|
] }, f.id)) }),
|
|
1626
|
-
/* @__PURE__ */
|
|
1670
|
+
/* @__PURE__ */ jsxs3("div", { className: "mt-8 flex justify-end gap-3 pt-5 border-t border-slate-100", children: [
|
|
1627
1671
|
/* @__PURE__ */ jsx5(
|
|
1628
1672
|
"button",
|
|
1629
1673
|
{
|
|
@@ -1639,8 +1683,8 @@ function CollectionEditor({ collection }) {
|
|
|
1639
1683
|
onClick: save,
|
|
1640
1684
|
disabled: saving,
|
|
1641
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",
|
|
1642
|
-
children: saving ? /* @__PURE__ */
|
|
1643
|
-
/* @__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: [
|
|
1644
1688
|
/* @__PURE__ */ jsx5("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
1645
1689
|
/* @__PURE__ */ jsx5("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
1646
1690
|
] }),
|
|
@@ -1650,19 +1694,19 @@ function CollectionEditor({ collection }) {
|
|
|
1650
1694
|
)
|
|
1651
1695
|
] })
|
|
1652
1696
|
] }),
|
|
1653
|
-
/* @__PURE__ */ jsx5("div", { className: "overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */
|
|
1654
|
-
/* @__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: [
|
|
1655
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)),
|
|
1656
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" })
|
|
1657
1701
|
] }) }),
|
|
1658
1702
|
/* @__PURE__ */ jsx5("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
|
|
1659
1703
|
// Loading skeleton rows
|
|
1660
|
-
Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */
|
|
1704
|
+
Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxs3("tr", { children: [
|
|
1661
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)),
|
|
1662
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" }) })
|
|
1663
1707
|
] }, i))
|
|
1664
|
-
) : /* @__PURE__ */
|
|
1665
|
-
entries.map((e, idx) => /* @__PURE__ */
|
|
1708
|
+
) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1709
|
+
entries.map((e, idx) => /* @__PURE__ */ jsxs3(
|
|
1666
1710
|
"tr",
|
|
1667
1711
|
{
|
|
1668
1712
|
draggable: true,
|
|
@@ -1673,7 +1717,7 @@ function CollectionEditor({ collection }) {
|
|
|
1673
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" : ""}`,
|
|
1674
1718
|
children: [
|
|
1675
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)),
|
|
1676
|
-
/* @__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: [
|
|
1677
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" }) }) }),
|
|
1678
1722
|
/* @__PURE__ */ jsx5(
|
|
1679
1723
|
"button",
|
|
@@ -1691,7 +1735,7 @@ function CollectionEditor({ collection }) {
|
|
|
1691
1735
|
disabled: deletingId === e.id,
|
|
1692
1736
|
className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
|
|
1693
1737
|
title: "Delete",
|
|
1694
|
-
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: [
|
|
1695
1739
|
/* @__PURE__ */ jsx5("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
1696
1740
|
/* @__PURE__ */ jsx5("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
1697
1741
|
] }) : /* @__PURE__ */ jsx5(Trash2, { className: "h-4 w-4" })
|
|
@@ -1707,7 +1751,7 @@ function CollectionEditor({ collection }) {
|
|
|
1707
1751
|
{
|
|
1708
1752
|
colSpan: visibleFields.length + 1,
|
|
1709
1753
|
className: "px-6 py-12 text-center text-slate-500",
|
|
1710
|
-
children: /* @__PURE__ */
|
|
1754
|
+
children: /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center justify-center", children: [
|
|
1711
1755
|
/* @__PURE__ */ jsx5(Boxes, { className: "h-10 w-10 text-slate-300 mb-3" }),
|
|
1712
1756
|
/* @__PURE__ */ jsx5("p", { children: 'No entries yet. Click "New Entry" to create one.' })
|
|
1713
1757
|
] })
|
|
@@ -1738,18 +1782,18 @@ function SubmissionsSection() {
|
|
|
1738
1782
|
setSelectedFormId(formIds[0]);
|
|
1739
1783
|
}
|
|
1740
1784
|
}, [formIds, selectedFormId]);
|
|
1741
|
-
return /* @__PURE__ */
|
|
1742
|
-
/* @__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: [
|
|
1743
1787
|
/* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Data Collections" }),
|
|
1744
|
-
/* @__PURE__ */
|
|
1745
|
-
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(
|
|
1746
1790
|
"button",
|
|
1747
1791
|
{
|
|
1748
1792
|
onClick: () => setSelectedFormId(id),
|
|
1749
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"}`,
|
|
1750
1794
|
children: [
|
|
1751
1795
|
/* @__PURE__ */ jsx5("div", { className: selectedFormId === id ? "text-slate-900" : "text-slate-700 capitalize", children: id }),
|
|
1752
|
-
/* @__PURE__ */
|
|
1796
|
+
/* @__PURE__ */ jsxs3("div", { className: `text-xs mt-0.5 ${selectedFormId === id ? "text-indigo-500" : "text-slate-400"}`, children: [
|
|
1753
1797
|
submissions.filter((s) => s.formId === id).length,
|
|
1754
1798
|
" items"
|
|
1755
1799
|
] })
|
|
@@ -1759,7 +1803,7 @@ function SubmissionsSection() {
|
|
|
1759
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." })
|
|
1760
1804
|
] })
|
|
1761
1805
|
] }),
|
|
1762
|
-
/* @__PURE__ */
|
|
1806
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex-1 overflow-auto p-4 md:p-8 relative", children: [
|
|
1763
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" }),
|
|
1764
1808
|
selectedFormId ? /* @__PURE__ */ jsx5(
|
|
1765
1809
|
SubmissionsList,
|
|
@@ -1808,8 +1852,8 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1808
1852
|
}
|
|
1809
1853
|
};
|
|
1810
1854
|
if (detail) {
|
|
1811
|
-
return /* @__PURE__ */
|
|
1812
|
-
/* @__PURE__ */
|
|
1855
|
+
return /* @__PURE__ */ jsxs3("div", { className: "mx-auto w-full max-w-2xl", children: [
|
|
1856
|
+
/* @__PURE__ */ jsxs3(
|
|
1813
1857
|
"button",
|
|
1814
1858
|
{
|
|
1815
1859
|
onClick: () => setDetail(null),
|
|
@@ -1820,9 +1864,9 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1820
1864
|
]
|
|
1821
1865
|
}
|
|
1822
1866
|
),
|
|
1823
|
-
/* @__PURE__ */
|
|
1824
|
-
/* @__PURE__ */ jsx5("div", { className: "px-8 py-6 border-b border-slate-100 bg-slate-50/50", children: /* @__PURE__ */
|
|
1825
|
-
/* @__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: [
|
|
1826
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 }),
|
|
1827
1871
|
/* @__PURE__ */ jsx5("p", { className: "text-xs text-slate-400", children: formatDate(detail.submittedAt) })
|
|
1828
1872
|
] }),
|
|
@@ -1836,23 +1880,23 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1836
1880
|
}
|
|
1837
1881
|
)
|
|
1838
1882
|
] }) }),
|
|
1839
|
-
/* @__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: [
|
|
1840
1884
|
/* @__PURE__ */ jsx5("dt", { className: "text-xs font-bold uppercase tracking-wide text-slate-400 pt-0.5", children: key }),
|
|
1841
1885
|
/* @__PURE__ */ jsx5("dd", { className: "text-sm text-slate-800 whitespace-pre-wrap", children: String(val ?? "\u2014") })
|
|
1842
1886
|
] }, key)) })
|
|
1843
1887
|
] })
|
|
1844
1888
|
] });
|
|
1845
1889
|
}
|
|
1846
|
-
return /* @__PURE__ */
|
|
1847
|
-
/* @__PURE__ */
|
|
1848
|
-
/* @__PURE__ */
|
|
1849
|
-
/* @__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: [
|
|
1850
1894
|
formId,
|
|
1851
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 })
|
|
1852
1896
|
] }),
|
|
1853
1897
|
/* @__PURE__ */ jsx5("p", { className: "text-sm text-slate-500 mt-1", children: "Data received for this collection." })
|
|
1854
1898
|
] }),
|
|
1855
|
-
/* @__PURE__ */
|
|
1899
|
+
/* @__PURE__ */ jsxs3(
|
|
1856
1900
|
"button",
|
|
1857
1901
|
{
|
|
1858
1902
|
onClick: onLoad,
|
|
@@ -1865,7 +1909,7 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1865
1909
|
}
|
|
1866
1910
|
)
|
|
1867
1911
|
] }),
|
|
1868
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ jsxs3("div", { className: "relative", children: [
|
|
1869
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" }),
|
|
1870
1914
|
/* @__PURE__ */ jsx5(
|
|
1871
1915
|
"input",
|
|
@@ -1880,28 +1924,28 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1880
1924
|
}
|
|
1881
1925
|
)
|
|
1882
1926
|
] }),
|
|
1883
|
-
/* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */
|
|
1884
|
-
/* @__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: [
|
|
1885
1929
|
/* @__PURE__ */ jsx5("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: "Summary" }),
|
|
1886
1930
|
/* @__PURE__ */ jsx5("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: "Received" }),
|
|
1887
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" })
|
|
1888
1932
|
] }) }),
|
|
1889
|
-
/* @__PURE__ */
|
|
1933
|
+
/* @__PURE__ */ jsxs3("tbody", { className: "divide-y divide-slate-100", children: [
|
|
1890
1934
|
paginated.map((s) => {
|
|
1891
1935
|
const firstVal = Object.values(s.data)[0];
|
|
1892
1936
|
const preview = firstVal ? String(firstVal).slice(0, 60) : "\u2014";
|
|
1893
|
-
return /* @__PURE__ */
|
|
1937
|
+
return /* @__PURE__ */ jsxs3(
|
|
1894
1938
|
"tr",
|
|
1895
1939
|
{
|
|
1896
1940
|
className: `hover:bg-slate-50/50 transition-colors group cursor-pointer ${!s.read ? "bg-indigo-50/40" : ""}`,
|
|
1897
1941
|
onClick: () => openDetail(s),
|
|
1898
1942
|
children: [
|
|
1899
|
-
/* @__PURE__ */
|
|
1943
|
+
/* @__PURE__ */ jsxs3("td", { className: "px-6 py-4", children: [
|
|
1900
1944
|
/* @__PURE__ */ jsx5("span", { className: "text-slate-600 max-w-[400px] truncate block", children: preview }),
|
|
1901
1945
|
!s.read && /* @__PURE__ */ jsx5("span", { className: "ml-2 inline-block h-2 w-2 rounded-full bg-indigo-500" })
|
|
1902
1946
|
] }),
|
|
1903
1947
|
/* @__PURE__ */ jsx5("td", { className: "px-6 py-4 text-slate-500 whitespace-nowrap", children: formatDate(s.submittedAt) }),
|
|
1904
|
-
/* @__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: [
|
|
1905
1949
|
/* @__PURE__ */ jsx5(
|
|
1906
1950
|
"button",
|
|
1907
1951
|
{
|
|
@@ -1926,19 +1970,19 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1926
1970
|
s.id
|
|
1927
1971
|
);
|
|
1928
1972
|
}),
|
|
1929
|
-
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: [
|
|
1930
1974
|
/* @__PURE__ */ jsx5(Inbox, { className: "h-12 w-12 text-slate-200" }),
|
|
1931
1975
|
/* @__PURE__ */ jsx5("p", { className: "text-sm font-medium", children: search ? "No matches." : "No data yet." })
|
|
1932
1976
|
] }) }) })
|
|
1933
1977
|
] })
|
|
1934
1978
|
] }) }),
|
|
1935
|
-
totalPages > 1 && /* @__PURE__ */
|
|
1936
|
-
/* @__PURE__ */
|
|
1979
|
+
totalPages > 1 && /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between text-sm text-slate-500", children: [
|
|
1980
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
1937
1981
|
filtered.length,
|
|
1938
1982
|
" item",
|
|
1939
1983
|
filtered.length !== 1 ? "s" : ""
|
|
1940
1984
|
] }),
|
|
1941
|
-
/* @__PURE__ */
|
|
1985
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
1942
1986
|
/* @__PURE__ */ jsx5(
|
|
1943
1987
|
"button",
|
|
1944
1988
|
{
|
|
@@ -1948,7 +1992,7 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1948
1992
|
children: /* @__PURE__ */ jsx5(ChevronLeft, { className: "h-4 w-4" })
|
|
1949
1993
|
}
|
|
1950
1994
|
),
|
|
1951
|
-
/* @__PURE__ */
|
|
1995
|
+
/* @__PURE__ */ jsxs3("span", { className: "font-medium text-slate-700", children: [
|
|
1952
1996
|
"Page ",
|
|
1953
1997
|
page,
|
|
1954
1998
|
" of ",
|
|
@@ -1969,14 +2013,14 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
1969
2013
|
}
|
|
1970
2014
|
function SettingsSection() {
|
|
1971
2015
|
const ctx = useCmsContext();
|
|
1972
|
-
return /* @__PURE__ */ jsx5("div", { className: "flex h-full bg-slate-50 p-8 overflow-y-auto", children: /* @__PURE__ */
|
|
1973
|
-
/* @__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: [
|
|
1974
2018
|
/* @__PURE__ */ jsx5("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: "System Settings" }),
|
|
1975
2019
|
/* @__PURE__ */ jsx5("p", { className: "text-sm text-slate-500 mt-1", children: "Current configuration and statistics for your CMS instance." })
|
|
1976
2020
|
] }),
|
|
1977
|
-
/* @__PURE__ */
|
|
2021
|
+
/* @__PURE__ */ jsxs3("div", { className: "rounded-2xl border border-slate-200 bg-white shadow-sm overflow-hidden", children: [
|
|
1978
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" }) }),
|
|
1979
|
-
/* @__PURE__ */
|
|
2023
|
+
/* @__PURE__ */ jsxs3("dl", { className: "divide-y divide-slate-100 text-sm", children: [
|
|
1980
2024
|
/* @__PURE__ */ jsx5(Row, { label: "Site Name", value: ctx.config.siteName ?? "\u2014" }),
|
|
1981
2025
|
/* @__PURE__ */ jsx5(Row, { label: "Active Storage Adapter", value: ctx.adapter.name, highlight: true }),
|
|
1982
2026
|
/* @__PURE__ */ jsx5(Row, { label: "Registered Pages", value: String(ctx.config.pages.length) }),
|
|
@@ -2019,10 +2063,10 @@ function ConfigSection() {
|
|
|
2019
2063
|
},
|
|
2020
2064
|
[ctx]
|
|
2021
2065
|
);
|
|
2022
|
-
return /* @__PURE__ */
|
|
2023
|
-
/* @__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: [
|
|
2024
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" }),
|
|
2025
|
-
/* @__PURE__ */
|
|
2069
|
+
/* @__PURE__ */ jsxs3("ul", { className: "flex flex-row lg:flex-col space-x-2 lg:space-x-0 lg:space-y-1", children: [
|
|
2026
2070
|
globals.map((g) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 w-32 lg:w-full", children: /* @__PURE__ */ jsx5(
|
|
2027
2071
|
"button",
|
|
2028
2072
|
{
|
|
@@ -2034,14 +2078,14 @@ function ConfigSection() {
|
|
|
2034
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." })
|
|
2035
2079
|
] })
|
|
2036
2080
|
] }),
|
|
2037
|
-
/* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-auto bg-slate-50 p-6 lg:p-10 relative", children: /* @__PURE__ */
|
|
2038
|
-
/* @__PURE__ */
|
|
2039
|
-
/* @__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: [
|
|
2040
2084
|
/* @__PURE__ */ jsx5("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: "Configuration" }),
|
|
2041
2085
|
/* @__PURE__ */ jsx5("p", { className: "text-sm text-slate-500 mt-1", children: "Edit global content like headers and footers." })
|
|
2042
2086
|
] }),
|
|
2043
|
-
/* @__PURE__ */
|
|
2044
|
-
/* @__PURE__ */
|
|
2087
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
2088
|
+
/* @__PURE__ */ jsxs3(
|
|
2045
2089
|
"button",
|
|
2046
2090
|
{
|
|
2047
2091
|
onClick: () => ctx.reset(),
|
|
@@ -2053,7 +2097,7 @@ function ConfigSection() {
|
|
|
2053
2097
|
]
|
|
2054
2098
|
}
|
|
2055
2099
|
),
|
|
2056
|
-
/* @__PURE__ */
|
|
2100
|
+
/* @__PURE__ */ jsxs3(
|
|
2057
2101
|
"button",
|
|
2058
2102
|
{
|
|
2059
2103
|
onClick: () => ctx.save(),
|
|
@@ -2067,7 +2111,7 @@ function ConfigSection() {
|
|
|
2067
2111
|
)
|
|
2068
2112
|
] })
|
|
2069
2113
|
] }),
|
|
2070
|
-
selectedGroup ? /* @__PURE__ */
|
|
2114
|
+
selectedGroup ? /* @__PURE__ */ jsxs3("div", { className: "space-y-4", children: [
|
|
2071
2115
|
/* @__PURE__ */ jsx5("h3", { className: "font-bold text-slate-800 text-lg", children: selectedGroup.label }),
|
|
2072
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(
|
|
2073
2117
|
FieldEditor,
|
|
@@ -2080,7 +2124,7 @@ function ConfigSection() {
|
|
|
2080
2124
|
}
|
|
2081
2125
|
}
|
|
2082
2126
|
) }, field.id)) })
|
|
2083
|
-
] }) : /* @__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: [
|
|
2084
2128
|
/* @__PURE__ */ jsx5(SettingsIcon, { className: "w-12 h-12 text-slate-300 mb-4" }),
|
|
2085
2129
|
/* @__PURE__ */ jsx5("p", { className: "text-slate-500 font-medium", children: "Select a setting group on the left to edit." })
|
|
2086
2130
|
] })
|
|
@@ -2093,7 +2137,7 @@ function Row({
|
|
|
2093
2137
|
highlight,
|
|
2094
2138
|
status
|
|
2095
2139
|
}) {
|
|
2096
|
-
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: [
|
|
2097
2141
|
/* @__PURE__ */ jsx5("dt", { className: "text-slate-500 font-medium", children: label }),
|
|
2098
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 })
|
|
2099
2143
|
] });
|
|
@@ -2104,8 +2148,8 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2104
2148
|
const filtered = options.filter((o) => o.toLowerCase().includes(search.toLowerCase()));
|
|
2105
2149
|
const capped = filtered.slice(0, 80);
|
|
2106
2150
|
const SelectedIcon = iconMap && value ? iconMap[value] : null;
|
|
2107
|
-
return /* @__PURE__ */
|
|
2108
|
-
/* @__PURE__ */
|
|
2151
|
+
return /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
|
|
2152
|
+
/* @__PURE__ */ jsxs3(
|
|
2109
2153
|
"button",
|
|
2110
2154
|
{
|
|
2111
2155
|
type: "button",
|
|
@@ -2115,7 +2159,7 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2115
2159
|
},
|
|
2116
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",
|
|
2117
2161
|
children: [
|
|
2118
|
-
/* @__PURE__ */
|
|
2162
|
+
/* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-2 truncate", children: [
|
|
2119
2163
|
SelectedIcon && /* @__PURE__ */ jsx5(SelectedIcon, { className: "w-4 h-4 text-indigo-600 shrink-0" }),
|
|
2120
2164
|
/* @__PURE__ */ jsx5("span", { className: "truncate", children: value || placeholder || "Select..." })
|
|
2121
2165
|
] }),
|
|
@@ -2123,10 +2167,10 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2123
2167
|
]
|
|
2124
2168
|
}
|
|
2125
2169
|
),
|
|
2126
|
-
open && /* @__PURE__ */
|
|
2170
|
+
open && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2127
2171
|
/* @__PURE__ */ jsx5("div", { className: "fixed inset-0 z-[100]", onClick: () => setOpen(false) }),
|
|
2128
|
-
/* @__PURE__ */
|
|
2129
|
-
/* @__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: [
|
|
2130
2174
|
/* @__PURE__ */ jsx5(Search, { className: "w-4 h-4 text-slate-400 shrink-0" }),
|
|
2131
2175
|
/* @__PURE__ */ jsx5(
|
|
2132
2176
|
"input",
|
|
@@ -2141,15 +2185,15 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2141
2185
|
),
|
|
2142
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 })
|
|
2143
2187
|
] }),
|
|
2144
|
-
/* @__PURE__ */
|
|
2145
|
-
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: [
|
|
2146
2190
|
'No results for "',
|
|
2147
2191
|
search,
|
|
2148
2192
|
'"'
|
|
2149
2193
|
] }),
|
|
2150
2194
|
capped.map((opt) => {
|
|
2151
2195
|
const OptIcon = iconMap ? iconMap[opt] : null;
|
|
2152
|
-
return /* @__PURE__ */
|
|
2196
|
+
return /* @__PURE__ */ jsxs3(
|
|
2153
2197
|
"button",
|
|
2154
2198
|
{
|
|
2155
2199
|
type: "button",
|
|
@@ -2166,7 +2210,7 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
2166
2210
|
opt
|
|
2167
2211
|
);
|
|
2168
2212
|
}),
|
|
2169
|
-
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: [
|
|
2170
2214
|
"Showing 80 of ",
|
|
2171
2215
|
filtered.length,
|
|
2172
2216
|
" \u2014 type to narrow results"
|
|
@@ -2181,7 +2225,7 @@ function PasswordField({ value, onChange }) {
|
|
|
2181
2225
|
const isHash = value.startsWith("$2a$") || value.startsWith("$2b$");
|
|
2182
2226
|
const [displayValue, setDisplayValue] = useState4(isHash ? "" : value);
|
|
2183
2227
|
const [pristine, setPristine] = useState4(isHash);
|
|
2184
|
-
return /* @__PURE__ */
|
|
2228
|
+
return /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
|
|
2185
2229
|
/* @__PURE__ */ jsx5(
|
|
2186
2230
|
"input",
|
|
2187
2231
|
{
|
|
@@ -2211,7 +2255,7 @@ function PasswordField({ value, onChange }) {
|
|
|
2211
2255
|
// src/admin/AdminLogin.tsx
|
|
2212
2256
|
import { useState as useState5, useEffect as useEffect5 } from "react";
|
|
2213
2257
|
import { Lock, UserPlus } from "lucide-react";
|
|
2214
|
-
import { jsx as jsx6, jsxs as
|
|
2258
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2215
2259
|
function AdminLogin({
|
|
2216
2260
|
authApiRoute = "/api/admin/auth",
|
|
2217
2261
|
redirectRoute = "/admin"
|
|
@@ -2257,19 +2301,19 @@ function AdminLogin({
|
|
|
2257
2301
|
}
|
|
2258
2302
|
};
|
|
2259
2303
|
if (view === "checking") {
|
|
2260
|
-
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: [
|
|
2261
2305
|
/* @__PURE__ */ jsx6("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2262
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" })
|
|
2263
2307
|
] }) });
|
|
2264
2308
|
}
|
|
2265
|
-
return /* @__PURE__ */ jsx6("div", { className: "min-h-screen flex items-center justify-center bg-slate-50 p-4", children: /* @__PURE__ */
|
|
2266
|
-
/* @__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: [
|
|
2267
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" }) }),
|
|
2268
2312
|
/* @__PURE__ */ jsx6("h1", { className: "text-2xl font-bold text-slate-900 text-center mb-2", children: view === "register" ? "Create Admin Account" : "Admin Login" }),
|
|
2269
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." }),
|
|
2270
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 }),
|
|
2271
|
-
/* @__PURE__ */
|
|
2272
|
-
/* @__PURE__ */
|
|
2315
|
+
/* @__PURE__ */ jsxs4("form", { onSubmit: handleSubmit, className: "space-y-5", children: [
|
|
2316
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
2273
2317
|
/* @__PURE__ */ jsx6("label", { className: "block text-sm font-medium text-slate-700 mb-1.5", children: "Email Address" }),
|
|
2274
2318
|
/* @__PURE__ */ jsx6(
|
|
2275
2319
|
"input",
|
|
@@ -2283,7 +2327,7 @@ function AdminLogin({
|
|
|
2283
2327
|
}
|
|
2284
2328
|
)
|
|
2285
2329
|
] }),
|
|
2286
|
-
/* @__PURE__ */
|
|
2330
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
2287
2331
|
/* @__PURE__ */ jsx6("label", { className: "block text-sm font-medium text-slate-700 mb-1.5", children: "Password" }),
|
|
2288
2332
|
/* @__PURE__ */ jsx6(
|
|
2289
2333
|
"input",
|
|
@@ -2303,7 +2347,7 @@ function AdminLogin({
|
|
|
2303
2347
|
type: "submit",
|
|
2304
2348
|
disabled: loading,
|
|
2305
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",
|
|
2306
|
-
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: [
|
|
2307
2351
|
/* @__PURE__ */ jsx6("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2308
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" })
|
|
2309
2353
|
] }) : view === "register" ? "Create Account" : "Sign In"
|