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.
Files changed (58) hide show
  1. package/package.json +1 -1
  2. package/templates/nextblock-template/app/actions/interactions.test.ts +301 -0
  3. package/templates/nextblock-template/app/actions/interactions.ts +372 -0
  4. package/templates/nextblock-template/app/api/ai/cortex/build-widget/route.ts +4 -4
  5. package/templates/nextblock-template/app/api/ai/generate-blocks/route.ts +2 -2
  6. package/templates/nextblock-template/app/api/ai/global-agent/route.ts +56 -57
  7. package/templates/nextblock-template/app/api/cron/reset-sandbox/route.ts +1 -1
  8. package/templates/nextblock-template/app/api/cron/reset-sandbox/sandboxResetSql.ts +837 -0
  9. package/templates/nextblock-template/app/article/[slug]/PostClientContent.tsx +6 -0
  10. package/templates/nextblock-template/app/cms/CmsClientLayout.tsx +4 -0
  11. package/templates/nextblock-template/app/cms/components/ConnectGitHubButton.tsx +7 -2
  12. package/templates/nextblock-template/app/cms/components/github-connect-actions.ts +4 -0
  13. package/templates/nextblock-template/app/cms/interactions/InteractionsModerationClient.tsx +408 -0
  14. package/templates/nextblock-template/app/cms/interactions/page.tsx +51 -0
  15. package/templates/nextblock-template/app/cms/settings/cortex-ai/SandboxCortexAiSettingsClient.tsx +4 -3
  16. package/templates/nextblock-template/app/cms/settings/cortex-ai/StoredCortexAiSettingsClient.tsx +1 -1
  17. package/templates/nextblock-template/app/cms/settings/cortex-ai/actions.ts +3 -5
  18. package/templates/nextblock-template/app/cms/settings/cortex-ai/page.tsx +1 -1
  19. package/templates/nextblock-template/app/page.tsx +2 -2
  20. package/templates/nextblock-template/app/product/[slug]/page.tsx +2 -0
  21. package/templates/nextblock-template/components/AppShell.tsx +1 -1
  22. package/templates/nextblock-template/components/PostCommentsSection.tsx +369 -0
  23. package/templates/nextblock-template/components/ProductReviewsSection.tsx +419 -0
  24. package/templates/nextblock-template/components/blocks/renderers/ProductDetailsBlockRenderer.tsx +2 -0
  25. package/templates/nextblock-template/components/privacy/ConsentBanner.tsx +62 -19
  26. package/templates/nextblock-template/docs/08-NEXTBLOCK-CORTEX-AI-ARCHITECTURE.md +19 -19
  27. package/templates/nextblock-template/docs/10-CUSTOM-BLOCKS.md +4 -4
  28. package/templates/nextblock-template/lib/blocks/ProductGridBlock.tsx +2 -0
  29. package/templates/nextblock-template/lib/setup/actions.ts +3 -1
  30. package/templates/nextblock-template/lib/setup/migrations-bundle.ts +30 -0
  31. package/templates/nextblock-template/lib/updates/check-upstream.ts +38 -4
  32. package/templates/nextblock-template/package.json +2 -1
  33. package/templates/nextblock-template/scripts/verify-cortex-ai-build-widget.tsx +2 -4
  34. package/templates/nextblock-template/scripts/verify-cortex-ai-generate-blocks.ts +1 -1
  35. package/templates/nextblock-template/scripts/verify-cortex-ai-global-tools.ts +1 -1
  36. package/templates/nextblock-template/scripts/verify-cortex-ai-routing.ts +1 -1
  37. package/templates/nextblock-template/tsconfig.tsbuildinfo +1 -1
  38. package/templates/nextblock-template/lib/ai-block-generation.ts +0 -339
  39. package/templates/nextblock-template/lib/ai-client.ts +0 -247
  40. package/templates/nextblock-template/lib/ai-config.ts +0 -98
  41. package/templates/nextblock-template/lib/ai-cortex-widget-builder.ts +0 -125
  42. package/templates/nextblock-template/lib/ai-global-agent-custom-block-tools.ts +0 -363
  43. package/templates/nextblock-template/lib/ai-global-agent-db-tools.test.ts +0 -405
  44. package/templates/nextblock-template/lib/ai-global-agent-db-tools.ts +0 -1228
  45. package/templates/nextblock-template/lib/ai-global-agent-ecommerce.ts +0 -5
  46. package/templates/nextblock-template/lib/ai-global-agent-tools-stats.test.ts +0 -223
  47. package/templates/nextblock-template/lib/ai-global-agent-tools.test.ts +0 -2183
  48. package/templates/nextblock-template/lib/ai-global-agent-tools.ts +0 -4807
  49. package/templates/nextblock-template/lib/ai-key-crypto.test.ts +0 -70
  50. package/templates/nextblock-template/lib/ai-key-crypto.ts +0 -132
  51. package/templates/nextblock-template/lib/ai-model-catalog.test.ts +0 -49
  52. package/templates/nextblock-template/lib/ai-model-catalog.ts +0 -41
  53. package/templates/nextblock-template/lib/ai-model-registry.test.ts +0 -231
  54. package/templates/nextblock-template/lib/ai-model-registry.ts +0 -522
  55. package/templates/nextblock-template/lib/cortex-widget-registry.test.ts +0 -199
  56. package/templates/nextblock-template/lib/cortex-widget-registry.ts +0 -88
  57. package/templates/nextblock-template/lib/cortex-widget-schema.test.tsx +0 -237
  58. package/templates/nextblock-template/lib/cortex-widget-schema.ts +0 -393
