admin-lib-cms 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -4
- package/dist/index.d.mts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +626 -357
- package/dist/index.mjs +774 -506
- package/dist/types.d.mts +3 -2
- package/dist/types.d.ts +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
AdminApp: () => AdminApp,
|
|
25
25
|
AdminLogin: () => AdminLogin,
|
|
26
26
|
CmsProvider: () => CmsProvider,
|
|
27
|
+
EditableFile: () => EditableFile,
|
|
27
28
|
EditableImage: () => EditableImage,
|
|
28
29
|
EditableLink: () => EditableLink,
|
|
29
30
|
EditableList: () => EditableList,
|
|
@@ -41,31 +42,256 @@ __export(index_exports, {
|
|
|
41
42
|
module.exports = __toCommonJS(index_exports);
|
|
42
43
|
|
|
43
44
|
// src/provider.tsx
|
|
45
|
+
var import_react3 = require("react");
|
|
46
|
+
|
|
47
|
+
// src/subscription/SubscriptionProvider.tsx
|
|
44
48
|
var import_react = require("react");
|
|
45
49
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
|
-
var
|
|
50
|
+
var SubscriptionContext = (0, import_react.createContext)(void 0);
|
|
51
|
+
function useSubscriptionContext() {
|
|
52
|
+
const ctx = (0, import_react.useContext)(SubscriptionContext);
|
|
53
|
+
if (!ctx) {
|
|
54
|
+
throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
|
|
55
|
+
}
|
|
56
|
+
return ctx;
|
|
57
|
+
}
|
|
58
|
+
function useSubscription() {
|
|
59
|
+
return useSubscriptionContext();
|
|
60
|
+
}
|
|
61
|
+
function SubscriptionProvider({
|
|
62
|
+
children,
|
|
63
|
+
apiUrl,
|
|
64
|
+
projectId,
|
|
65
|
+
email,
|
|
66
|
+
validateSubscriptionUrl
|
|
67
|
+
}) {
|
|
68
|
+
const [subscription, setSubscription] = (0, import_react.useState)(null);
|
|
69
|
+
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
70
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
71
|
+
const fetchSubscription = (0, import_react.useCallback)(
|
|
72
|
+
async (silent = false) => {
|
|
73
|
+
if (!apiUrl || !projectId) {
|
|
74
|
+
setLoading(false);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!silent) setLoading(true);
|
|
78
|
+
setError(null);
|
|
79
|
+
try {
|
|
80
|
+
const endpoint = validateSubscriptionUrl || `${apiUrl}/api/validate-subscription`;
|
|
81
|
+
const res = await fetch(endpoint, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
headers: { "Content-Type": "application/json" },
|
|
84
|
+
body: JSON.stringify({ projectId })
|
|
85
|
+
});
|
|
86
|
+
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
87
|
+
const data = await res.json();
|
|
88
|
+
setSubscription({
|
|
89
|
+
subscriptionStatus: data.valid ? data.status : "inactive",
|
|
90
|
+
currentPeriodEnd: data.expiryDate,
|
|
91
|
+
customerEmail: email,
|
|
92
|
+
subscriptionId: data._id,
|
|
93
|
+
stripeCustomerId: data.stripeCustomerId,
|
|
94
|
+
stripePaymentLink: data.stripePaymentLink,
|
|
95
|
+
valid: data.valid
|
|
96
|
+
});
|
|
97
|
+
} catch (err) {
|
|
98
|
+
console.error("SubscriptionProvider Error:", err);
|
|
99
|
+
setError(err.message || "Failed to fetch subscription");
|
|
100
|
+
setSubscription({ subscriptionStatus: "active", valid: true });
|
|
101
|
+
} finally {
|
|
102
|
+
setLoading(false);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
[apiUrl, projectId, email]
|
|
106
|
+
);
|
|
107
|
+
(0, import_react.useEffect)(() => {
|
|
108
|
+
fetchSubscription();
|
|
109
|
+
const handleFocus = () => {
|
|
110
|
+
fetchSubscription(true);
|
|
111
|
+
};
|
|
112
|
+
window.addEventListener("focus", handleFocus);
|
|
113
|
+
let intervalId;
|
|
114
|
+
if (subscription && !subscription.valid) {
|
|
115
|
+
intervalId = setInterval(() => {
|
|
116
|
+
fetchSubscription(true);
|
|
117
|
+
}, 1e4);
|
|
118
|
+
}
|
|
119
|
+
return () => {
|
|
120
|
+
window.removeEventListener("focus", handleFocus);
|
|
121
|
+
if (intervalId) clearInterval(intervalId);
|
|
122
|
+
};
|
|
123
|
+
}, [fetchSubscription, subscription?.valid]);
|
|
124
|
+
let daysOverdue = 0;
|
|
125
|
+
if (subscription && !subscription.valid && subscription.currentPeriodEnd) {
|
|
126
|
+
const diffTime = Date.now() - new Date(subscription.currentPeriodEnd).getTime();
|
|
127
|
+
if (diffTime > 0) {
|
|
128
|
+
daysOverdue = Math.floor(diffTime / (1e3 * 60 * 60 * 24));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const isSubscriptionActive = subscription ? subscription.valid || daysOverdue < 30 : true;
|
|
132
|
+
const value = {
|
|
133
|
+
subscription,
|
|
134
|
+
loading,
|
|
135
|
+
error,
|
|
136
|
+
refetch: fetchSubscription,
|
|
137
|
+
isSubscriptionActive,
|
|
138
|
+
daysOverdue,
|
|
139
|
+
config: { apiUrl, projectId }
|
|
140
|
+
};
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubscriptionContext.Provider, { value, children });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/subscription/SubscriptionPage.tsx
|
|
145
|
+
var import_react2 = require("react");
|
|
146
|
+
var import_lucide_react = require("lucide-react");
|
|
147
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
148
|
+
function SubscriptionPage() {
|
|
149
|
+
const { subscription, loading, config } = useSubscription();
|
|
150
|
+
const [actionLoading, setActionLoading] = (0, import_react2.useState)(null);
|
|
151
|
+
const status = subscription?.subscriptionStatus || "inactive";
|
|
152
|
+
const isValid = subscription?.valid ?? false;
|
|
153
|
+
const handleSubscribe = () => {
|
|
154
|
+
if (!subscription?.stripePaymentLink) {
|
|
155
|
+
alert("No payment link found. Please contact support.");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const raw = subscription.stripePaymentLink;
|
|
159
|
+
const url = raw.startsWith("http") ? raw : `https://buy.stripe.com/${raw}`;
|
|
160
|
+
window.open(url, "_blank");
|
|
161
|
+
};
|
|
162
|
+
const handleManageBilling = async () => {
|
|
163
|
+
if (!subscription?.stripeCustomerId) {
|
|
164
|
+
alert("No customer ID available. Please contact support.");
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
setActionLoading("billing");
|
|
168
|
+
try {
|
|
169
|
+
const returnUrl = window.location.href;
|
|
170
|
+
const apiUrl = config.apiUrl || "https://dev-soft-admin-sigma.vercel.app";
|
|
171
|
+
const res = await fetch(`${apiUrl}/api/create-billing-session`, {
|
|
172
|
+
method: "POST",
|
|
173
|
+
headers: { "Content-Type": "application/json" },
|
|
174
|
+
body: JSON.stringify({
|
|
175
|
+
customerId: subscription.stripeCustomerId,
|
|
176
|
+
returnUrl
|
|
177
|
+
})
|
|
178
|
+
});
|
|
179
|
+
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
180
|
+
const data = await res.json();
|
|
181
|
+
if (data.url) {
|
|
182
|
+
window.open(data.url, "_blank");
|
|
183
|
+
} else {
|
|
184
|
+
alert("Could not create billing session.");
|
|
185
|
+
}
|
|
186
|
+
} catch (err) {
|
|
187
|
+
alert(`Portal failed: ${err.message}`);
|
|
188
|
+
} finally {
|
|
189
|
+
setActionLoading(null);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
if (loading && !subscription) {
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex h-full min-h-[500px] w-full items-center justify-center bg-slate-50", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col items-center gap-3 text-slate-500", children: [
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-indigo-200 border-t-indigo-600" }),
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-sm font-medium", children: "Verifying subscription..." })
|
|
196
|
+
] }) });
|
|
197
|
+
}
|
|
198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex min-h-screen w-full flex-col items-center justify-center bg-slate-50 p-6", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "w-full max-w-md overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-xl", children: [
|
|
199
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `p-8 text-center ${isValid ? "bg-emerald-50" : "bg-rose-50"}`, children: [
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white shadow-sm", children: isValid ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.CheckCircle2, { className: "h-8 w-8 text-emerald-500" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.AlertTriangle, { className: "h-8 w-8 text-rose-500" }) }),
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: isValid ? "Subscription Active" : "Subscription Inactive" }),
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "mt-2 text-sm text-slate-600", children: isValid ? "Your subscription is currently active and in good standing." : "Your project requires an active subscription to access the administration panel." })
|
|
203
|
+
] }),
|
|
204
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-8", children: [
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "space-y-4", children: [
|
|
206
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
207
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Status" }),
|
|
208
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold capitalize ${isValid ? "bg-emerald-100 text-emerald-700" : "bg-rose-100 text-rose-700"}`, children: status })
|
|
209
|
+
] }),
|
|
210
|
+
subscription?.currentPeriodEnd && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
211
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Next Billing Date" }),
|
|
212
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-sm font-semibold text-slate-900", children: new Date(subscription.currentPeriodEnd).toLocaleDateString() })
|
|
213
|
+
] })
|
|
214
|
+
] }),
|
|
215
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mt-8 space-y-3", children: [
|
|
216
|
+
!isValid && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
217
|
+
"button",
|
|
218
|
+
{
|
|
219
|
+
onClick: handleSubscribe,
|
|
220
|
+
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",
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.CreditCard, { className: "h-4 w-4" }),
|
|
223
|
+
"Pay Now to Restore Access",
|
|
224
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ExternalLink, { className: "h-3.5 w-3.5 opacity-70 transition-transform group-hover:translate-x-0.5" })
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
229
|
+
"button",
|
|
230
|
+
{
|
|
231
|
+
onClick: handleManageBilling,
|
|
232
|
+
disabled: actionLoading === "billing",
|
|
233
|
+
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",
|
|
234
|
+
children: [
|
|
235
|
+
actionLoading === "billing" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-slate-300 border-t-slate-600" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Settings, { className: "h-4 w-4 text-slate-400 group-hover:text-slate-600" }),
|
|
236
|
+
"Manage Billing & Invoices"
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
] })
|
|
241
|
+
] })
|
|
242
|
+
] }) });
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// src/provider.tsx
|
|
246
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
247
|
+
var CmsContext = (0, import_react3.createContext)(null);
|
|
47
248
|
function useCmsContext() {
|
|
48
|
-
const ctx = (0,
|
|
249
|
+
const ctx = (0, import_react3.useContext)(CmsContext);
|
|
49
250
|
if (!ctx) throw new Error("useCms must be used inside <CmsProvider>");
|
|
50
251
|
return ctx;
|
|
51
252
|
}
|
|
52
253
|
function useCmsOptional() {
|
|
53
|
-
return (0,
|
|
254
|
+
return (0, import_react3.useContext)(CmsContext);
|
|
54
255
|
}
|
|
55
|
-
function CmsProvider(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
256
|
+
function CmsProvider(props) {
|
|
257
|
+
if (props.projectId) {
|
|
258
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
259
|
+
SubscriptionProvider,
|
|
260
|
+
{
|
|
261
|
+
apiUrl: props.apiUrl,
|
|
262
|
+
projectId: props.projectId,
|
|
263
|
+
email: props.email,
|
|
264
|
+
validateSubscriptionUrl: props.validateSubscriptionUrl,
|
|
265
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CmsProviderInner, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SiteGuard, { children: props.children }) })
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CmsProviderInner, { ...props, children: props.children });
|
|
270
|
+
}
|
|
271
|
+
function SiteGuard({ children }) {
|
|
272
|
+
const { daysOverdue, isSubscriptionActive } = useSubscription();
|
|
273
|
+
if (!isSubscriptionActive && daysOverdue >= 60) {
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", height: "100vh", width: "100%", alignItems: "center", justifyContent: "center", backgroundColor: "#f8fafc", color: "#0f172a", fontFamily: "system-ui, -apple-system, sans-serif" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { textAlign: "center", padding: "2rem", maxWidth: "32rem" }, children: [
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { style: { fontSize: "1.5rem", fontWeight: 600, marginBottom: "0.5rem" }, children: "This website is temporarily unavailable" }),
|
|
276
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { style: { color: "#64748b" }, children: "Please contact the site administrator if you believe this is an error." })
|
|
277
|
+
] }) });
|
|
278
|
+
}
|
|
279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
|
|
280
|
+
}
|
|
281
|
+
function CmsProviderInner({ config, adapter, children, iconMap, initialOverrides }) {
|
|
282
|
+
const [overrides, setOverrides] = (0, import_react3.useState)(initialOverrides || {});
|
|
283
|
+
const [savedOverrides, setSavedOverrides] = (0, import_react3.useState)(initialOverrides || {});
|
|
284
|
+
const [selectedId, setSelectedIdRaw] = (0, import_react3.useState)(null);
|
|
285
|
+
const [editMode, setEditMode] = (0, import_react3.useState)(false);
|
|
286
|
+
const [collectionChangedAt, setCollectionChangedAt] = (0, import_react3.useState)(0);
|
|
287
|
+
const registryRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
288
|
+
(0, import_react3.useEffect)(() => {
|
|
63
289
|
if (typeof window === "undefined" || typeof BroadcastChannel === "undefined") return;
|
|
64
290
|
const bc = new BroadcastChannel("admin-cms:collection-changed");
|
|
65
291
|
bc.onmessage = () => setCollectionChangedAt(Date.now());
|
|
66
292
|
return () => bc.close();
|
|
67
293
|
}, []);
|
|
68
|
-
const notifyCollectionChanged = (0,
|
|
294
|
+
const notifyCollectionChanged = (0, import_react3.useCallback)(() => {
|
|
69
295
|
setCollectionChangedAt(Date.now());
|
|
70
296
|
if (typeof BroadcastChannel !== "undefined") {
|
|
71
297
|
const bc = new BroadcastChannel("admin-cms:collection-changed");
|
|
@@ -73,12 +299,12 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
73
299
|
bc.close();
|
|
74
300
|
}
|
|
75
301
|
}, []);
|
|
76
|
-
(0,
|
|
302
|
+
(0, import_react3.useEffect)(() => {
|
|
77
303
|
if (typeof window === "undefined") return;
|
|
78
304
|
const params = new URLSearchParams(window.location.search);
|
|
79
305
|
if (params.get("__cms") === "edit") setEditMode(true);
|
|
80
306
|
}, []);
|
|
81
|
-
(0,
|
|
307
|
+
(0, import_react3.useEffect)(() => {
|
|
82
308
|
let cancelled = false;
|
|
83
309
|
adapter.getOverrides().then((o) => {
|
|
84
310
|
if (cancelled) return;
|
|
@@ -89,7 +315,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
89
315
|
cancelled = true;
|
|
90
316
|
};
|
|
91
317
|
}, [adapter]);
|
|
92
|
-
(0,
|
|
318
|
+
(0, import_react3.useEffect)(() => {
|
|
93
319
|
if (!editMode || typeof window === "undefined") return;
|
|
94
320
|
const parent = window.parent;
|
|
95
321
|
if (!parent || parent === window) return;
|
|
@@ -107,7 +333,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
107
333
|
window.addEventListener("message", onMsg);
|
|
108
334
|
return () => window.removeEventListener("message", onMsg);
|
|
109
335
|
}, [editMode]);
|
|
110
|
-
const setSelectedId = (0,
|
|
336
|
+
const setSelectedId = (0, import_react3.useCallback)(
|
|
111
337
|
(id) => {
|
|
112
338
|
setSelectedIdRaw(id);
|
|
113
339
|
if (editMode && typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
@@ -119,7 +345,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
119
345
|
},
|
|
120
346
|
[editMode]
|
|
121
347
|
);
|
|
122
|
-
const registerEditable = (0,
|
|
348
|
+
const registerEditable = (0, import_react3.useCallback)((meta) => {
|
|
123
349
|
registryRef.current.set(meta.id, meta);
|
|
124
350
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
125
351
|
window.parent.postMessage(
|
|
@@ -132,7 +358,7 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
132
358
|
);
|
|
133
359
|
}
|
|
134
360
|
}, []);
|
|
135
|
-
const unregisterEditable = (0,
|
|
361
|
+
const unregisterEditable = (0, import_react3.useCallback)((id) => {
|
|
136
362
|
registryRef.current.delete(id);
|
|
137
363
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
138
364
|
window.parent.postMessage(
|
|
@@ -145,14 +371,14 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
145
371
|
);
|
|
146
372
|
}
|
|
147
373
|
}, []);
|
|
148
|
-
const setOverride = (0,
|
|
374
|
+
const setOverride = (0, import_react3.useCallback)((id, value2) => {
|
|
149
375
|
setOverrides((prev) => ({ ...prev, [id]: value2 }));
|
|
150
376
|
}, []);
|
|
151
|
-
const save = (0,
|
|
377
|
+
const save = (0, import_react3.useCallback)(async () => {
|
|
152
378
|
await adapter.setOverrides(overrides);
|
|
153
379
|
setSavedOverrides(overrides);
|
|
154
380
|
}, [adapter, overrides]);
|
|
155
|
-
const reset = (0,
|
|
381
|
+
const reset = (0, import_react3.useCallback)(
|
|
156
382
|
async (id) => {
|
|
157
383
|
if (id) {
|
|
158
384
|
setOverrides((prev) => {
|
|
@@ -166,15 +392,15 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
166
392
|
},
|
|
167
393
|
[]
|
|
168
394
|
);
|
|
169
|
-
const isDirty = (0,
|
|
395
|
+
const isDirty = (0, import_react3.useMemo)(
|
|
170
396
|
() => JSON.stringify(overrides) !== JSON.stringify(savedOverrides),
|
|
171
397
|
[overrides, savedOverrides]
|
|
172
398
|
);
|
|
173
|
-
const getRegistered = (0,
|
|
399
|
+
const getRegistered = (0, import_react3.useCallback)(
|
|
174
400
|
() => Array.from(registryRef.current.values()),
|
|
175
401
|
[]
|
|
176
402
|
);
|
|
177
|
-
const value = (0,
|
|
403
|
+
const value = (0, import_react3.useMemo)(() => ({
|
|
178
404
|
config,
|
|
179
405
|
adapter,
|
|
180
406
|
overrides,
|
|
@@ -193,10 +419,10 @@ function CmsProvider({ config, adapter, children, iconMap, initialOverrides }) {
|
|
|
193
419
|
collectionChangedAt,
|
|
194
420
|
notifyCollectionChanged
|
|
195
421
|
}), [config, adapter, overrides, editMode, selectedId, setSelectedId, setOverride, registerEditable, unregisterEditable, getRegistered, save, reset, isDirty, iconMap, collectionChangedAt, notifyCollectionChanged]);
|
|
196
|
-
return /* @__PURE__ */ (0,
|
|
422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CmsContext.Provider, { value, children });
|
|
197
423
|
}
|
|
198
424
|
function useSubmit(formId) {
|
|
199
|
-
const ctx = (0,
|
|
425
|
+
const ctx = (0, import_react3.useContext)(CmsContext);
|
|
200
426
|
return async (data) => {
|
|
201
427
|
const submission = {
|
|
202
428
|
id: crypto.randomUUID(),
|
|
@@ -223,11 +449,11 @@ function useSubmit(formId) {
|
|
|
223
449
|
}
|
|
224
450
|
|
|
225
451
|
// src/editable.tsx
|
|
226
|
-
var
|
|
227
|
-
var
|
|
452
|
+
var import_react4 = require("react");
|
|
453
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
228
454
|
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength) {
|
|
229
455
|
const ctx = useCmsOptional();
|
|
230
|
-
(0,
|
|
456
|
+
(0, import_react4.useEffect)(() => {
|
|
231
457
|
if (!ctx) return;
|
|
232
458
|
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength });
|
|
233
459
|
return () => ctx.unregisterEditable(id);
|
|
@@ -260,7 +486,7 @@ function EditableText({
|
|
|
260
486
|
e.stopPropagation();
|
|
261
487
|
ctx.setSelectedId(id);
|
|
262
488
|
};
|
|
263
|
-
return (0,
|
|
489
|
+
return (0, import_react4.createElement)(
|
|
264
490
|
as,
|
|
265
491
|
{
|
|
266
492
|
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
@@ -291,7 +517,7 @@ function EditableImage({
|
|
|
291
517
|
e.stopPropagation();
|
|
292
518
|
ctx.setSelectedId(id);
|
|
293
519
|
};
|
|
294
|
-
return /* @__PURE__ */ (0,
|
|
520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
295
521
|
"img",
|
|
296
522
|
{
|
|
297
523
|
src: value,
|
|
@@ -304,22 +530,19 @@ function EditableImage({
|
|
|
304
530
|
}
|
|
305
531
|
);
|
|
306
532
|
}
|
|
307
|
-
function
|
|
533
|
+
function EditableFile({
|
|
308
534
|
id,
|
|
309
535
|
label,
|
|
310
536
|
section,
|
|
311
537
|
pageId,
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
text,
|
|
538
|
+
src,
|
|
539
|
+
defaultUrl = "",
|
|
315
540
|
className,
|
|
316
|
-
|
|
541
|
+
children
|
|
317
542
|
}) {
|
|
318
|
-
const
|
|
319
|
-
const ctx = useRegister(id, "
|
|
320
|
-
const
|
|
321
|
-
const hrefValue = override?.href ?? href;
|
|
322
|
-
const textValue = override?.text ?? defaultText;
|
|
543
|
+
const initialUrl = src || defaultUrl;
|
|
544
|
+
const ctx = useRegister(id, "file", label, section, pageId, initialUrl);
|
|
545
|
+
const value = ctx && Object.prototype.hasOwnProperty.call(ctx.overrides, id) ? String(ctx.overrides[id] ?? initialUrl) : initialUrl;
|
|
323
546
|
const active = !!ctx?.editMode;
|
|
324
547
|
const selected = ctx?.selectedId === id;
|
|
325
548
|
const onClick = (e) => {
|
|
@@ -328,250 +551,113 @@ function EditableLink({
|
|
|
328
551
|
e.stopPropagation();
|
|
329
552
|
ctx.setSelectedId(id);
|
|
330
553
|
};
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
554
|
+
if (children) {
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
556
|
+
"div",
|
|
557
|
+
{
|
|
558
|
+
"data-cms-id": id,
|
|
559
|
+
onClick: active ? onClick : void 0,
|
|
560
|
+
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
561
|
+
children: children(value)
|
|
562
|
+
}
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
566
|
+
"div",
|
|
336
567
|
{
|
|
337
|
-
href: hrefValue,
|
|
338
|
-
target: computedTarget,
|
|
339
|
-
rel: computedRel,
|
|
340
568
|
"data-cms-id": id,
|
|
341
569
|
onClick: active ? onClick : void 0,
|
|
342
570
|
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
343
|
-
children:
|
|
571
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
572
|
+
"iframe",
|
|
573
|
+
{
|
|
574
|
+
src: value,
|
|
575
|
+
className: "w-full h-[500px] rounded-xl border-0",
|
|
576
|
+
title: label || id
|
|
577
|
+
}
|
|
578
|
+
)
|
|
344
579
|
}
|
|
345
580
|
);
|
|
346
581
|
}
|
|
347
|
-
function
|
|
582
|
+
function EditableLink({
|
|
348
583
|
id,
|
|
349
584
|
label,
|
|
350
585
|
section,
|
|
351
586
|
pageId,
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
itemSchema,
|
|
356
|
-
fixedLength,
|
|
587
|
+
href,
|
|
588
|
+
children,
|
|
589
|
+
text,
|
|
357
590
|
className,
|
|
358
|
-
|
|
591
|
+
target
|
|
359
592
|
}) {
|
|
360
|
-
const
|
|
361
|
-
const
|
|
362
|
-
const
|
|
593
|
+
const defaultText = text ?? (typeof children === "string" ? children : "");
|
|
594
|
+
const ctx = useRegister(id, "link", label, section, pageId, { href, text: defaultText });
|
|
595
|
+
const override = ctx?.overrides[id];
|
|
596
|
+
const hrefValue = override?.href ?? href;
|
|
597
|
+
const textValue = override?.text ?? defaultText;
|
|
363
598
|
const active = !!ctx?.editMode;
|
|
364
599
|
const selected = ctx?.selectedId === id;
|
|
365
600
|
const onClick = (e) => {
|
|
366
601
|
if (!active || !ctx) return;
|
|
367
602
|
e.preventDefault();
|
|
368
|
-
e.stopPropagation();
|
|
369
|
-
ctx.setSelectedId(id);
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
var import_lucide_react2 = require("lucide-react");
|
|
385
|
-
var import_lucide_react3 = require("lucide-react");
|
|
386
|
-
|
|
387
|
-
// src/subscription/SubscriptionProvider.tsx
|
|
388
|
-
var import_react3 = require("react");
|
|
389
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
390
|
-
var SubscriptionContext = (0, import_react3.createContext)(void 0);
|
|
391
|
-
function useSubscriptionContext() {
|
|
392
|
-
const ctx = (0, import_react3.useContext)(SubscriptionContext);
|
|
393
|
-
if (!ctx) {
|
|
394
|
-
throw new Error("useSubscriptionContext must be used within a SubscriptionProvider");
|
|
395
|
-
}
|
|
396
|
-
return ctx;
|
|
397
|
-
}
|
|
398
|
-
function useSubscription() {
|
|
399
|
-
return useSubscriptionContext();
|
|
400
|
-
}
|
|
401
|
-
function SubscriptionProvider({
|
|
402
|
-
children,
|
|
403
|
-
apiUrl,
|
|
404
|
-
projectId,
|
|
405
|
-
email
|
|
406
|
-
}) {
|
|
407
|
-
const [subscription, setSubscription] = (0, import_react3.useState)(null);
|
|
408
|
-
const [loading, setLoading] = (0, import_react3.useState)(true);
|
|
409
|
-
const [error, setError] = (0, import_react3.useState)(null);
|
|
410
|
-
const fetchSubscription = (0, import_react3.useCallback)(
|
|
411
|
-
async (silent = false) => {
|
|
412
|
-
if (!apiUrl || !projectId) {
|
|
413
|
-
setLoading(false);
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
if (!silent) setLoading(true);
|
|
417
|
-
setError(null);
|
|
418
|
-
try {
|
|
419
|
-
const res = await fetch(`${apiUrl}/api/validate-subscription`, {
|
|
420
|
-
method: "POST",
|
|
421
|
-
headers: { "Content-Type": "application/json" },
|
|
422
|
-
body: JSON.stringify({ projectId })
|
|
423
|
-
});
|
|
424
|
-
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
425
|
-
const data = await res.json();
|
|
426
|
-
setSubscription({
|
|
427
|
-
subscriptionStatus: data.valid ? data.status : "inactive",
|
|
428
|
-
currentPeriodEnd: data.expiryDate,
|
|
429
|
-
customerEmail: email,
|
|
430
|
-
subscriptionId: data._id,
|
|
431
|
-
stripeCustomerId: data.stripeCustomerId,
|
|
432
|
-
stripePaymentLink: data.stripePaymentLink,
|
|
433
|
-
valid: data.valid
|
|
434
|
-
});
|
|
435
|
-
} catch (err) {
|
|
436
|
-
console.error("SubscriptionProvider Error:", err);
|
|
437
|
-
setError(err.message || "Failed to fetch subscription");
|
|
438
|
-
setSubscription({ subscriptionStatus: "active", valid: true });
|
|
439
|
-
} finally {
|
|
440
|
-
setLoading(false);
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
[apiUrl, projectId, email]
|
|
444
|
-
);
|
|
445
|
-
(0, import_react3.useEffect)(() => {
|
|
446
|
-
fetchSubscription();
|
|
447
|
-
const handleFocus = () => {
|
|
448
|
-
fetchSubscription(true);
|
|
449
|
-
};
|
|
450
|
-
window.addEventListener("focus", handleFocus);
|
|
451
|
-
let intervalId;
|
|
452
|
-
if (subscription && !subscription.valid) {
|
|
453
|
-
intervalId = setInterval(() => {
|
|
454
|
-
fetchSubscription(true);
|
|
455
|
-
}, 1e4);
|
|
456
|
-
}
|
|
457
|
-
return () => {
|
|
458
|
-
window.removeEventListener("focus", handleFocus);
|
|
459
|
-
if (intervalId) clearInterval(intervalId);
|
|
460
|
-
};
|
|
461
|
-
}, [fetchSubscription, subscription?.valid]);
|
|
462
|
-
const value = {
|
|
463
|
-
subscription,
|
|
464
|
-
loading,
|
|
465
|
-
error,
|
|
466
|
-
refetch: fetchSubscription,
|
|
467
|
-
isSubscriptionActive: subscription?.valid ?? true,
|
|
468
|
-
config: { apiUrl, projectId }
|
|
469
|
-
};
|
|
470
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SubscriptionContext.Provider, { value, children });
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// src/subscription/SubscriptionPage.tsx
|
|
474
|
-
var import_react4 = require("react");
|
|
475
|
-
var import_lucide_react = require("lucide-react");
|
|
476
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
477
|
-
function SubscriptionPage() {
|
|
478
|
-
const { subscription, loading, config } = useSubscription();
|
|
479
|
-
const [actionLoading, setActionLoading] = (0, import_react4.useState)(null);
|
|
480
|
-
const status = subscription?.subscriptionStatus || "inactive";
|
|
481
|
-
const isValid = subscription?.valid ?? false;
|
|
482
|
-
const handleSubscribe = () => {
|
|
483
|
-
if (!subscription?.stripePaymentLink) {
|
|
484
|
-
alert("No payment link found. Please contact support.");
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
const raw = subscription.stripePaymentLink;
|
|
488
|
-
const url = raw.startsWith("http") ? raw : `https://buy.stripe.com/${raw}`;
|
|
489
|
-
window.open(url, "_blank");
|
|
490
|
-
};
|
|
491
|
-
const handleManageBilling = async () => {
|
|
492
|
-
if (!subscription?.stripeCustomerId) {
|
|
493
|
-
alert("No customer ID available. Please contact support.");
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
setActionLoading("billing");
|
|
497
|
-
try {
|
|
498
|
-
const returnUrl = window.location.href;
|
|
499
|
-
const apiUrl = config.apiUrl || "https://dev-soft-admin-sigma.vercel.app";
|
|
500
|
-
const res = await fetch(`${apiUrl}/api/create-billing-session`, {
|
|
501
|
-
method: "POST",
|
|
502
|
-
headers: { "Content-Type": "application/json" },
|
|
503
|
-
body: JSON.stringify({
|
|
504
|
-
customerId: subscription.stripeCustomerId,
|
|
505
|
-
returnUrl
|
|
506
|
-
})
|
|
507
|
-
});
|
|
508
|
-
if (!res.ok) throw new Error(`Server error: ${res.status}`);
|
|
509
|
-
const data = await res.json();
|
|
510
|
-
if (data.url) {
|
|
511
|
-
window.open(data.url, "_blank");
|
|
512
|
-
} else {
|
|
513
|
-
alert("Could not create billing session.");
|
|
514
|
-
}
|
|
515
|
-
} catch (err) {
|
|
516
|
-
alert(`Portal failed: ${err.message}`);
|
|
517
|
-
} finally {
|
|
518
|
-
setActionLoading(null);
|
|
603
|
+
e.stopPropagation();
|
|
604
|
+
ctx.setSelectedId(id);
|
|
605
|
+
};
|
|
606
|
+
const isExternal = hrefValue.startsWith("http");
|
|
607
|
+
const computedTarget = target || (isExternal ? "_blank" : void 0);
|
|
608
|
+
const computedRel = computedTarget === "_blank" ? "noopener noreferrer" : void 0;
|
|
609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
610
|
+
"a",
|
|
611
|
+
{
|
|
612
|
+
href: hrefValue,
|
|
613
|
+
target: computedTarget,
|
|
614
|
+
rel: computedRel,
|
|
615
|
+
"data-cms-id": id,
|
|
616
|
+
onClick: active ? onClick : void 0,
|
|
617
|
+
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
618
|
+
children: typeof children !== "undefined" ? children : textValue
|
|
519
619
|
}
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
function EditableList({
|
|
623
|
+
id,
|
|
624
|
+
label,
|
|
625
|
+
section,
|
|
626
|
+
pageId,
|
|
627
|
+
initialItems,
|
|
628
|
+
renderItem,
|
|
629
|
+
renderList,
|
|
630
|
+
itemSchema,
|
|
631
|
+
fixedLength,
|
|
632
|
+
className,
|
|
633
|
+
listClassName
|
|
634
|
+
}) {
|
|
635
|
+
const ctx = useRegister(id, "list", label, section, pageId, initialItems, itemSchema, fixedLength);
|
|
636
|
+
const rawValue = ctx && Object.prototype.hasOwnProperty.call(ctx.overrides, id) ? ctx.overrides[id] : initialItems;
|
|
637
|
+
const value = Array.isArray(rawValue) ? rawValue : initialItems;
|
|
638
|
+
const active = !!ctx?.editMode;
|
|
639
|
+
const selected = ctx?.selectedId === id;
|
|
640
|
+
const onClick = (e) => {
|
|
641
|
+
if (!active || !ctx) return;
|
|
642
|
+
e.preventDefault();
|
|
643
|
+
e.stopPropagation();
|
|
644
|
+
ctx.setSelectedId(id);
|
|
520
645
|
};
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: isValid ? "Subscription Active" : "Subscription Inactive" }),
|
|
531
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "mt-2 text-sm text-slate-600", children: isValid ? "Your subscription is currently active and in good standing." : "Your project requires an active subscription to access the administration panel." })
|
|
532
|
-
] }),
|
|
533
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "p-8", children: [
|
|
534
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "space-y-4", children: [
|
|
535
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
536
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Status" }),
|
|
537
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: `inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold capitalize ${isValid ? "bg-emerald-100 text-emerald-700" : "bg-rose-100 text-rose-700"}`, children: status })
|
|
538
|
-
] }),
|
|
539
|
-
subscription?.currentPeriodEnd && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center justify-between rounded-xl bg-slate-50 p-4 border border-slate-100", children: [
|
|
540
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-medium text-slate-500", children: "Next Billing Date" }),
|
|
541
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-sm font-semibold text-slate-900", children: new Date(subscription.currentPeriodEnd).toLocaleDateString() })
|
|
542
|
-
] })
|
|
543
|
-
] }),
|
|
544
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mt-8 space-y-3", children: [
|
|
545
|
-
!isValid && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
546
|
-
"button",
|
|
547
|
-
{
|
|
548
|
-
onClick: handleSubscribe,
|
|
549
|
-
className: "group flex w-full items-center justify-center gap-2 rounded-xl bg-indigo-600 px-4 py-3.5 text-sm font-semibold text-white shadow-sm transition-all hover:bg-indigo-700 hover:shadow",
|
|
550
|
-
children: [
|
|
551
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.CreditCard, { className: "h-4 w-4" }),
|
|
552
|
-
"Pay Now to Restore Access",
|
|
553
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.ExternalLink, { className: "h-3.5 w-3.5 opacity-70 transition-transform group-hover:translate-x-0.5" })
|
|
554
|
-
]
|
|
555
|
-
}
|
|
556
|
-
),
|
|
557
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
558
|
-
"button",
|
|
559
|
-
{
|
|
560
|
-
onClick: handleManageBilling,
|
|
561
|
-
disabled: actionLoading === "billing",
|
|
562
|
-
className: "group flex w-full items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-3.5 text-sm font-semibold text-slate-700 shadow-sm transition-all hover:bg-slate-50 hover:text-slate-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50",
|
|
563
|
-
children: [
|
|
564
|
-
actionLoading === "billing" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-slate-300 border-t-slate-600" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.Settings, { className: "h-4 w-4 text-slate-400 group-hover:text-slate-600" }),
|
|
565
|
-
"Manage Billing & Invoices"
|
|
566
|
-
]
|
|
567
|
-
}
|
|
568
|
-
)
|
|
569
|
-
] })
|
|
570
|
-
] })
|
|
571
|
-
] }) });
|
|
646
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
647
|
+
"div",
|
|
648
|
+
{
|
|
649
|
+
"data-cms-id": id,
|
|
650
|
+
onClick: active ? onClick : void 0,
|
|
651
|
+
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
652
|
+
children: renderList ? renderList(value) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: listClassName, children: renderItem && value.map(renderItem) })
|
|
653
|
+
}
|
|
654
|
+
);
|
|
572
655
|
}
|
|
573
656
|
|
|
574
657
|
// src/admin/AdminApp.tsx
|
|
658
|
+
var import_react5 = require("react");
|
|
659
|
+
var import_lucide_react2 = require("lucide-react");
|
|
660
|
+
var import_lucide_react3 = require("lucide-react");
|
|
575
661
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
576
662
|
async function handleImageFile(file, onUrl, uploadImage) {
|
|
577
663
|
if (uploadImage) {
|
|
@@ -602,106 +688,111 @@ function AdminAppContent() {
|
|
|
602
688
|
} catch (e) {
|
|
603
689
|
}
|
|
604
690
|
const isSubscriptionActive = subscriptionCtx?.isSubscriptionActive ?? true;
|
|
691
|
+
const daysOverdue = subscriptionCtx?.daysOverdue ?? 0;
|
|
605
692
|
if (!isSubscriptionActive) {
|
|
606
693
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-col lg:flex-row h-screen w-full overflow-hidden bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {}) });
|
|
607
694
|
}
|
|
608
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col
|
|
609
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-screen w-full bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900 overflow-hidden", children: [
|
|
696
|
+
daysOverdue > 0 && daysOverdue <= 15 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-amber-400 text-amber-950 px-4 py-2.5 text-center text-sm font-semibold shadow-sm z-50", children: "Your account has an overdue balance. Please update your payment." }),
|
|
697
|
+
daysOverdue > 15 && daysOverdue < 30 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-rose-600 text-white px-4 py-2.5 text-center text-sm font-bold shadow-sm z-50", children: "Attention: If you do not settle your balance, your account will be suspended soon." }),
|
|
698
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
|
|
699
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg:hidden flex items-center justify-between bg-white/80 backdrop-blur-xl border-b border-slate-200 px-4 py-3 shrink-0 z-20 relative", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
700
|
+
ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
|
|
701
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-bold text-slate-900 tracking-tight", children: "Admin CMS" })
|
|
702
|
+
] }) }),
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { className: "flex w-full lg:w-64 shrink-0 flex-col border-b lg:border-b-0 lg:border-r border-slate-200 bg-white/80 backdrop-blur-xl shadow-sm z-10 overflow-hidden", children: [
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hidden lg:block border-b border-slate-200 px-6 py-5 bg-white/50", children: [
|
|
705
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 mb-1", children: [
|
|
706
|
+
ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
|
|
707
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: "Admin CMS" })
|
|
708
|
+
] }),
|
|
709
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
|
|
618
710
|
] }),
|
|
619
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
)
|
|
676
|
-
] }),
|
|
677
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: [
|
|
678
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between text-xs text-slate-500 mb-4", children: [
|
|
679
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Storage Adapter" }),
|
|
680
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-semibold px-2 py-0.5 rounded-full bg-slate-200 text-slate-700", children: ctx.adapter.name })
|
|
711
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("nav", { className: "flex flex-row lg:flex-col overflow-x-auto lg:overflow-visible space-x-2 lg:space-x-0 lg:space-y-1.5 p-3 lg:p-4 text-sm font-medium hide-scrollbar", children: [
|
|
712
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
713
|
+
SideItem,
|
|
714
|
+
{
|
|
715
|
+
active: section === "pages",
|
|
716
|
+
onClick: () => setSection("pages"),
|
|
717
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileText, { className: "h-4 w-4 shrink-0" }),
|
|
718
|
+
children: "Pages"
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
722
|
+
SideItem,
|
|
723
|
+
{
|
|
724
|
+
active: section === "collections",
|
|
725
|
+
onClick: () => setSection("collections"),
|
|
726
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
|
|
727
|
+
children: "Collections"
|
|
728
|
+
}
|
|
729
|
+
),
|
|
730
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
731
|
+
SideItem,
|
|
732
|
+
{
|
|
733
|
+
active: section === "submissions",
|
|
734
|
+
onClick: () => setSection("submissions"),
|
|
735
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-4 w-4 shrink-0" }),
|
|
736
|
+
children: "Data"
|
|
737
|
+
}
|
|
738
|
+
),
|
|
739
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
740
|
+
SideItem,
|
|
741
|
+
{
|
|
742
|
+
active: section === "config",
|
|
743
|
+
onClick: () => setSection("config"),
|
|
744
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
|
|
745
|
+
children: "Config"
|
|
746
|
+
}
|
|
747
|
+
),
|
|
748
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
749
|
+
SideItem,
|
|
750
|
+
{
|
|
751
|
+
active: section === "settings",
|
|
752
|
+
onClick: () => setSection("settings"),
|
|
753
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Settings, { className: "h-4 w-4 shrink-0" }),
|
|
754
|
+
children: "Settings"
|
|
755
|
+
}
|
|
756
|
+
),
|
|
757
|
+
subscriptionCtx && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
758
|
+
SideItem,
|
|
759
|
+
{
|
|
760
|
+
active: section === "subscription",
|
|
761
|
+
onClick: () => setSection("subscription"),
|
|
762
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CreditCard, { className: "h-4 w-4 shrink-0" }),
|
|
763
|
+
children: "Subscription"
|
|
764
|
+
}
|
|
765
|
+
)
|
|
681
766
|
] }),
|
|
682
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
683
|
-
"
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
767
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: [
|
|
768
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between text-xs text-slate-500 mb-4", children: [
|
|
769
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Storage Adapter" }),
|
|
770
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-semibold px-2 py-0.5 rounded-full bg-slate-200 text-slate-700", children: ctx.adapter.name })
|
|
771
|
+
] }),
|
|
772
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
773
|
+
"button",
|
|
774
|
+
{
|
|
775
|
+
onClick: async () => {
|
|
776
|
+
await fetch("/api/admin/auth?action=logout", { method: "POST" });
|
|
777
|
+
window.location.href = "/admin/login";
|
|
778
|
+
},
|
|
779
|
+
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",
|
|
780
|
+
children: [
|
|
781
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.LogOut, { className: "w-4 h-4" }),
|
|
782
|
+
"Logout"
|
|
783
|
+
]
|
|
784
|
+
}
|
|
785
|
+
)
|
|
786
|
+
] })
|
|
787
|
+
] }),
|
|
788
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("main", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
|
|
789
|
+
section === "pages" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PagesSection, {}),
|
|
790
|
+
section === "collections" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollectionsSection, {}),
|
|
791
|
+
section === "submissions" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubmissionsSection, {}),
|
|
792
|
+
section === "config" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ConfigSection, {}),
|
|
793
|
+
section === "settings" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SettingsSection, {}),
|
|
794
|
+
section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {})
|
|
696
795
|
] })
|
|
697
|
-
] }),
|
|
698
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("main", { className: "flex-1 overflow-hidden relative flex flex-col", children: [
|
|
699
|
-
section === "pages" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PagesSection, {}),
|
|
700
|
-
section === "collections" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollectionsSection, {}),
|
|
701
|
-
section === "submissions" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubmissionsSection, {}),
|
|
702
|
-
section === "config" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ConfigSection, {}),
|
|
703
|
-
section === "settings" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SettingsSection, {}),
|
|
704
|
-
section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {})
|
|
705
796
|
] })
|
|
706
797
|
] });
|
|
707
798
|
}
|
|
@@ -1098,6 +1189,41 @@ function FieldEditor({
|
|
|
1098
1189
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-white text-xs font-medium px-2 py-1 bg-black/50 rounded backdrop-blur", children: "Preview" }) })
|
|
1099
1190
|
] }) : null
|
|
1100
1191
|
] }),
|
|
1192
|
+
meta.type === "file" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
1193
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
1194
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1195
|
+
"input",
|
|
1196
|
+
{
|
|
1197
|
+
type: "url",
|
|
1198
|
+
value: String(value ?? ""),
|
|
1199
|
+
onChange: (e) => onChange(e.target.value),
|
|
1200
|
+
placeholder: "https://... or upload PDF/file",
|
|
1201
|
+
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"
|
|
1202
|
+
}
|
|
1203
|
+
),
|
|
1204
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex-shrink-0 cursor-pointer rounded-xl bg-indigo-50 px-4 py-2.5 text-sm font-semibold text-indigo-700 hover:bg-indigo-100 transition-colors border border-indigo-100 flex items-center justify-center", children: [
|
|
1205
|
+
"Upload File",
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1207
|
+
"input",
|
|
1208
|
+
{
|
|
1209
|
+
type: "file",
|
|
1210
|
+
accept: "application/pdf,.pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,image/*",
|
|
1211
|
+
className: "hidden",
|
|
1212
|
+
onChange: (e) => {
|
|
1213
|
+
const file = e.target.files?.[0];
|
|
1214
|
+
if (file) {
|
|
1215
|
+
void handleImageFile(file, onChange, ctx.uploadImage);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
)
|
|
1220
|
+
] })
|
|
1221
|
+
] }),
|
|
1222
|
+
value ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-3 bg-slate-50 text-xs font-mono text-slate-600 truncate flex items-center gap-2", children: [
|
|
1223
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "\u{1F4C4} File URL:" }),
|
|
1224
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate text-indigo-600 font-semibold", children: String(value) })
|
|
1225
|
+
] }) : null
|
|
1226
|
+
] }),
|
|
1101
1227
|
meta.type === "link" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-4 bg-slate-50 p-4 rounded-xl border border-slate-100", children: [
|
|
1102
1228
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block", children: [
|
|
1103
1229
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold text-slate-500 uppercase tracking-wide", children: "Link Text" }),
|
|
@@ -1618,7 +1744,149 @@ function CollectionEditor({ collection }) {
|
|
|
1618
1744
|
value: String(editing[f.id] ?? ""),
|
|
1619
1745
|
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
1620
1746
|
}
|
|
1621
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime5.
|
|
1747
|
+
) : f.type === "color" && !f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
1748
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1749
|
+
"input",
|
|
1750
|
+
{
|
|
1751
|
+
type: "color",
|
|
1752
|
+
value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
|
|
1753
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
1754
|
+
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
1755
|
+
}
|
|
1756
|
+
),
|
|
1757
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1758
|
+
"input",
|
|
1759
|
+
{
|
|
1760
|
+
type: "text",
|
|
1761
|
+
value: String(editing[f.id] ?? ""),
|
|
1762
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
1763
|
+
placeholder: "#000000",
|
|
1764
|
+
className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
1765
|
+
}
|
|
1766
|
+
),
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1768
|
+
"div",
|
|
1769
|
+
{
|
|
1770
|
+
className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
1771
|
+
style: { backgroundColor: String(editing[f.id] ?? "#000000") }
|
|
1772
|
+
}
|
|
1773
|
+
)
|
|
1774
|
+
] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
1775
|
+
(Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : []).map((item, idx) => {
|
|
1776
|
+
const colorVal = String(item ?? "").trim();
|
|
1777
|
+
const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
|
|
1778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
|
|
1779
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1780
|
+
"input",
|
|
1781
|
+
{
|
|
1782
|
+
type: "color",
|
|
1783
|
+
value: validHex.length === 7 ? validHex : "#000000",
|
|
1784
|
+
onChange: (e) => {
|
|
1785
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1786
|
+
arr[idx] = e.target.value;
|
|
1787
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
1788
|
+
},
|
|
1789
|
+
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
1790
|
+
}
|
|
1791
|
+
),
|
|
1792
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1793
|
+
"input",
|
|
1794
|
+
{
|
|
1795
|
+
type: "text",
|
|
1796
|
+
value: colorVal,
|
|
1797
|
+
onChange: (e) => {
|
|
1798
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1799
|
+
arr[idx] = e.target.value;
|
|
1800
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
1801
|
+
},
|
|
1802
|
+
placeholder: "#1c2a44",
|
|
1803
|
+
className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
1804
|
+
}
|
|
1805
|
+
),
|
|
1806
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1807
|
+
"div",
|
|
1808
|
+
{
|
|
1809
|
+
className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
1810
|
+
style: { backgroundColor: colorVal || "#000000" }
|
|
1811
|
+
}
|
|
1812
|
+
),
|
|
1813
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1814
|
+
"button",
|
|
1815
|
+
{
|
|
1816
|
+
type: "button",
|
|
1817
|
+
onClick: () => {
|
|
1818
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1819
|
+
arr.splice(idx, 1);
|
|
1820
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
1821
|
+
},
|
|
1822
|
+
className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
|
|
1823
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
1824
|
+
}
|
|
1825
|
+
)
|
|
1826
|
+
] }, idx);
|
|
1827
|
+
}),
|
|
1828
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1829
|
+
"button",
|
|
1830
|
+
{
|
|
1831
|
+
type: "button",
|
|
1832
|
+
onClick: () => {
|
|
1833
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1834
|
+
arr.push("#000000");
|
|
1835
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
1836
|
+
},
|
|
1837
|
+
className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 rounded-lg border border-indigo-100 transition-colors",
|
|
1838
|
+
children: [
|
|
1839
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
1840
|
+
" Add Color"
|
|
1841
|
+
]
|
|
1842
|
+
}
|
|
1843
|
+
)
|
|
1844
|
+
] }) : f.type === "list" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
1845
|
+
(Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
|
|
1846
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1847
|
+
"input",
|
|
1848
|
+
{
|
|
1849
|
+
type: "text",
|
|
1850
|
+
value: String(item ?? ""),
|
|
1851
|
+
onChange: (e) => {
|
|
1852
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
1853
|
+
arr[idx] = e.target.value;
|
|
1854
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
1855
|
+
},
|
|
1856
|
+
className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
1857
|
+
}
|
|
1858
|
+
),
|
|
1859
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1860
|
+
"button",
|
|
1861
|
+
{
|
|
1862
|
+
type: "button",
|
|
1863
|
+
onClick: () => {
|
|
1864
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
1865
|
+
arr.splice(idx, 1);
|
|
1866
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
1867
|
+
},
|
|
1868
|
+
className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
|
|
1869
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
1870
|
+
}
|
|
1871
|
+
)
|
|
1872
|
+
] }, idx)),
|
|
1873
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1874
|
+
"button",
|
|
1875
|
+
{
|
|
1876
|
+
type: "button",
|
|
1877
|
+
onClick: () => {
|
|
1878
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
1879
|
+
arr.push("");
|
|
1880
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
1881
|
+
},
|
|
1882
|
+
className: "inline-flex items-center gap-1.5 px-3 py-2 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-semibold rounded-xl transition-colors",
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
1885
|
+
" Add Item"
|
|
1886
|
+
]
|
|
1887
|
+
}
|
|
1888
|
+
)
|
|
1889
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1622
1890
|
"input",
|
|
1623
1891
|
{
|
|
1624
1892
|
value: String(editing[f.id] ?? ""),
|
|
@@ -2471,6 +2739,7 @@ async function sendEmailNotification(content, apiUrl) {
|
|
|
2471
2739
|
AdminApp,
|
|
2472
2740
|
AdminLogin,
|
|
2473
2741
|
CmsProvider,
|
|
2742
|
+
EditableFile,
|
|
2474
2743
|
EditableImage,
|
|
2475
2744
|
EditableLink,
|
|
2476
2745
|
EditableList,
|