since3-portal/app/(templates)/ki/[id]/[tool]/page.tsx
2026-10-05 08:23:02 +02:00

30 lines
1.3 KiB
TypeScript

import type { Metadata } from "next"
import { notFound, redirect } from "next/navigation"
import { verifySession } from "@/lib/supabase/dal"
import { demoInfo } from "@/modules/templates/ai/demo-info"
import { isDemoSlug } from "@/modules/templates/ai/demos"
import { AiDemo } from "@/modules/templates/ai/ui/ai-demo"
import { resolveContent } from "@/modules/templates/lib/content"
import { getTemplate } from "@/modules/templates/lib/registry"
import { getVariant } from "@/modules/templates/queries/variants"
export const metadata: Metadata = {
title: "KI-Demo",
robots: { index: false, follow: false },
}
// Interne KI-Demo für Admins: alle Demos, ohne Tageslimit, auch ohne Freigabe-Link
export default async function AdminAiDemoPage({ params }: PageProps<"/ki/[id]/[tool]">) {
const session = await verifySession()
if (!session.isAdmin) redirect("/client/dashboard")
const { id, tool } = await params
if (!isDemoSlug(tool)) notFound()
const variant = await getVariant(id)
const def = variant ? getTemplate(variant.template_key) : undefined
if (!variant || !def) notFound()
const content = resolveContent(def, variant.content)
return <AiDemo tool={tool} access={{ variantId: id }} info={demoInfo(def, content, { siteHref: `/preview/${def.key}?variant=${id}`, all: true })} />
}