@@ -0,0 +1,419 @@
1
+ "use client";
2
+
3
+ import React, { useState, useEffect, useTransition, useOptimistic } from "react";
4
+ import { createClient } from "@nextblock-cms/db";
5
+ import { Button } from "@nextblock-cms/ui";
6
+ import { Textarea } from "@nextblock-cms/ui";
7
+ import { Avatar, AvatarFallback, AvatarImage } from "@nextblock-cms/ui";
8
+ import { submitInteraction, toggleReaction } from "../app/actions/interactions";
9
+ import { cn, useTranslations } from "@nextblock-cms/utils";
10
+ import { MessageSquare, ThumbsUp, Star, Loader2, PenTool } from "lucide-react";
11
+
12
+ interface ProductReviewsSectionProps {
13
+ productId: string;
14
+ }
15
+
16
+ export default function ProductReviewsSection({ productId }: ProductReviewsSectionProps) {
17
+ const { t, lang } = useTranslations();
18
+ const [reviews, setReviews] = useState<any[]>([]);
19
+ const [loading, setLoading] = useState(true);
20
+ const [page, setPage] = useState(0);
21
+ const [hasMore, setHasMore] = useState(true);
22
+ const [user, setUser] = useState<any>(null);
23
+
24
+ // Form states
25
+ const [isFormOpen, setIsFormOpen] = useState(false);
26
+ const [rating, setRating] = useState(5);
27
+ const [hoverRating, setHoverRating] = useState(0);
28
+ const [content, setContent] = useState("");
29
+ const [submitting, setSubmitting] = useState(false);
30
+ const [error, setError] = useState<string | null>(null);
31
+ const [success, setSuccess] = useState<string | null>(null);
32
+
33
+ // Liked interactions tracking
34
+ const [likedIds, setLikedIds] = useState<string[]>([]);
35
+ const [, startTransition] = useTransition();
36
+
37
+ // Optimistic reviews list
38
+ const [optimisticReviews, setOptimisticReviews] = useOptimistic(
39
+ reviews,
40
+ (state, { reviewId, hasReacted, count }: { reviewId: string; hasReacted: boolean; count: number }) =>
41
+ state.map((r) => {
42
+ if (r.id === reviewId) {
43
+ const reactions = { ...((r.reactions as Record<string, number>) || {}) };
44
+ reactions.likes = count;
45
+ return { ...r, reactions, tempHasReacted: hasReacted };
46
+ }
47
+ return r;
48
+ })
49
+ );
50
+
51
+ useEffect(() => {
52
+ // 1. Fetch user
53
+ const supabase = createClient();
54
+ supabase.auth.getUser().then(({ data: { user } }) => {
55
+ setUser(user);
56
+ });
57
+
58
+ // 2. Read liked interactions from cookies
59
+ const match = document.cookie.match(/reacted_interactions=([^;]+)/);
60
+ if (match) {
61
+ try {
62
+ setLikedIds(JSON.parse(decodeURIComponent(match[1])));
63
+ } catch (err) {
64
+ console.warn("Failed to parse liked interactions cookie:", err);
65
+ }
66
+ }
67
+
68
+ // 3. Load initial reviews
69
+ fetchReviews(0, true);
70
+ }, [productId]);
71
+
72
+ const fetchReviews = async (pageNum: number, isInitial = false) => {
73
+ setLoading(true);
74
+ const supabase = createClient();
75
+ const limit = 5;
76
+ const start = pageNum * limit;
77
+ const end = start + limit - 1;
78
+
79
+ try {
80
+ const { data, error: dbError } = await supabase
81
+ .from("cms_interactions" as any)
82
+ .select("*, profiles(full_name, avatar_url, github_username)")
83
+ .eq("product_id", productId)
84
+ .eq("type", "review")
85
+ .eq("status", "approved")
86
+ .order("created_at", { ascending: false })
87
+ .range(start, end);
88
+
89
+ if (dbError) throw dbError;
90
+
91
+ if (data) {
92
+ if (isInitial) {
93
+ setReviews(data);
94
+ setPage(0);
95
+ } else {
96
+ setReviews((prev) => [...prev, ...data]);
97
+ setPage(pageNum);
98
+ }
99
+ setHasMore(data.length === limit);
100
+ }
101
+ } catch (err) {
102
+ console.error("Error fetching reviews:", err);
103
+ } finally {
104
+ setLoading(false);
105
+ }
106
+ };
107
+
108
+ const handleLoadMore = () => {
109
+ fetchReviews(page + 1);
110
+ };
111
+
112
+ const handleLike = async (reviewId: string) => {
113
+ const isLiked = likedIds.includes(reviewId);
114
+ const review = reviews.find((r) => r.id === reviewId);
115
+ if (!review) return;
116
+
117
+ const currentLikes = (review.reactions as Record<string, number>)?.likes || 0;
118
+ const nextCount = isLiked ? Math.max(0, currentLikes - 1) : currentLikes + 1;
119
+
120
+ startTransition(async () => {
121
+ // Apply optimistic update
122
+ setOptimisticReviews({ reviewId, hasReacted: !isLiked, count: nextCount });
123
+
124
+ const res = await toggleReaction(reviewId);
125
+ if (res.success) {
126
+ // Update liked cookie state locally
127
+ if (isLiked) {
128
+ setLikedIds((prev) => prev.filter((id) => id !== reviewId));
129
+ } else {
130
+ setLikedIds((prev) => [...prev, reviewId]);
131
+ }
132
+ // Sync actual state
133
+ setReviews((prev) =>
134
+ prev.map((r) => {
135
+ if (r.id === reviewId) {
136
+ const reactions = { ...((r.reactions as Record<string, number>) || {}) };
137
+ reactions.likes = res.count ?? nextCount;
138
+ return { ...r, reactions };
139
+ }
140
+ return r;
141
+ })
142
+ );
143
+ }
144
+ });
145
+ };
146
+
147
+ const handleSubmitReview = async (e: React.FormEvent) => {
148
+ e.preventDefault();
149
+ if (!user) {
150
+ setError(t("reviews.login_to_write"));
151
+ return;
152
+ }
153
+
154
+ if (content.trim().length < 5) {
155
+ setError(lang === "fr" ? "Votre avis doit faire au moins 5 caractères." : "Your review must be at least 5 characters long.");
156
+ return;
157
+ }
158
+
159
+ setSubmitting(true);
160
+ setError(null);
161
+ setSuccess(null);
162
+
163
+ const res = await submitInteraction({
164
+ type: "review",
165
+ content: content.trim(),
166
+ rating,
167
+ productId,
168
+ });
169
+
170
+ setSubmitting(false);
171
+
172
+ if (res.error) {
173
+ setError(res.error);
174
+ } else {
175
+ setSuccess(t("reviews.success_pending"));
176
+ setContent("");
177
+ setRating(5);
178
+ // Close form after a brief delay
179
+ setTimeout(() => {
180
+ setIsFormOpen(false);
181
+ setSuccess(null);
182
+ }, 3000);
183
+ }
184
+ };
185
+
186
+ const getInitials = (profile: any) => {
187
+ if (profile?.full_name) {
188
+ return profile.full_name
189
+ .split(" ")
190
+ .map((n: string) => n[0])
191
+ .join("")
192
+ .toUpperCase()
193
+ .slice(0, 2);
194
+ }
195
+ return "U";
196
+ };
197
+
198
+ return (
199
+ <div className="space-y-8 max-w-4xl mx-auto px-4">
200
+ {/* Header */}
201
+ <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between border-b pb-6 gap-4">
202
+ <div>
203
+ <h2 className="text-2xl font-bold tracking-tight text-foreground flex items-center gap-2">
204
+ <MessageSquare className="h-6 w-6 text-primary" />
205
+ {t("reviews.customer_reviews")}
206
+ </h2>
207
+ <p className="text-sm text-muted-foreground mt-1 text-left">
208
+ {t("reviews.share_thoughts")}
209
+ </p>
210
+ </div>
211
+
212
+ {user ? (
213
+ <Button
214
+ onClick={() => setIsFormOpen(!isFormOpen)}
215
+ className="flex items-center gap-2 transition-all"
216
+ variant={isFormOpen ? "outline" : "default"}
217
+ >
218
+ <PenTool className="h-4 w-4" />
219
+ {isFormOpen ? t("reviews.cancel_review") : t("reviews.write_review")}
220
+ </Button>
221
+ ) : (
222
+ <p className="text-sm text-muted-foreground italic">
223
+ {t("reviews.login_to_write")}
224
+ </p>
225
+ )}
226
+ </div>
227
+
228
+ {/* Submission Form */}
229
+ {isFormOpen && (
230
+ <form
231
+ onSubmit={handleSubmitReview}
232
+ className="bg-card/50 border border-border/80 rounded-2xl p-6 shadow-sm space-y-4 animate-in fade-in slide-in-from-top-4 duration-300"
233
+ >
234
+ <h3 className="text-lg font-semibold text-foreground">{t("reviews.write_your_review")}</h3>
235
+
236
+ {/* Stars Selection */}
237
+ <div className="space-y-1.5">
238
+ <label className="text-xs font-semibold text-muted-foreground uppercase tracking-wider block">
239
+ {t("reviews.rating")}
240
+ </label>
241
+ <div className="flex items-center gap-1.5">
242
+ {Array.from({ length: 5 }).map((_, i) => {
243
+ const starVal = i + 1;
244
+ const isActive = starVal <= (hoverRating || rating);
245
+ return (
246
+ <button
247
+ key={i}
248
+ type="button"
249
+ onClick={() => setRating(starVal)}
250
+ onMouseEnter={() => setHoverRating(starVal)}
251
+ onMouseLeave={() => setHoverRating(0)}
252
+ className="transition-transform active:scale-95 focus:outline-none"
253
+ aria-label={`Rate ${starVal} stars`}
254
+ >
255
+ <Star
256
+ className={cn(
257
+ "h-7 w-7 transition-colors",
258
+ isActive
259
+ ? "text-amber-500 fill-amber-500"
260
+ : "text-slate-300 dark:text-slate-700"
261
+ )}
262
+ />
263
+ </button>
264
+ );
265
+ })}
266
+ </div>
267
+ </div>
268
+
269
+ {/* Text Area */}
270
+ <div className="space-y-1.5">
271
+ <label
272
+ htmlFor="review-content"
273
+ className="text-xs font-semibold text-muted-foreground uppercase tracking-wider block"
274
+ >
275
+ {t("reviews.description")}
276
+ </label>
277
+ <Textarea
278
+ id="review-content"
279
+ placeholder={t("reviews.description_placeholder")}
280
+ value={content}
281
+ onChange={(e) => setContent(e.target.value)}
282
+ className="min-h-[120px] focus:ring-1 focus:ring-primary"
283
+ disabled={submitting}
284
+ required
285
+ />
286
+ </div>
287
+
288
+ {error && <div className="text-sm font-semibold text-destructive">{error}</div>}
289
+ {success && <div className="text-sm font-semibold text-emerald-600">{success}</div>}
290
+
291
+ <div className="flex justify-end gap-3 pt-2">
292
+ <Button
293
+ type="button"
294
+ variant="ghost"
295
+ onClick={() => setIsFormOpen(false)}
296
+ disabled={submitting}
297
+ >
298
+ {t("reviews.cancel")}
299
+ </Button>
300
+ <Button type="submit" disabled={submitting} className="min-w-[120px]">
301
+ {submitting ? (
302
+ <>
303
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
304
+ {t("reviews.submitting")}
305
+ </>
306
+ ) : (
307
+ t("reviews.submit_review")
308
+ )}
309
+ </Button>
310
+ </div>
311
+ </form>
312
+ )}
313
+
314
+ {/* Reviews List */}
315
+ <div className="space-y-6">
316
+ {optimisticReviews.length > 0 ? (
317
+ optimisticReviews.map((review) => {
318
+ const hasLiked = likedIds.includes(review.id) || review.tempHasReacted;
319
+ const likeCount = (review.reactions as Record<string, number>)?.likes || 0;
320
+ const reviewerName = review.profiles?.full_name || review.profiles?.github_username || "Anonymous";
321
+ const dateStr = new Date(review.created_at).toLocaleDateString(lang, {
322
+ year: "numeric",
323
+ month: "long",
324
+ day: "numeric",
325
+ });
326
+
327
+ return (
328
+ <div
329
+ key={review.id}
330
+ className="bg-card border border-border/60 rounded-2xl p-5 shadow-sm space-y-4 hover:border-border/100 transition-all duration-300"
331
+ >
332
+ {/* Reviewer Header */}
333
+ <div className="flex items-center justify-between gap-4">
334
+ <div className="flex items-center gap-3">
335
+ <Avatar className="h-10 w-10 border">
336
+ <AvatarImage src={review.profiles?.avatar_url || undefined} alt={reviewerName} />
337
+ <AvatarFallback className="bg-primary/5 text-primary text-xs font-semibold">
338
+ {getInitials(review.profiles)}
339
+ </AvatarFallback>
340
+ </Avatar>
341
+ <div>
342
+ <h4 className="text-sm font-semibold text-foreground leading-none">
343
+ {reviewerName}
344
+ </h4>
345
+ <span className="text-[10px] text-muted-foreground mt-1.5 block" suppressHydrationWarning>
346
+ {dateStr}
347
+ </span>
348
+ </div>
349
+ </div>
350
+
351
+ {/* Rating Stars */}
352
+ <div className="flex items-center gap-0.5 text-amber-500">
353
+ {Array.from({ length: 5 }).map((_, i) => (
354
+ <Star
355
+ key={i}
356
+ className={cn(
357
+ "h-4 w-4",
358
+ i < review.rating ? "fill-amber-500 text-amber-500" : "text-slate-200 dark:text-slate-800"
359
+ )}
360
+ />
361
+ ))}
362
+ </div>
363
+ </div>
364
+
365
+ {/* Review Content */}
366
+ <p className="text-sm text-slate-600 dark:text-slate-350 leading-relaxed whitespace-pre-line text-left">
367
+ {review.content}
368
+ </p>
369
+
370
+ {/* Reaction Actions */}
371
+ <div className="flex items-center pt-2">
372
+ <button
373
+ onClick={() => handleLike(review.id)}
374
+ className={cn(
375
+ "flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded-full border transition-all active:scale-95",
376
+ hasLiked
377
+ ? "bg-primary/5 border-primary/20 text-primary"
378
+ : "bg-background border-border text-muted-foreground hover:text-foreground hover:border-border/100"
379
+ )}
380
+ >
381
+ <ThumbsUp className={cn("h-3.5 w-3.5", hasLiked && "fill-current")} />
382
+ <span>{t("reviews.helpful")}</span>
383
+ {likeCount > 0 && <span className="font-semibold ml-0.5">{likeCount}</span>}
384
+ </button>
385
+ </div>
386
+ </div>
387
+ );
388
+ })
389
+ ) : (
390
+ !loading && (
391
+ <div className="text-center py-12 border border-dashed rounded-2xl bg-slate-50/50 dark:bg-slate-900/10">
392
+ <Star className="mx-auto h-8 w-8 text-slate-300 dark:text-slate-700" />
393
+ <h3 className="mt-4 text-sm font-semibold text-foreground">{t("reviews.no_reviews")}</h3>
394
+ <p className="mt-1 text-xs text-muted-foreground">
395
+ {t("reviews.be_the_first")}
396
+ </p>
397
+ </div>
398
+ )
399
+ )}
400
+
401
+ {/* Loading Spinner */}
402
+ {loading && (
403
+ <div className="flex justify-center py-6">
404
+ <Loader2 className="h-6 w-6 animate-spin text-primary" />
405
+ </div>
406
+ )}
407
+
408
+ {/* Load More */}
409
+ {hasMore && !loading && (
410
+ <div className="flex justify-center pt-2">
411
+ <Button variant="outline" size="sm" onClick={handleLoadMore}>
412
+ {t("reviews.load_more")}
413
+ </Button>
414
+ </div>
415
+ )}
416
+ </div>
417
+ </div>
418
+ );
419
+ }
@@ -3,6 +3,7 @@ import { ProductDetailsLayout } from '@nextblock-cms/ecommerce/components/Produc
3
3
  import type { VisualEditAttributes, VisualEditingDocumentContext } from '../../../lib/visual-editing/types';
