admin-lib-cms 1.1.8 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.d.mts +2 -0
- package/dist/auth.d.ts +2 -0
- package/dist/auth.js +18 -1
- package/dist/auth.mjs +19 -2
- package/dist/chunk-4KJKAYIC.mjs +153 -0
- package/dist/emails/index.js +2 -1
- package/dist/emails/index.mjs +1 -1
- package/dist/index.js +79 -5
- package/dist/index.mjs +80 -6
- package/package.json +1 -1
package/dist/auth.d.mts
CHANGED
package/dist/auth.d.ts
CHANGED
package/dist/auth.js
CHANGED
|
@@ -44,7 +44,24 @@ function createAuthHandler({ adapter, jwtSecret }) {
|
|
|
44
44
|
const action = url.searchParams.get("action");
|
|
45
45
|
if (request.method === "GET") {
|
|
46
46
|
const users = await adapter.listEntries("usersAdmin");
|
|
47
|
-
|
|
47
|
+
let authenticated = false;
|
|
48
|
+
let user = null;
|
|
49
|
+
const cookieHeader = request.headers.get("cookie") || "";
|
|
50
|
+
const match = cookieHeader.match(/admin_token=([^;]+)/);
|
|
51
|
+
const token = match ? match[1] : null;
|
|
52
|
+
if (token) {
|
|
53
|
+
try {
|
|
54
|
+
const { payload } = await (0, import_jose.jwtVerify)(token, secret);
|
|
55
|
+
authenticated = true;
|
|
56
|
+
user = { email: payload.email, id: payload.id };
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return import_server.NextResponse.json({
|
|
61
|
+
hasUsers: users && users.length > 0,
|
|
62
|
+
authenticated,
|
|
63
|
+
user
|
|
64
|
+
});
|
|
48
65
|
}
|
|
49
66
|
if (request.method === "POST") {
|
|
50
67
|
let body = {};
|
package/dist/auth.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/auth.ts
|
|
2
2
|
import { NextResponse } from "next/server";
|
|
3
3
|
import bcrypt from "bcryptjs";
|
|
4
|
-
import { SignJWT } from "jose";
|
|
4
|
+
import { SignJWT, jwtVerify } from "jose";
|
|
5
5
|
function createAuthHandler({ adapter, jwtSecret }) {
|
|
6
6
|
const secret = new TextEncoder().encode(jwtSecret || "fallback_secret_for_development_only");
|
|
7
7
|
return async function handler(request) {
|
|
@@ -10,7 +10,24 @@ function createAuthHandler({ adapter, jwtSecret }) {
|
|
|
10
10
|
const action = url.searchParams.get("action");
|
|
11
11
|
if (request.method === "GET") {
|
|
12
12
|
const users = await adapter.listEntries("usersAdmin");
|
|
13
|
-
|
|
13
|
+
let authenticated = false;
|
|
14
|
+
let user = null;
|
|
15
|
+
const cookieHeader = request.headers.get("cookie") || "";
|
|
16
|
+
const match = cookieHeader.match(/admin_token=([^;]+)/);
|
|
17
|
+
const token = match ? match[1] : null;
|
|
18
|
+
if (token) {
|
|
19
|
+
try {
|
|
20
|
+
const { payload } = await jwtVerify(token, secret);
|
|
21
|
+
authenticated = true;
|
|
22
|
+
user = { email: payload.email, id: payload.id };
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return NextResponse.json({
|
|
27
|
+
hasUsers: users && users.length > 0,
|
|
28
|
+
authenticated,
|
|
29
|
+
user
|
|
30
|
+
});
|
|
14
31
|
}
|
|
15
32
|
if (request.method === "POST") {
|
|
16
33
|
let body = {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// src/emails/templates/default.ts
|
|
2
|
+
function generateDefaultTemplate(data, title, description, companyName = "Admin CMS") {
|
|
3
|
+
const items = Object.entries(data).filter(([_, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => {
|
|
4
|
+
const label = key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase());
|
|
5
|
+
const displayValue = Array.isArray(value) ? value.join(", ") : String(value);
|
|
6
|
+
return `
|
|
7
|
+
<div class="detail-item">
|
|
8
|
+
<span class="detail-label">${label}</span>
|
|
9
|
+
<span class="detail-value">${displayValue}</span>
|
|
10
|
+
</div>
|
|
11
|
+
`;
|
|
12
|
+
}).join("");
|
|
13
|
+
return `
|
|
14
|
+
<!DOCTYPE html>
|
|
15
|
+
<html lang="en">
|
|
16
|
+
<head>
|
|
17
|
+
<meta charset="UTF-8">
|
|
18
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
19
|
+
<title>${title}</title>
|
|
20
|
+
<style>
|
|
21
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
22
|
+
body {
|
|
23
|
+
background-color: #f4f4f5;
|
|
24
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
25
|
+
color: #18181b;
|
|
26
|
+
line-height: 1.5;
|
|
27
|
+
}
|
|
28
|
+
.wrapper { width: 100%; padding: 40px 20px; }
|
|
29
|
+
.container { max-width: 600px; margin: 0 auto; }
|
|
30
|
+
.card {
|
|
31
|
+
background: #ffffff;
|
|
32
|
+
border-radius: 12px;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
35
|
+
border: 1px solid #e4e4e7;
|
|
36
|
+
}
|
|
37
|
+
.header {
|
|
38
|
+
background: #1a2d42;
|
|
39
|
+
padding: 40px 32px;
|
|
40
|
+
text-align: center;
|
|
41
|
+
border-bottom: 4px solid #d4af37;
|
|
42
|
+
}
|
|
43
|
+
.header h1 {
|
|
44
|
+
color: #ffffff;
|
|
45
|
+
font-size: 24px;
|
|
46
|
+
font-weight: 700;
|
|
47
|
+
margin-bottom: 8px;
|
|
48
|
+
text-transform: uppercase;
|
|
49
|
+
letter-spacing: 0.05em;
|
|
50
|
+
}
|
|
51
|
+
.header p {
|
|
52
|
+
color: rgba(255, 255, 255, 0.9);
|
|
53
|
+
font-size: 14px;
|
|
54
|
+
}
|
|
55
|
+
.content { padding: 32px; }
|
|
56
|
+
.details-grid {
|
|
57
|
+
display: grid;
|
|
58
|
+
gap: 12px;
|
|
59
|
+
margin-bottom: 24px;
|
|
60
|
+
}
|
|
61
|
+
.detail-item {
|
|
62
|
+
background: #fafafa;
|
|
63
|
+
padding: 12px 16px;
|
|
64
|
+
border-radius: 8px;
|
|
65
|
+
border: 1px solid #f1f1f4;
|
|
66
|
+
}
|
|
67
|
+
.detail-label {
|
|
68
|
+
font-size: 11px;
|
|
69
|
+
font-weight: 700;
|
|
70
|
+
color: #71717a;
|
|
71
|
+
text-transform: uppercase;
|
|
72
|
+
letter-spacing: 0.05em;
|
|
73
|
+
display: block;
|
|
74
|
+
margin-bottom: 4px;
|
|
75
|
+
}
|
|
76
|
+
.detail-value {
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
font-weight: 500;
|
|
79
|
+
color: #18181b;
|
|
80
|
+
word-break: break-word;
|
|
81
|
+
}
|
|
82
|
+
.footer {
|
|
83
|
+
padding: 24px 32px;
|
|
84
|
+
background: #f8fafc;
|
|
85
|
+
border-top: 1px solid #e2e8f0;
|
|
86
|
+
text-align: center;
|
|
87
|
+
}
|
|
88
|
+
.footer-text {
|
|
89
|
+
font-size: 12px;
|
|
90
|
+
color: #64748b;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
93
|
+
</head>
|
|
94
|
+
<body>
|
|
95
|
+
<div class="wrapper">
|
|
96
|
+
<div class="container">
|
|
97
|
+
<div class="card">
|
|
98
|
+
<div class="header">
|
|
99
|
+
<h1>${title}</h1>
|
|
100
|
+
<p>${description}</p>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="content">
|
|
103
|
+
<div class="details-grid">
|
|
104
|
+
${items}
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="footer">
|
|
108
|
+
<p class="footer-text">\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} ${companyName}. This is an automated notification.</p>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</body>
|
|
114
|
+
</html>
|
|
115
|
+
`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/emails/index.ts
|
|
119
|
+
async function sendEmailNotification(content, apiUrl) {
|
|
120
|
+
try {
|
|
121
|
+
const url = apiUrl || process.env.API_URL || process.env.NEXT_PUBLIC_API_URL || "";
|
|
122
|
+
const response = await fetch(`${url}/api/send-email`, {
|
|
123
|
+
method: "POST",
|
|
124
|
+
headers: {
|
|
125
|
+
"Content-Type": "application/json"
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify({
|
|
128
|
+
content: {
|
|
129
|
+
...content,
|
|
130
|
+
from: content.from || "Admin CMS <notifications@admincms.com>"
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
if (response.ok) {
|
|
135
|
+
const result = await response.json();
|
|
136
|
+
if (!result.success) {
|
|
137
|
+
console.error("Failed to send email:", result.error);
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
} else {
|
|
141
|
+
const errText = await response.text().catch(() => "");
|
|
142
|
+
console.warn("Email API endpoint error:", response.status, errText);
|
|
143
|
+
}
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error("Error sending email:", error);
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
generateDefaultTemplate,
|
|
152
|
+
sendEmailNotification
|
|
153
|
+
};
|
package/dist/emails/index.js
CHANGED
|
@@ -165,7 +165,8 @@ async function sendEmailNotification(content, apiUrl) {
|
|
|
165
165
|
}
|
|
166
166
|
return result;
|
|
167
167
|
} else {
|
|
168
|
-
|
|
168
|
+
const errText = await response.text().catch(() => "");
|
|
169
|
+
console.warn("Email API endpoint error:", response.status, errText);
|
|
169
170
|
}
|
|
170
171
|
} catch (error) {
|
|
171
172
|
console.error("Error sending email:", error);
|
package/dist/emails/index.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -681,7 +681,22 @@ function AdminApp({ apiUrl, projectId, email }) {
|
|
|
681
681
|
}
|
|
682
682
|
function AdminAppContent() {
|
|
683
683
|
const [section, setSection] = (0, import_react5.useState)("pages");
|
|
684
|
+
const [authChecking, setAuthChecking] = (0, import_react5.useState)(true);
|
|
685
|
+
const [authenticated, setAuthenticated] = (0, import_react5.useState)(false);
|
|
684
686
|
const ctx = useCmsContext();
|
|
687
|
+
(0, import_react5.useEffect)(() => {
|
|
688
|
+
fetch("/api/admin/auth").then((res) => res.json()).then((data) => {
|
|
689
|
+
if (data && data.authenticated) {
|
|
690
|
+
setAuthenticated(true);
|
|
691
|
+
} else {
|
|
692
|
+
window.location.href = "/admin/login";
|
|
693
|
+
}
|
|
694
|
+
}).catch(() => {
|
|
695
|
+
window.location.href = "/admin/login";
|
|
696
|
+
}).finally(() => {
|
|
697
|
+
setAuthChecking(false);
|
|
698
|
+
});
|
|
699
|
+
}, []);
|
|
685
700
|
let subscriptionCtx = null;
|
|
686
701
|
try {
|
|
687
702
|
subscriptionCtx = useSubscription();
|
|
@@ -689,6 +704,15 @@ function AdminAppContent() {
|
|
|
689
704
|
}
|
|
690
705
|
const isSubscriptionActive = subscriptionCtx?.isSubscriptionActive ?? true;
|
|
691
706
|
const daysOverdue = subscriptionCtx?.daysOverdue ?? 0;
|
|
707
|
+
if (authChecking) {
|
|
708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex h-screen w-full items-center justify-center bg-slate-50", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3 text-slate-500 font-medium text-sm", children: [
|
|
709
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-5 h-5 border-2 border-indigo-600 border-t-transparent rounded-full animate-spin" }),
|
|
710
|
+
"Authenticating Admin..."
|
|
711
|
+
] }) });
|
|
712
|
+
}
|
|
713
|
+
if (!authenticated) {
|
|
714
|
+
return null;
|
|
715
|
+
}
|
|
692
716
|
if (!isSubscriptionActive) {
|
|
693
717
|
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, {}) });
|
|
694
718
|
}
|
|
@@ -2108,10 +2132,59 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
2108
2132
|
}
|
|
2109
2133
|
)
|
|
2110
2134
|
] }) }),
|
|
2111
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-8 py-6 divide-y divide-slate-100", children: Object.entries(detail.data).map(([key, val]) =>
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2135
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-8 py-6 divide-y divide-slate-100", children: Object.entries(detail.data).map(([key, val]) => {
|
|
2136
|
+
const strVal = String(val ?? "\u2014");
|
|
2137
|
+
const isImage = typeof val === "string" && (val.startsWith("data:image/") || /\.(jpg|jpeg|png|webp|avif|gif|svg)(\?.*)?$/i.test(val) || val.includes("/images/") && val.includes("sanity.io"));
|
|
2138
|
+
const isUrl = typeof val === "string" && /^https?:\/\//i.test(val);
|
|
2139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "py-4 grid grid-cols-[160px_1fr] gap-4 items-start", children: [
|
|
2140
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { className: "text-xs font-bold uppercase tracking-wide text-slate-400 pt-0.5", children: key }),
|
|
2141
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dd", { className: "text-sm text-slate-800", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-2", children: [
|
|
2142
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2143
|
+
"a",
|
|
2144
|
+
{
|
|
2145
|
+
href: strVal,
|
|
2146
|
+
target: "_blank",
|
|
2147
|
+
rel: "noopener noreferrer",
|
|
2148
|
+
className: "inline-block max-w-sm rounded-lg overflow-hidden border border-slate-200 shadow-sm hover:shadow transition-shadow bg-slate-50 p-1",
|
|
2149
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2150
|
+
"img",
|
|
2151
|
+
{
|
|
2152
|
+
src: strVal,
|
|
2153
|
+
alt: key,
|
|
2154
|
+
className: "max-h-64 w-auto object-contain rounded"
|
|
2155
|
+
}
|
|
2156
|
+
)
|
|
2157
|
+
}
|
|
2158
|
+
),
|
|
2159
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2160
|
+
"a",
|
|
2161
|
+
{
|
|
2162
|
+
href: strVal,
|
|
2163
|
+
target: "_blank",
|
|
2164
|
+
rel: "noopener noreferrer",
|
|
2165
|
+
className: "inline-flex items-center gap-1.5 text-xs text-indigo-600 font-semibold hover:underline",
|
|
2166
|
+
children: [
|
|
2167
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5" }),
|
|
2168
|
+
" View / Download file"
|
|
2169
|
+
]
|
|
2170
|
+
}
|
|
2171
|
+
) })
|
|
2172
|
+
] }) : isUrl ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2173
|
+
"a",
|
|
2174
|
+
{
|
|
2175
|
+
href: strVal,
|
|
2176
|
+
target: "_blank",
|
|
2177
|
+
rel: "noopener noreferrer",
|
|
2178
|
+
className: "inline-flex items-center gap-1.5 text-indigo-600 font-medium hover:underline break-all text-sm",
|
|
2179
|
+
children: [
|
|
2180
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5 flex-shrink-0" }),
|
|
2181
|
+
" ",
|
|
2182
|
+
strVal
|
|
2183
|
+
]
|
|
2184
|
+
}
|
|
2185
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "whitespace-pre-wrap", children: strVal }) })
|
|
2186
|
+
] }, key);
|
|
2187
|
+
}) })
|
|
2115
2188
|
] })
|
|
2116
2189
|
] });
|
|
2117
2190
|
}
|
|
@@ -2727,7 +2800,8 @@ async function sendEmailNotification(content, apiUrl) {
|
|
|
2727
2800
|
}
|
|
2728
2801
|
return result;
|
|
2729
2802
|
} else {
|
|
2730
|
-
|
|
2803
|
+
const errText = await response.text().catch(() => "");
|
|
2804
|
+
console.warn("Email API endpoint error:", response.status, errText);
|
|
2731
2805
|
}
|
|
2732
2806
|
} catch (error) {
|
|
2733
2807
|
console.error("Error sending email:", error);
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import "./chunk-WBQAMGXK.mjs";
|
|
|
3
3
|
import {
|
|
4
4
|
generateDefaultTemplate,
|
|
5
5
|
sendEmailNotification
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4KJKAYIC.mjs";
|
|
7
7
|
|
|
8
8
|
// src/provider.tsx
|
|
9
9
|
import {
|
|
@@ -653,7 +653,8 @@ import {
|
|
|
653
653
|
ChevronLeft,
|
|
654
654
|
ChevronRight,
|
|
655
655
|
SlidersHorizontal,
|
|
656
|
-
LogOut
|
|
656
|
+
LogOut,
|
|
657
|
+
ExternalLink as ExternalLink2
|
|
657
658
|
} from "lucide-react";
|
|
658
659
|
import { CreditCard as CreditCard2 } from "lucide-react";
|
|
659
660
|
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
@@ -679,7 +680,22 @@ function AdminApp({ apiUrl, projectId, email }) {
|
|
|
679
680
|
}
|
|
680
681
|
function AdminAppContent() {
|
|
681
682
|
const [section, setSection] = useState4("pages");
|
|
683
|
+
const [authChecking, setAuthChecking] = useState4(true);
|
|
684
|
+
const [authenticated, setAuthenticated] = useState4(false);
|
|
682
685
|
const ctx = useCmsContext();
|
|
686
|
+
useEffect4(() => {
|
|
687
|
+
fetch("/api/admin/auth").then((res) => res.json()).then((data) => {
|
|
688
|
+
if (data && data.authenticated) {
|
|
689
|
+
setAuthenticated(true);
|
|
690
|
+
} else {
|
|
691
|
+
window.location.href = "/admin/login";
|
|
692
|
+
}
|
|
693
|
+
}).catch(() => {
|
|
694
|
+
window.location.href = "/admin/login";
|
|
695
|
+
}).finally(() => {
|
|
696
|
+
setAuthChecking(false);
|
|
697
|
+
});
|
|
698
|
+
}, []);
|
|
683
699
|
let subscriptionCtx = null;
|
|
684
700
|
try {
|
|
685
701
|
subscriptionCtx = useSubscription();
|
|
@@ -687,6 +703,15 @@ function AdminAppContent() {
|
|
|
687
703
|
}
|
|
688
704
|
const isSubscriptionActive = subscriptionCtx?.isSubscriptionActive ?? true;
|
|
689
705
|
const daysOverdue = subscriptionCtx?.daysOverdue ?? 0;
|
|
706
|
+
if (authChecking) {
|
|
707
|
+
return /* @__PURE__ */ jsx5("div", { className: "flex h-screen w-full items-center justify-center bg-slate-50", children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3 text-slate-500 font-medium text-sm", children: [
|
|
708
|
+
/* @__PURE__ */ jsx5("div", { className: "w-5 h-5 border-2 border-indigo-600 border-t-transparent rounded-full animate-spin" }),
|
|
709
|
+
"Authenticating Admin..."
|
|
710
|
+
] }) });
|
|
711
|
+
}
|
|
712
|
+
if (!authenticated) {
|
|
713
|
+
return null;
|
|
714
|
+
}
|
|
690
715
|
if (!isSubscriptionActive) {
|
|
691
716
|
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, {}) });
|
|
692
717
|
}
|
|
@@ -2106,10 +2131,59 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
2106
2131
|
}
|
|
2107
2132
|
)
|
|
2108
2133
|
] }) }),
|
|
2109
|
-
/* @__PURE__ */ jsx5("div", { className: "px-8 py-6 divide-y divide-slate-100", children: Object.entries(detail.data).map(([key, val]) =>
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2134
|
+
/* @__PURE__ */ jsx5("div", { className: "px-8 py-6 divide-y divide-slate-100", children: Object.entries(detail.data).map(([key, val]) => {
|
|
2135
|
+
const strVal = String(val ?? "\u2014");
|
|
2136
|
+
const isImage = typeof val === "string" && (val.startsWith("data:image/") || /\.(jpg|jpeg|png|webp|avif|gif|svg)(\?.*)?$/i.test(val) || val.includes("/images/") && val.includes("sanity.io"));
|
|
2137
|
+
const isUrl = typeof val === "string" && /^https?:\/\//i.test(val);
|
|
2138
|
+
return /* @__PURE__ */ jsxs3("div", { className: "py-4 grid grid-cols-[160px_1fr] gap-4 items-start", children: [
|
|
2139
|
+
/* @__PURE__ */ jsx5("dt", { className: "text-xs font-bold uppercase tracking-wide text-slate-400 pt-0.5", children: key }),
|
|
2140
|
+
/* @__PURE__ */ jsx5("dd", { className: "text-sm text-slate-800", children: isImage ? /* @__PURE__ */ jsxs3("div", { className: "space-y-2", children: [
|
|
2141
|
+
/* @__PURE__ */ jsx5(
|
|
2142
|
+
"a",
|
|
2143
|
+
{
|
|
2144
|
+
href: strVal,
|
|
2145
|
+
target: "_blank",
|
|
2146
|
+
rel: "noopener noreferrer",
|
|
2147
|
+
className: "inline-block max-w-sm rounded-lg overflow-hidden border border-slate-200 shadow-sm hover:shadow transition-shadow bg-slate-50 p-1",
|
|
2148
|
+
children: /* @__PURE__ */ jsx5(
|
|
2149
|
+
"img",
|
|
2150
|
+
{
|
|
2151
|
+
src: strVal,
|
|
2152
|
+
alt: key,
|
|
2153
|
+
className: "max-h-64 w-auto object-contain rounded"
|
|
2154
|
+
}
|
|
2155
|
+
)
|
|
2156
|
+
}
|
|
2157
|
+
),
|
|
2158
|
+
/* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsxs3(
|
|
2159
|
+
"a",
|
|
2160
|
+
{
|
|
2161
|
+
href: strVal,
|
|
2162
|
+
target: "_blank",
|
|
2163
|
+
rel: "noopener noreferrer",
|
|
2164
|
+
className: "inline-flex items-center gap-1.5 text-xs text-indigo-600 font-semibold hover:underline",
|
|
2165
|
+
children: [
|
|
2166
|
+
/* @__PURE__ */ jsx5(ExternalLink2, { className: "w-3.5 h-3.5" }),
|
|
2167
|
+
" View / Download file"
|
|
2168
|
+
]
|
|
2169
|
+
}
|
|
2170
|
+
) })
|
|
2171
|
+
] }) : isUrl ? /* @__PURE__ */ jsxs3(
|
|
2172
|
+
"a",
|
|
2173
|
+
{
|
|
2174
|
+
href: strVal,
|
|
2175
|
+
target: "_blank",
|
|
2176
|
+
rel: "noopener noreferrer",
|
|
2177
|
+
className: "inline-flex items-center gap-1.5 text-indigo-600 font-medium hover:underline break-all text-sm",
|
|
2178
|
+
children: [
|
|
2179
|
+
/* @__PURE__ */ jsx5(ExternalLink2, { className: "w-3.5 h-3.5 flex-shrink-0" }),
|
|
2180
|
+
" ",
|
|
2181
|
+
strVal
|
|
2182
|
+
]
|
|
2183
|
+
}
|
|
2184
|
+
) : /* @__PURE__ */ jsx5("p", { className: "whitespace-pre-wrap", children: strVal }) })
|
|
2185
|
+
] }, key);
|
|
2186
|
+
}) })
|
|
2113
2187
|
] })
|
|
2114
2188
|
] });
|
|
2115
2189
|
}
|