create-nextblock 0.11.1 → 0.11.2
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/package.json +1 -1
- package/templates/nextblock-template/app/actions/interactions.test.ts +301 -0
- package/templates/nextblock-template/app/actions/interactions.ts +372 -0
- package/templates/nextblock-template/app/api/ai/cortex/build-widget/route.ts +4 -4
- package/templates/nextblock-template/app/api/ai/generate-blocks/route.ts +2 -2
- package/templates/nextblock-template/app/api/ai/global-agent/route.ts +56 -57
- package/templates/nextblock-template/app/api/cron/reset-sandbox/route.ts +1 -1
- package/templates/nextblock-template/app/api/cron/reset-sandbox/sandboxResetSql.ts +837 -0
- package/templates/nextblock-template/app/article/[slug]/PostClientContent.tsx +6 -0
- package/templates/nextblock-template/app/cms/CmsClientLayout.tsx +4 -0
- package/templates/nextblock-template/app/cms/components/ConnectGitHubButton.tsx +7 -2
- package/templates/nextblock-template/app/cms/components/github-connect-actions.ts +4 -0
- package/templates/nextblock-template/app/cms/interactions/InteractionsModerationClient.tsx +408 -0
- package/templates/nextblock-template/app/cms/interactions/page.tsx +51 -0
- package/templates/nextblock-template/app/cms/settings/cortex-ai/SandboxCortexAiSettingsClient.tsx +4 -3
- package/templates/nextblock-template/app/cms/settings/cortex-ai/StoredCortexAiSettingsClient.tsx +1 -1
- package/templates/nextblock-template/app/cms/settings/cortex-ai/actions.ts +3 -5
- package/templates/nextblock-template/app/cms/settings/cortex-ai/page.tsx +1 -1
- package/templates/nextblock-template/app/page.tsx +2 -2
- package/templates/nextblock-template/app/product/[slug]/page.tsx +2 -0
- package/templates/nextblock-template/components/AppShell.tsx +1 -1
- package/templates/nextblock-template/components/PostCommentsSection.tsx +369 -0
- package/templates/nextblock-template/components/ProductReviewsSection.tsx +419 -0
- package/templates/nextblock-template/components/blocks/renderers/ProductDetailsBlockRenderer.tsx +2 -0
- package/templates/nextblock-template/components/privacy/ConsentBanner.tsx +62 -19
- package/templates/nextblock-template/docs/08-NEXTBLOCK-CORTEX-AI-ARCHITECTURE.md +19 -19
- package/templates/nextblock-template/docs/10-CUSTOM-BLOCKS.md +4 -4
- package/templates/nextblock-template/lib/blocks/ProductGridBlock.tsx +2 -0
- package/templates/nextblock-template/lib/setup/actions.ts +3 -1
- package/templates/nextblock-template/lib/setup/migrations-bundle.ts +30 -0
- package/templates/nextblock-template/lib/updates/check-upstream.ts +38 -4
- package/templates/nextblock-template/package.json +2 -1
- package/templates/nextblock-template/scripts/verify-cortex-ai-build-widget.tsx +2 -4
- package/templates/nextblock-template/scripts/verify-cortex-ai-generate-blocks.ts +1 -1
- package/templates/nextblock-template/scripts/verify-cortex-ai-global-tools.ts +1 -1
- package/templates/nextblock-template/scripts/verify-cortex-ai-routing.ts +1 -1
- package/templates/nextblock-template/tsconfig.tsbuildinfo +1 -1
- package/templates/nextblock-template/lib/ai-block-generation.ts +0 -339
- package/templates/nextblock-template/lib/ai-client.ts +0 -247
- package/templates/nextblock-template/lib/ai-config.ts +0 -98
- package/templates/nextblock-template/lib/ai-cortex-widget-builder.ts +0 -125
- package/templates/nextblock-template/lib/ai-global-agent-custom-block-tools.ts +0 -363
- package/templates/nextblock-template/lib/ai-global-agent-db-tools.test.ts +0 -405
- package/templates/nextblock-template/lib/ai-global-agent-db-tools.ts +0 -1228
- package/templates/nextblock-template/lib/ai-global-agent-ecommerce.ts +0 -5
- package/templates/nextblock-template/lib/ai-global-agent-tools-stats.test.ts +0 -223
- package/templates/nextblock-template/lib/ai-global-agent-tools.test.ts +0 -2183
- package/templates/nextblock-template/lib/ai-global-agent-tools.ts +0 -4807
- package/templates/nextblock-template/lib/ai-key-crypto.test.ts +0 -70
- package/templates/nextblock-template/lib/ai-key-crypto.ts +0 -132
- package/templates/nextblock-template/lib/ai-model-catalog.test.ts +0 -49
- package/templates/nextblock-template/lib/ai-model-catalog.ts +0 -41
- package/templates/nextblock-template/lib/ai-model-registry.test.ts +0 -231
- package/templates/nextblock-template/lib/ai-model-registry.ts +0 -522
- package/templates/nextblock-template/lib/cortex-widget-registry.test.ts +0 -199
- package/templates/nextblock-template/lib/cortex-widget-registry.ts +0 -88
- package/templates/nextblock-template/lib/cortex-widget-schema.test.tsx +0 -237
- package/templates/nextblock-template/lib/cortex-widget-schema.ts +0 -393
|
@@ -9,6 +9,7 @@ import { useCurrentContent } from '../../../context/CurrentContentContext';
|
|
|
9
9
|
import Link from 'next/link';
|
|
10
10
|
import { estimateReadTimeMinutesFromBlocks } from '../../../lib/posts/readTime';
|
|
11
11
|
import FeatureImageHero from '../../../components/FeatureImageHero';
|
|
12
|
+
import PostCommentsSection from '../../../components/PostCommentsSection';
|
|
12
13
|
|
|
13
14
|
type PostType = Database['public']['Tables']['posts']['Row'];
|
|
14
15
|
type BlockType = Database['public']['Tables']['blocks']['Row'];
|
|
@@ -430,6 +431,11 @@ export default function PostClientContent({ initialPostData, currentSlug, childr
|
|
|
430
431
|
<div ref={articleBodyRef} className="post-article__body mx-auto mt-10 w-full px-4 md:mt-14">
|
|
431
432
|
{children}
|
|
432
433
|
</div>
|
|
434
|
+
|
|
435
|
+
{/* Post Comments Section */}
|
|
436
|
+
<div className="mx-auto max-w-4xl px-4 mt-16 border-t pt-10 border-slate-200 dark:border-slate-800">
|
|
437
|
+
<PostCommentsSection postId={currentPostData.id} />
|
|
438
|
+
</div>
|
|
433
439
|
</article>
|
|
434
440
|
);
|
|
435
441
|
}
|
|
@@ -244,6 +244,7 @@ export default function CmsClientLayout({
|
|
|
244
244
|
|
|
245
245
|
else if (pathname.startsWith("/cms/settings/packages")) pageTitle = "Packages";
|
|
246
246
|
else if (pathname.startsWith("/cms/settings")) pageTitle = "Settings";
|
|
247
|
+
else if (pathname.startsWith("/cms/interactions")) pageTitle = "Interactions";
|
|
247
248
|
else if (pathname.startsWith("/cms/products/inventory")) pageTitle = "Inventory";
|
|
248
249
|
else if (pathname.startsWith("/cms/coupons/") && pathname.endsWith("/edit")) pageTitle = "Edit Coupon";
|
|
249
250
|
else if (pathname.startsWith("/cms/coupons")) pageTitle = "Coupons";
|
|
@@ -316,6 +317,9 @@ export default function CmsClientLayout({
|
|
|
316
317
|
<NavItem href="/cms/custom-blocks" icon={Boxes} isActive={pathname.startsWith("/cms/custom-blocks")} writerOnly isAdmin={isAdmin} isWriter={isWriter} onClick={closeSidebarOnMobile}>
|
|
317
318
|
Blocks
|
|
318
319
|
</NavItem>
|
|
320
|
+
<NavItem href="/cms/interactions" icon={MessageSquare} isActive={pathname.startsWith("/cms/interactions")} writerOnly isAdmin={isAdmin} isWriter={isWriter} onClick={closeSidebarOnMobile}>
|
|
321
|
+
Interactions
|
|
322
|
+
</NavItem>
|
|
319
323
|
<NavItem href="/cms/navigation" icon={ListTree} isActive={pathname.startsWith("/cms/navigation")} adminOnly isAdmin={isAdmin} onClick={closeSidebarOnMobile}>
|
|
320
324
|
Navigation
|
|
321
325
|
</NavItem>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useRouter } from 'next/navigation';
|
|
4
5
|
import { Check, ExternalLink, Github, Loader2 } from 'lucide-react';
|
|
5
6
|
import { Button } from '@nextblock-cms/ui';
|
|
6
7
|
import { startGithubConnect, pollGithubConnect } from './github-connect-actions';
|
|
@@ -13,6 +14,7 @@ type Phase = 'idle' | 'starting' | 'awaiting' | 'installed' | 'error';
|
|
|
13
14
|
* No PAT, no env config — the public client id is baked into the app.
|
|
14
15
|
*/
|
|
15
16
|
export default function ConnectGitHubButton() {
|
|
17
|
+
const router = useRouter();
|
|
16
18
|
const [phase, setPhase] = useState<Phase>('idle');
|
|
17
19
|
const [userCode, setUserCode] = useState('');
|
|
18
20
|
const [verificationUri, setVerificationUri] = useState('https://github.com/login/device');
|
|
@@ -34,6 +36,9 @@ export default function ConnectGitHubButton() {
|
|
|
34
36
|
|
|
35
37
|
if (result.status === 'installed') {
|
|
36
38
|
setPhase('installed');
|
|
39
|
+
// Re-render the dashboard so the onboarding step picks up the now-active workflow
|
|
40
|
+
// (the step then flips to done and this control is replaced).
|
|
41
|
+
router.refresh();
|
|
37
42
|
return;
|
|
38
43
|
}
|
|
39
44
|
if (result.status === 'error') {
|
|
@@ -44,7 +49,7 @@ export default function ConnectGitHubButton() {
|
|
|
44
49
|
// pending — back off a little on slow_down, then poll again.
|
|
45
50
|
const next = result.slowDown ? intervalMs + 5000 : intervalMs;
|
|
46
51
|
setTimeout(() => void poll(next), next);
|
|
47
|
-
}, []);
|
|
52
|
+
}, [router]);
|
|
48
53
|
|
|
49
54
|
const connect = useCallback(async () => {
|
|
50
55
|
setError('');
|
|
@@ -67,7 +72,7 @@ export default function ConnectGitHubButton() {
|
|
|
67
72
|
return (
|
|
68
73
|
<div className="flex items-center gap-1.5 text-sm font-medium text-emerald-600 dark:text-emerald-400">
|
|
69
74
|
<Check className="h-4 w-4" />
|
|
70
|
-
Connected —
|
|
75
|
+
Connected — workflow installed
|
|
71
76
|
</div>
|
|
72
77
|
);
|
|
73
78
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
pollDeviceFlowOnce,
|
|
9
9
|
installSyncWorkflow,
|
|
10
10
|
} from '../../../lib/updates/github-device';
|
|
11
|
+
import { markSyncWorkflowInstalled } from '../../../lib/updates/check-upstream';
|
|
11
12
|
|
|
12
13
|
const DEVICE_COOKIE = 'nb_gh_device';
|
|
13
14
|
|
|
@@ -84,6 +85,9 @@ export async function pollGithubConnect(): Promise<PollConnectResult> {
|
|
|
84
85
|
const install = await installSyncWorkflow(poll.token);
|
|
85
86
|
store.delete({ name: DEVICE_COOKIE, path: '/cms' });
|
|
86
87
|
if (install.ok) {
|
|
88
|
+
// We just installed the workflow — flip the onboarding state now instead of waiting
|
|
89
|
+
// for the throttled background poll / GitHub's registration lag.
|
|
90
|
+
await markSyncWorkflowInstalled();
|
|
87
91
|
revalidatePath('/cms', 'layout');
|
|
88
92
|
return { status: 'installed', htmlUrl: install.htmlUrl };
|
|
89
93
|
}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useState, useTransition } from "react";
|
|
4
|
+
import { Button } from "@nextblock-cms/ui";
|
|
5
|
+
import { Avatar, AvatarFallback, AvatarImage } from "@nextblock-cms/ui";
|
|
6
|
+
import { Badge } from "@nextblock-cms/ui";
|
|
7
|
+
import { updateInteractionStatus, saveNotificationEmails } from "../../actions/interactions";
|
|
8
|
+
import { cn } from "@nextblock-cms/utils";
|
|
9
|
+
import {
|
|
10
|
+
MessageSquare,
|
|
11
|
+
Check,
|
|
12
|
+
X,
|
|
13
|
+
Star,
|
|
14
|
+
Inbox,
|
|
15
|
+
Filter,
|
|
16
|
+
ExternalLink,
|
|
17
|
+
ThumbsUp,
|
|
18
|
+
AlertCircle,
|
|
19
|
+
Mail
|
|
20
|
+
} from "lucide-react";
|
|
21
|
+
import Link from "next/link";
|
|
22
|
+
|
|
23
|
+
interface InteractionsModerationClientProps {
|
|
24
|
+
initialInteractions: any[];
|
|
25
|
+
isAdmin: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function InteractionsModerationClient({
|
|
29
|
+
initialInteractions,
|
|
30
|
+
isAdmin,
|
|
31
|
+
}: InteractionsModerationClientProps) {
|
|
32
|
+
const [interactions, setInteractions] = useState<any[]>(initialInteractions);
|
|
33
|
+
|
|
34
|
+
// Notification settings states
|
|
35
|
+
const [emailsInput, setEmailsInput] = useState("");
|
|
36
|
+
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
|
37
|
+
const [savingEmails, setSavingEmails] = useState(false);
|
|
38
|
+
const [settingsError, setSettingsError] = useState<string | null>(null);
|
|
39
|
+
const [settingsSuccess, setSettingsSuccess] = useState<string | null>(null);
|
|
40
|
+
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (isAdmin) {
|
|
43
|
+
import("../../actions/interactions").then(({ getNotificationEmails }) => {
|
|
44
|
+
getNotificationEmails().then((res) => {
|
|
45
|
+
if (res.success && res.emails) {
|
|
46
|
+
setEmailsInput(res.emails);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, [isAdmin]);
|
|
52
|
+
|
|
53
|
+
const handleSaveEmails = async () => {
|
|
54
|
+
setSavingEmails(true);
|
|
55
|
+
setSettingsError(null);
|
|
56
|
+
setSettingsSuccess(null);
|
|
57
|
+
|
|
58
|
+
const res = await saveNotificationEmails(emailsInput);
|
|
59
|
+
setSavingEmails(false);
|
|
60
|
+
|
|
61
|
+
if (res.error) {
|
|
62
|
+
setSettingsError(res.error);
|
|
63
|
+
} else {
|
|
64
|
+
setSettingsSuccess("Notification settings saved successfully.");
|
|
65
|
+
if (res.emails) {
|
|
66
|
+
setEmailsInput(res.emails);
|
|
67
|
+
}
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
setSettingsSuccess(null);
|
|
70
|
+
setIsSettingsOpen(false);
|
|
71
|
+
}, 1500);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const [filterType, setFilterType] = useState<"all" | "review" | "comment">("all");
|
|
75
|
+
const [filterStatus, setFilterStatus] = useState<"pending" | "approved" | "denied">("pending");
|
|
76
|
+
const [, startTransition] = useTransition();
|
|
77
|
+
const [moderatingId, setModeratingId] = useState<string | null>(null);
|
|
78
|
+
const [actionError, setActionError] = useState<string | null>(null);
|
|
79
|
+
|
|
80
|
+
// Counter helper
|
|
81
|
+
const getCount = (status: "pending" | "approved" | "denied") => {
|
|
82
|
+
return interactions.filter((i) => i.status === status).length;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Filtered interactions
|
|
86
|
+
const filteredInteractions = interactions.filter((item) => {
|
|
87
|
+
const matchesStatus = item.status === filterStatus;
|
|
88
|
+
const matchesType = filterType === "all" ? true : item.type === filterType;
|
|
89
|
+
return matchesStatus && matchesType;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const handleModerate = async (interactionId: string, status: "approved" | "denied") => {
|
|
93
|
+
if (!isAdmin) {
|
|
94
|
+
setActionError("Only administrators can moderate reviews and comments.");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
setModeratingId(interactionId);
|
|
99
|
+
setActionError(null);
|
|
100
|
+
|
|
101
|
+
startTransition(async () => {
|
|
102
|
+
const res = await updateInteractionStatus(interactionId, status);
|
|
103
|
+
setModeratingId(null);
|
|
104
|
+
|
|
105
|
+
if (res.error) {
|
|
106
|
+
setActionError(res.error);
|
|
107
|
+
} else {
|
|
108
|
+
// Update local state
|
|
109
|
+
setInteractions((prev) =>
|
|
110
|
+
prev.map((item) => (item.id === interactionId ? { ...item, status } : item))
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const getInitials = (profile: any) => {
|
|
117
|
+
if (profile?.full_name) {
|
|
118
|
+
return profile.full_name
|
|
119
|
+
.split(" ")
|
|
120
|
+
.map((n: string) => n[0])
|
|
121
|
+
.join("")
|
|
122
|
+
.toUpperCase()
|
|
123
|
+
.slice(0, 2);
|
|
124
|
+
}
|
|
125
|
+
return "U";
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<div className="space-y-6 max-w-7xl mx-auto p-4 sm:p-6 lg:p-8">
|
|
130
|
+
{/* Header */}
|
|
131
|
+
<div className="flex flex-col md:flex-row md:items-center md:justify-between border-b pb-6 gap-4">
|
|
132
|
+
<div>
|
|
133
|
+
<h1 className="text-3xl font-bold tracking-tight text-foreground flex items-center gap-2.5">
|
|
134
|
+
<MessageSquare className="h-8 w-8 text-primary" />
|
|
135
|
+
Interactions Moderation
|
|
136
|
+
</h1>
|
|
137
|
+
<p className="text-sm text-muted-foreground mt-1.5">
|
|
138
|
+
Review and moderate customer reviews and blog comments.
|
|
139
|
+
</p>
|
|
140
|
+
</div>
|
|
141
|
+
{isAdmin && (
|
|
142
|
+
<div className="flex items-center gap-2 self-start md:self-auto">
|
|
143
|
+
<Button
|
|
144
|
+
onClick={() => setIsSettingsOpen(true)}
|
|
145
|
+
className="flex items-center gap-2 text-xs"
|
|
146
|
+
variant="outline"
|
|
147
|
+
>
|
|
148
|
+
<Mail className="h-4 w-4" />
|
|
149
|
+
Notifications
|
|
150
|
+
</Button>
|
|
151
|
+
</div>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
{/* Tabs / Filters Bar */}
|
|
156
|
+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 bg-card border border-border/60 rounded-2xl p-4 shadow-sm">
|
|
157
|
+
{/* Status Tabs */}
|
|
158
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
159
|
+
{(["pending", "approved", "denied"] as const).map((status) => {
|
|
160
|
+
const count = getCount(status);
|
|
161
|
+
const isActive = filterStatus === status;
|
|
162
|
+
return (
|
|
163
|
+
<button
|
|
164
|
+
key={status}
|
|
165
|
+
onClick={() => setFilterStatus(status)}
|
|
166
|
+
className={cn(
|
|
167
|
+
"flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-xl transition-all border",
|
|
168
|
+
isActive
|
|
169
|
+
? "bg-primary text-primary-foreground border-primary shadow-sm"
|
|
170
|
+
: "bg-background border-border text-muted-foreground hover:text-foreground hover:border-border/100"
|
|
171
|
+
)}
|
|
172
|
+
>
|
|
173
|
+
<span className="capitalize">{status}</span>
|
|
174
|
+
<Badge
|
|
175
|
+
variant={isActive ? "secondary" : "outline"}
|
|
176
|
+
className={cn(
|
|
177
|
+
"text-xs font-semibold px-2 py-0.5",
|
|
178
|
+
isActive ? "bg-white/20 text-white" : "text-muted-foreground border-border/80"
|
|
179
|
+
)}
|
|
180
|
+
>
|
|
181
|
+
{count}
|
|
182
|
+
</Badge>
|
|
183
|
+
</button>
|
|
184
|
+
);
|
|
185
|
+
})}
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
{/* Type Filter */}
|
|
189
|
+
<div className="flex items-center gap-2">
|
|
190
|
+
<Filter className="h-4 w-4 text-muted-foreground hidden sm:block" />
|
|
191
|
+
<select
|
|
192
|
+
value={filterType}
|
|
193
|
+
onChange={(e: any) => setFilterType(e.target.value)}
|
|
194
|
+
className="bg-background border border-border rounded-xl px-3 py-2 text-sm font-medium text-foreground focus:ring-1 focus:ring-primary focus:outline-none"
|
|
195
|
+
>
|
|
196
|
+
<option value="all">All Types</option>
|
|
197
|
+
<option value="review">Reviews Only</option>
|
|
198
|
+
<option value="comment">Comments Only</option>
|
|
199
|
+
</select>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
{/* Error Banner */}
|
|
204
|
+
{actionError && (
|
|
205
|
+
<div className="bg-destructive/10 border border-destructive/20 text-destructive text-sm rounded-xl p-4 flex items-center gap-2.5">
|
|
206
|
+
<AlertCircle className="h-5 w-5 shrink-0" />
|
|
207
|
+
<span className="font-medium">{actionError}</span>
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
210
|
+
|
|
211
|
+
{/* Interactions List */}
|
|
212
|
+
<div className="space-y-4">
|
|
213
|
+
{filteredInteractions.length > 0 ? (
|
|
214
|
+
filteredInteractions.map((item) => {
|
|
215
|
+
const authorName = item.profiles?.full_name || item.profiles?.github_username || "Anonymous";
|
|
216
|
+
const dateStr = new Date(item.created_at).toLocaleString();
|
|
217
|
+
const targetName = item.products?.title || item.posts?.title || "Unknown Target";
|
|
218
|
+
const targetUrl = item.product_id
|
|
219
|
+
? `/product/${item.products?.slug}`
|
|
220
|
+
: `/article/${item.posts?.slug}`;
|
|
221
|
+
const targetLabel = item.product_id ? "Product" : "Article";
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<div
|
|
225
|
+
key={item.id}
|
|
226
|
+
className={cn(
|
|
227
|
+
"bg-card border rounded-2xl p-5 shadow-sm space-y-4 hover:border-border/100 transition-all duration-300 relative",
|
|
228
|
+
item.status === "pending" && "border-amber-200/60 dark:border-amber-900/30"
|
|
229
|
+
)}
|
|
230
|
+
>
|
|
231
|
+
{/* Header */}
|
|
232
|
+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 border-b border-border/40 pb-4">
|
|
233
|
+
<div className="flex items-center gap-3">
|
|
234
|
+
<Avatar className="h-10 w-10 border">
|
|
235
|
+
<AvatarImage src={item.profiles?.avatar_url || undefined} alt={authorName} />
|
|
236
|
+
<AvatarFallback className="bg-primary/5 text-primary text-xs font-semibold">
|
|
237
|
+
{getInitials(item.profiles)}
|
|
238
|
+
</AvatarFallback>
|
|
239
|
+
</Avatar>
|
|
240
|
+
<div>
|
|
241
|
+
<div className="flex items-center gap-2">
|
|
242
|
+
<h3 className="text-sm font-semibold text-foreground leading-none">
|
|
243
|
+
{authorName}
|
|
244
|
+
</h3>
|
|
245
|
+
<Badge
|
|
246
|
+
variant="outline"
|
|
247
|
+
className={cn(
|
|
248
|
+
"text-[10px] font-bold uppercase py-0 px-2",
|
|
249
|
+
item.type === "review"
|
|
250
|
+
? "border-amber-500/20 bg-amber-500/5 text-amber-600"
|
|
251
|
+
: "border-sky-500/20 bg-sky-500/5 text-sky-600"
|
|
252
|
+
)}
|
|
253
|
+
>
|
|
254
|
+
{item.type}
|
|
255
|
+
</Badge>
|
|
256
|
+
</div>
|
|
257
|
+
<span className="text-[10px] text-muted-foreground mt-1.5 block" suppressHydrationWarning>
|
|
258
|
+
{dateStr}
|
|
259
|
+
</span>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
{/* Target Link */}
|
|
264
|
+
<div className="flex items-center text-xs">
|
|
265
|
+
<span className="text-muted-foreground mr-1.5 font-medium">{targetLabel}:</span>
|
|
266
|
+
<Link
|
|
267
|
+
href={targetUrl}
|
|
268
|
+
target="_blank"
|
|
269
|
+
className="text-primary hover:underline font-semibold flex items-center gap-1 group"
|
|
270
|
+
>
|
|
271
|
+
{targetName}
|
|
272
|
+
<ExternalLink className="h-3 w-3 opacity-60 group-hover:opacity-100 transition-opacity" />
|
|
273
|
+
</Link>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
{/* Rating if Review */}
|
|
278
|
+
{item.type === "review" && item.rating && (
|
|
279
|
+
<div className="flex items-center gap-0.5 text-amber-500">
|
|
280
|
+
{Array.from({ length: 5 }).map((_, i) => (
|
|
281
|
+
<Star
|
|
282
|
+
key={i}
|
|
283
|
+
className={cn(
|
|
284
|
+
"h-4.5 w-4.5",
|
|
285
|
+
i < item.rating ? "fill-amber-500 text-amber-500" : "text-slate-200 dark:text-slate-800"
|
|
286
|
+
)}
|
|
287
|
+
/>
|
|
288
|
+
))}
|
|
289
|
+
</div>
|
|
290
|
+
)}
|
|
291
|
+
|
|
292
|
+
{/* Body Content */}
|
|
293
|
+
<p className="text-sm text-slate-700 dark:text-slate-300 leading-relaxed whitespace-pre-line text-left">
|
|
294
|
+
{item.content}
|
|
295
|
+
</p>
|
|
296
|
+
|
|
297
|
+
{/* Reactions Count */}
|
|
298
|
+
{Object.keys(item.reactions || {}).length > 0 && (
|
|
299
|
+
<div className="flex items-center gap-1.5 text-xs text-muted-foreground bg-slate-50 dark:bg-slate-900/20 px-3 py-1.5 rounded-xl w-fit">
|
|
300
|
+
<ThumbsUp className="h-3.5 w-3.5" />
|
|
301
|
+
<span>Likes:</span>
|
|
302
|
+
<span className="font-semibold text-foreground">
|
|
303
|
+
{item.reactions.likes || 0}
|
|
304
|
+
</span>
|
|
305
|
+
</div>
|
|
306
|
+
)}
|
|
307
|
+
|
|
308
|
+
{/* Moderation Actions */}
|
|
309
|
+
{isAdmin && (
|
|
310
|
+
<div className="flex items-center justify-end gap-2.5 pt-2">
|
|
311
|
+
{item.status !== "approved" && (
|
|
312
|
+
<Button
|
|
313
|
+
size="sm"
|
|
314
|
+
onClick={() => handleModerate(item.id, "approved")}
|
|
315
|
+
disabled={moderatingId === item.id}
|
|
316
|
+
className="bg-emerald-600 hover:bg-emerald-700 text-white flex items-center gap-1.5 rounded-xl shadow-sm transition-all"
|
|
317
|
+
>
|
|
318
|
+
<Check className="h-3.5 w-3.5" />
|
|
319
|
+
Approve
|
|
320
|
+
</Button>
|
|
321
|
+
)}
|
|
322
|
+
{item.status !== "denied" && (
|
|
323
|
+
<Button
|
|
324
|
+
size="sm"
|
|
325
|
+
variant="outline"
|
|
326
|
+
onClick={() => handleModerate(item.id, "denied")}
|
|
327
|
+
disabled={moderatingId === item.id}
|
|
328
|
+
className="border-destructive/30 hover:border-destructive hover:bg-destructive/5 text-destructive flex items-center gap-1.5 rounded-xl transition-all"
|
|
329
|
+
>
|
|
330
|
+
<X className="h-3.5 w-3.5" />
|
|
331
|
+
Deny
|
|
332
|
+
</Button>
|
|
333
|
+
)}
|
|
334
|
+
</div>
|
|
335
|
+
)}
|
|
336
|
+
</div>
|
|
337
|
+
);
|
|
338
|
+
})
|
|
339
|
+
) : (
|
|
340
|
+
<div className="text-center py-20 border border-dashed rounded-2xl bg-slate-50/50 dark:bg-slate-900/10">
|
|
341
|
+
<Inbox className="mx-auto h-10 w-10 text-slate-300 dark:text-slate-700" />
|
|
342
|
+
<h3 className="mt-4 text-sm font-semibold text-foreground">All caught up!</h3>
|
|
343
|
+
<p className="mt-1.5 text-xs text-muted-foreground">
|
|
344
|
+
No interactions matching status <span className="font-semibold">"{filterStatus}"</span> and type <span className="font-semibold">"{filterType}"</span>.
|
|
345
|
+
</p>
|
|
346
|
+
</div>
|
|
347
|
+
)}
|
|
348
|
+
</div>
|
|
349
|
+
|
|
350
|
+
{/* Settings Modal */}
|
|
351
|
+
{isSettingsOpen && (
|
|
352
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/45 backdrop-blur-sm animate-in fade-in duration-200">
|
|
353
|
+
<div className="bg-background border border-border rounded-2xl max-w-md w-full p-6 shadow-xl space-y-4 animate-in zoom-in-95 duration-200">
|
|
354
|
+
<div className="flex items-center justify-between">
|
|
355
|
+
<h3 className="text-lg font-semibold text-foreground flex items-center gap-2">
|
|
356
|
+
<Mail className="h-5 w-5 text-primary" />
|
|
357
|
+
Notification Settings
|
|
358
|
+
</h3>
|
|
359
|
+
<button
|
|
360
|
+
onClick={() => setIsSettingsOpen(false)}
|
|
361
|
+
className="text-muted-foreground hover:text-foreground transition-colors"
|
|
362
|
+
>
|
|
363
|
+
<X className="h-5 w-5" />
|
|
364
|
+
</button>
|
|
365
|
+
</div>
|
|
366
|
+
<p className="text-sm text-muted-foreground text-left">
|
|
367
|
+
Configure which email addresses receive notification alerts when new pending reviews or comments are submitted.
|
|
368
|
+
</p>
|
|
369
|
+
<div className="space-y-1.5 text-left">
|
|
370
|
+
<label className="text-xs font-semibold text-muted-foreground uppercase tracking-wider block">
|
|
371
|
+
Email Recipients
|
|
372
|
+
</label>
|
|
373
|
+
<textarea
|
|
374
|
+
value={emailsInput}
|
|
375
|
+
onChange={(e) => setEmailsInput(e.target.value)}
|
|
376
|
+
placeholder="admin@example.com, moderator@example.com"
|
|
377
|
+
className="w-full min-h-[80px] bg-background border border-border rounded-xl px-3 py-2 text-sm text-foreground focus:ring-1 focus:ring-primary focus:outline-none"
|
|
378
|
+
/>
|
|
379
|
+
<span className="text-[10px] text-muted-foreground">
|
|
380
|
+
Enter a comma-separated list of email addresses.
|
|
381
|
+
</span>
|
|
382
|
+
</div>
|
|
383
|
+
|
|
384
|
+
{settingsError && <div className="text-xs font-medium text-destructive text-left">{settingsError}</div>}
|
|
385
|
+
{settingsSuccess && <div className="text-xs font-medium text-emerald-600 text-left">{settingsSuccess}</div>}
|
|
386
|
+
|
|
387
|
+
<div className="flex justify-end gap-3 pt-2">
|
|
388
|
+
<Button
|
|
389
|
+
variant="ghost"
|
|
390
|
+
onClick={() => setIsSettingsOpen(false)}
|
|
391
|
+
disabled={savingEmails}
|
|
392
|
+
>
|
|
393
|
+
Cancel
|
|
394
|
+
</Button>
|
|
395
|
+
<Button
|
|
396
|
+
onClick={handleSaveEmails}
|
|
397
|
+
disabled={savingEmails}
|
|
398
|
+
className="min-w-[100px]"
|
|
399
|
+
>
|
|
400
|
+
{savingEmails ? "Saving..." : "Save Settings"}
|
|
401
|
+
</Button>
|
|
402
|
+
</div>
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
405
|
+
)}
|
|
406
|
+
</div>
|
|
407
|
+
);
|
|
408
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { redirect } from "next/navigation";
|
|
2
|
+
import { createClient, getProfileWithRoleServerSide } from "@nextblock-cms/db/server";
|
|
3
|
+
import InteractionsModerationClient from "./InteractionsModerationClient";
|
|
4
|
+
|
|
5
|
+
export const dynamic = "force-dynamic";
|
|
6
|
+
|
|
7
|
+
export default async function InteractionsPage() {
|
|
8
|
+
const supabase = createClient();
|
|
9
|
+
|
|
10
|
+
// 1. Authenticate user
|
|
11
|
+
const { data: { user } } = await supabase.auth.getUser();
|
|
12
|
+
if (!user) {
|
|
13
|
+
redirect("/login?redirect_to=/cms/interactions");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 2. Authorize user (requires ADMIN or WRITER roles to access CMS)
|
|
17
|
+
const profile = await getProfileWithRoleServerSide(user.id);
|
|
18
|
+
if (!profile || (profile.role !== "ADMIN" && profile.role !== "WRITER")) {
|
|
19
|
+
redirect("/cms/dashboard");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 3. Fetch initial interactions (reviews and comments)
|
|
23
|
+
const { data: interactions, error } = await supabase
|
|
24
|
+
.from("cms_interactions" as any)
|
|
25
|
+
.select(`
|
|
26
|
+
id,
|
|
27
|
+
type,
|
|
28
|
+
status,
|
|
29
|
+
content,
|
|
30
|
+
rating,
|
|
31
|
+
reactions,
|
|
32
|
+
created_at,
|
|
33
|
+
product_id,
|
|
34
|
+
post_id,
|
|
35
|
+
profiles(full_name, avatar_url, github_username),
|
|
36
|
+
products(title, slug),
|
|
37
|
+
posts(title, slug)
|
|
38
|
+
`)
|
|
39
|
+
.order("created_at", { ascending: false });
|
|
40
|
+
|
|
41
|
+
if (error) {
|
|
42
|
+
console.error("Error fetching initial interactions:", error);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<InteractionsModerationClient
|
|
47
|
+
initialInteractions={interactions || []}
|
|
48
|
+
isAdmin={profile.role === "ADMIN"}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
package/templates/nextblock-template/app/cms/settings/cortex-ai/SandboxCortexAiSettingsClient.tsx
CHANGED
|
@@ -27,14 +27,15 @@ import {
|
|
|
27
27
|
Trash2,
|
|
28
28
|
Info,
|
|
29
29
|
} from 'lucide-react';
|
|
30
|
+
import {
|
|
31
|
+
createCortexAiStoredModelSelection,
|
|
32
|
+
type CortexAiStoredModelSelection,
|
|
33
|
+
} from '@nextblock/cortex/client';
|
|
30
34
|
|
|
31
35
|
const CORTEX_AI_SANDBOX_KEY_LOCAL_STORAGE = 'cortex_ai_sandbox_openrouter_api_key';
|
|
32
36
|
const CORTEX_AI_SANDBOX_MODEL_LOCAL_STORAGE = 'cortex_ai_sandbox_openrouter_model_selection';
|
|
33
37
|
const CORTEX_AI_SETTINGS_CHANGED_EVENT = 'nextblock:cortex-ai-settings-changed';
|
|
34
38
|
|
|
35
|
-
import type { CortexAiStoredModelSelection } from '../../../../lib/ai-model-registry';
|
|
36
|
-
import { createCortexAiStoredModelSelection } from '../../../../lib/ai-model-registry';
|
|
37
|
-
|
|
38
39
|
type SandboxCortexAiSettingsClientProps = {
|
|
39
40
|
compatibleModels: Array<{
|
|
40
41
|
id: string;
|
package/templates/nextblock-template/app/cms/settings/cortex-ai/StoredCortexAiSettingsClient.tsx
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
Trash2,
|
|
28
28
|
} from 'lucide-react';
|
|
29
29
|
|
|
30
|
-
import type { CortexAiStoredModelSelection } from '
|
|
30
|
+
import type { CortexAiStoredModelSelection } from '@nextblock/cortex/client';
|
|
31
31
|
import {
|
|
32
32
|
clearCortexAiModelSelectionAction,
|
|
33
33
|
clearOpenRouterApiKeyAction,
|
|
@@ -9,17 +9,15 @@ import {
|
|
|
9
9
|
CORTEX_AI_OPENROUTER_MODEL_SELECTION_SETTING_KEY,
|
|
10
10
|
CORTEX_AI_OPENROUTER_SETTING_KEY,
|
|
11
11
|
CORTEX_AI_PACKAGE_ID,
|
|
12
|
+
createCortexAiStoredModelSelection,
|
|
12
13
|
encryptStoredOpenRouterApiKey,
|
|
13
14
|
getCortexAiEnvConfig,
|
|
14
15
|
getEnvOpenRouterKeyStatus,
|
|
15
16
|
getStoredOpenRouterKeyStatus,
|
|
16
|
-
|
|
17
|
-
import { listCortexAiCompatibleOpenRouterModels } from '../../../../lib/ai-model-catalog';
|
|
18
|
-
import {
|
|
19
|
-
createCortexAiStoredModelSelection,
|
|
17
|
+
listCortexAiCompatibleOpenRouterModels,
|
|
20
18
|
safeParseCortexAiModelSelection,
|
|
21
19
|
type CortexAiStoredModelSelection,
|
|
22
|
-
} from '
|
|
20
|
+
} from '@nextblock/cortex';
|
|
23
21
|
|
|
24
22
|
const CORTEX_AI_SETTINGS_PATH = '/cms/settings/cortex-ai';
|
|
25
23
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { listCortexAiCompatibleOpenRouterModels } from '
|
|
1
|
+
import { listCortexAiCompatibleOpenRouterModels } from '@nextblock/cortex';
|
|
2
2
|
import { getCortexAiSettingsStatus } from './actions';
|
|
3
3
|
import { SandboxCortexAiSettingsClient } from './SandboxCortexAiSettingsClient';
|
|
4
4
|
import { StoredCortexAiSettingsClient } from './StoredCortexAiSettingsClient';
|
|
@@ -113,14 +113,14 @@ export async function generateMetadata(): Promise<Metadata> {
|
|
|
113
113
|
...buildSocialMetadata({
|
|
114
114
|
title,
|
|
115
115
|
description,
|
|
116
|
-
url: `${siteUrl}
|
|
116
|
+
url: `${siteUrl}`,
|
|
117
117
|
siteTitle,
|
|
118
118
|
imageUrl: pageData.feature_image_url,
|
|
119
119
|
type: 'website',
|
|
120
120
|
locale: toOpenGraphLocale(pageData.language_code),
|
|
121
121
|
}),
|
|
122
122
|
alternates: {
|
|
123
|
-
canonical: `${siteUrl}
|
|
123
|
+
canonical: `${siteUrl}`,
|
|
124
124
|
languages: Object.keys(alternates).length > 0 ? alternates : undefined,
|
|
125
125
|
},
|
|
126
126
|
};
|
|
@@ -326,6 +326,8 @@ export default async function ProductPage({ params }: ProductPageProps) {
|
|
|
326
326
|
title: productRecord.title,
|
|
327
327
|
slug: productRecord.slug,
|
|
328
328
|
sku: productRecord.sku,
|
|
329
|
+
average_rating: productRecord.average_rating,
|
|
330
|
+
total_reviews: productRecord.total_reviews,
|
|
329
331
|
upc: productRecord.upc || undefined,
|
|
330
332
|
price: productRecord.price,
|
|
331
333
|
prices: normalizePriceMap(productRecord.prices),
|
|
@@ -128,7 +128,7 @@ export function AppShell({
|
|
|
128
128
|
(corporateFooter.legalName ||
|
|
129
129
|
corporateFooter.address ||
|
|
130
130
|
corporateFooter.supportEmail) && (
|
|
131
|
-
<p className="max-w-2xl text-[11px] leading-relaxed text-
|
|
131
|
+
<p className="max-w-2xl text-[11px] leading-relaxed text-slate-600">
|
|
132
132
|
{[corporateFooter.legalName, corporateFooter.address]
|
|
133
133
|
.filter(Boolean)
|
|
134
134
|
.join(' · ')}
|