4
4
  import { createClient } from "@nextblock-cms/db/server";
5
5
  import BlockRenderer from "../../BlockRenderer";
6
+ import ProductReviewsSection from "../../ProductReviewsSection";
6
7
 
7
8
  interface ProductDetailsBlockRendererProps {
8
9
  visualEditAttributes?: VisualEditAttributes;
@@ -84,6 +85,7 @@ export default async function ProductDetailsBlockRenderer({
84
85
  <ProductDetailsLayout
85
86
  visualEditingEnabled={productVisualEditingEnabled}
86
87
  descriptionNode={descriptionNode}
88
+ reviewsNode={excludeProductId ? <ProductReviewsSection productId={excludeProductId} /> : undefined}
87
89
  />
88
90
  </div>
89
91
  );
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { useEffect, useState } from 'react';
4
4
  import Link from 'next/link';
5
+ import { useTranslations } from '@nextblock-cms/utils';
5
6
  import { logConsentDecision } from '../../app/actions/consent';
6
7
  import { readConsent, writeConsent } from '../../lib/privacy/consent-client';
7
8
 
@@ -11,10 +12,22 @@ import { readConsent, writeConsent } from '../../lib/privacy/consent-client';
11
12
  * are mirrored to privacy_consent_logs for accountability.
12
13
  */
13
14
  export function ConsentBanner() {
15
+ const { lang, t } = useTranslations();
14
16
  const [visible, setVisible] = useState(false);
15
17
  const [managing, setManaging] = useState(false);
16
18
  const [analytics, setAnalytics] = useState(true);
17
19
  const [marketing, setMarketing] = useState(false);
20
+ const isFrench = lang.toLowerCase().startsWith('fr');
21
+
22
+ const translate = (key: string, fallback: string) => {
23
+ const translated = t(key);
24
+ return translated === key ? fallback : translated;
25
+ };
26
+
27
+ const privacyPolicyHref = translate(
28
+ 'privacy.consent.privacy_policy_href',
29
+ isFrench ? '/politique-de-confidentialite' : '/privacy-policy',
30
+ );
18
31
 
19
32
  useEffect(() => {
20
33
  if (!readConsent()) setVisible(true);
@@ -35,35 +48,56 @@ export function ConsentBanner() {
35
48
  return (
36
49
  <div
37
50
  role="dialog"
38
- aria-label="Privacy consent"
51
+ aria-label={translate('privacy.consent.aria_label', 'Privacy consent')}
39
52
  className="fixed bottom-4 right-4 z-[70] w-[min(92vw,360px)] animate-in fade-in slide-in-from-bottom-2 duration-300"
40
53
  >
41
54
  <div className="rounded-2xl border border-slate-200/70 bg-white/95 p-4 shadow-[0_8px_30px_rgba(15,23,42,0.12)] backdrop-blur-md dark:border-slate-700/60 dark:bg-slate-900/95 dark:shadow-[0_8px_30px_rgba(0,0,0,0.5)]">
42
55
  <p className="text-sm font-medium text-slate-900 dark:text-slate-100">
43
- We value your privacy
56
+ {translate('privacy.consent.title', 'We value your privacy')}
44
57
  </p>
45
58
  <p className="mt-1 text-xs leading-relaxed text-slate-500 dark:text-slate-400">
46
- We use only essential cookies by default. With your consent we also use
47
- analytics to improve the site. See our{' '}
48
- <Link href="/privacy-policy" className="underline underline-offset-2 hover:text-slate-700 dark:hover:text-slate-200">
49
- Privacy Policy
59
+ {translate(
60
+ 'privacy.consent.description_before_policy_link',
61
+ 'We use only essential cookies by default. With your consent we also use analytics to improve the site. See our',
62
+ )}{' '}
63
+ <Link
64
+ href={privacyPolicyHref}
65
+ className="underline underline-offset-2 hover:text-slate-700 dark:hover:text-slate-200"
66
+ >
67
+ {translate('privacy.consent.privacy_policy_link', 'Privacy Policy')}
50
68
  </Link>
51
- .
69
+ {translate('privacy.consent.description_after_policy_link', '.')}
52
70
  </p>
53
71
 
54
72
  {managing && (
55
73
  <div className="mt-3 space-y-2 rounded-lg bg-slate-50 p-3 dark:bg-slate-800/60">
56
74
  <label className="flex items-center justify-between gap-3 text-xs text-slate-600 dark:text-slate-300">
57
75
  <span>
58
- <span className="font-medium text-slate-800 dark:text-slate-200">Necessary</span>
59
- <span className="block text-[11px] text-slate-400">Always on</span>
76
+ <span className="font-medium text-slate-800 dark:text-slate-200">
77
+ {translate('privacy.consent.necessary_label', 'Necessary')}
78
+ </span>
79
+ <span className="block text-[11px] text-slate-400">
80
+ {translate('privacy.consent.necessary_help', 'Always on')}
81
+ </span>
60
82
  </span>
61
- <input type="checkbox" checked disabled className="h-4 w-4 accent-slate-400" />
83
+ <input
84
+ type="checkbox"
85
+ checked
86
+ disabled
87
+ className="h-4 w-4 accent-slate-400"
88
+ />
62
89
  </label>
63
90
  <label className="flex cursor-pointer items-center justify-between gap-3 text-xs text-slate-600 dark:text-slate-300">
64
91
  <span>
65
- <span className="font-medium text-slate-800 dark:text-slate-200">Analytics</span>
66
- <span className="block text-[11px] text-slate-400">Usage insights</span>
92
+ <span className="font-medium text-slate-800 dark:text-slate-200">
93
+ {translate('privacy.consent.analytics_label', 'Analytics')}
94
+ </span>
95
+ <span className="block text-[11px] text-slate-400">
96
+ {translate(
97
+ 'privacy.consent.analytics_help',
98
+ 'Usage insights',
99
+ )}
100
+ </span>
67
101
  </span>
68
102
  <input
69
103
  type="checkbox"
@@ -74,8 +108,15 @@ export function ConsentBanner() {
74
108
  </label>
75
109
  <label className="flex cursor-pointer items-center justify-between gap-3 text-xs text-slate-600 dark:text-slate-300">
76
110
  <span>
77
- <span className="font-medium text-slate-800 dark:text-slate-200">Marketing</span>
78
- <span className="block text-[11px] text-slate-400">Personalized content</span>
111
+ <span className="font-medium text-slate-800 dark:text-slate-200">
112
+ {translate('privacy.consent.marketing_label', 'Marketing')}
113
+ </span>
114
+ <span className="block text-[11px] text-slate-400">
115
+ {translate(
116
+ 'privacy.consent.marketing_help',
117
+ 'Personalized content',
118
+ )}
119
+ </span>
79
120
  </span>
80
121
  <input
81
122
  type="checkbox"
@@ -94,7 +135,7 @@ export function ConsentBanner() {
94
135
  onClick={() => decide({ analytics, marketing })}
95
136
  className="flex-1 rounded-lg bg-slate-900 px-3 py-2 text-xs font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white"
96
137
  >
97
- Save choices
138
+ {translate('privacy.consent.save_choices', 'Save choices')}
98
139
  </button>
99
140
  ) : (
100
141
  <button
@@ -102,7 +143,7 @@ export function ConsentBanner() {
102
143
  onClick={() => decide({ analytics: true, marketing: true })}
103
144
  className="flex-1 rounded-lg bg-slate-900 px-3 py-2 text-xs font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white"
104
145
  >
105
- Accept all
146
+ {translate('privacy.consent.accept_all', 'Accept all')}
106
147
  </button>
107
148
  )}
108
149
  <button
@@ -110,16 +151,18 @@ export function ConsentBanner() {
110
151
  onClick={() => decide({ analytics: false, marketing: false })}
111
152
  className="rounded-lg border border-slate-200 px-3 py-2 text-xs font-medium text-slate-600 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
112
153
  >
113
- Reject all
154
+ {translate('privacy.consent.reject_all', 'Reject all')}
114
155
  </button>
115
156
  </div>
116
157
 
117
158
  <button
118
159
  type="button"
119
160
  onClick={() => setManaging((prev) => !prev)}
120
- className="mt-2 w-full text-center text-[11px] text-slate-400 underline underline-offset-2 transition hover:text-slate-600 dark:hover:text-slate-300"
161
+ className="mt-2 w-full text-center text-[11px] text-slate-800 underline underline-offset-2 transition hover:text-slate-600 dark:hover:text-slate-300"
121
162
  >
122
- {managing ? 'Hide options' : 'Manage options'}
163
+ {managing
164
+ ? translate('privacy.consent.hide_options', 'Hide options')
165
+ : translate('privacy.consent.manage_options', 'Manage options')}
123
166
  </button>
124
167
  </div>
125
168
  </div>