import { notFound } from "next/navigation"; import Link from "next/link"; import { prisma } from "@streamclipper/db"; import { fetchChannelStatuses } from "../../../lib/apiDaemon"; import { deleteRawSegment, deleteCandidateSegment, deleteChannel, stopSession, forceStartCapture, retryRender, cancelRender, } from "../../actions"; import { ConfirmButton } from "../../components/ConfirmButton"; import { LiveLogViewer } from "../../components/LiveLogViewer"; import { SessionTimer } from "../../components/SessionTimer"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Badge, type badgeVariants } from "@/components/ui/badge"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import type { VariantProps } from "class-variance-authority"; export const dynamic = "force-dynamic"; const STATUS_BADGE: Record["variant"]> = { PENDING: "muted", PROCESSED: "ok", DISCARDED: "err", PENDING_STT: "warn", TRANSCRIBED: "ok", RENDERING: "warn", READY: "ok", FAILED: "err", }; function transcriptPreview(transcriptJson: unknown): string | null { if (!transcriptJson || typeof transcriptJson !== "object") return null; const text = (transcriptJson as { text?: string }).text; return text ? text.slice(0, 240) : null; } export default async function ChannelDetailPage({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; const [channel, statuses] = await Promise.all([ prisma.channel.findUnique({ where: { id }, include: { sessions: { orderBy: { startedAt: "desc" }, include: { segments: { orderBy: { createdAt: "desc" }, include: { candidates: { orderBy: { createdAt: "desc" }, include: { short: true } } }, }, }, }, }, }), fetchChannelStatuses(), ]); if (!channel) notFound(); const status = statuses.get(channel.id); const activeSession = channel.sessions.find((s) => s.endedAt === null); return (
← Kanal Durumu

{channel.name}

{channel.youtubeHandle} · {channel.channelId}

Canlı Durum
{status?.recording ? "🔴 Kayıtta" : "Kayıtta değil"} {status?.recording && activeSession && ( <> {" · "} )} {status?.recording && activeSession && (
)}

Aktif: {channel.isActive ? "evet" : "hayır"} · Son kontrol:{" "} {channel.lastCheckedAt ? new Date(channel.lastCheckedAt).toLocaleString("tr-TR") : "—"}

{status === undefined && (

api-daemon'dan canlı durum alınamadı (servis erişilemez olabilir).

)} {status?.lastPollError && (
son poll hatası {new Date(status.lastPollError.at).toLocaleString("tr-TR")}
                {status.lastPollError.message}
              
)} {status?.recording && activeSession?.liveVideoId && activeSession.liveVideoId !== "forced" && (