"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Trash2 } from "lucide-react"; import { toast } from "sonner"; export interface SessionRow { id: number; name: string | null; kind: "live" | "replay"; status: "active" | "completed" | "aborted"; startedAt: number; durationMs: number | null; } function formatDuration(ms: number | null): string { if (ms === null) return "-"; const totalSeconds = Math.round(ms / 1000); const minutes = Math.floor(totalSeconds / 60); const seconds = totalSeconds % 60; return `${minutes}:${seconds.toString().padStart(2, "0")}`; } export function SessionsTable({ sessions }: { sessions: SessionRow[] }) { const router = useRouter(); async function handleDelete(id: number) { const res = await fetch(`/api/play-sessions/${id}`, { method: "DELETE" }); if (res.ok) { toast.success("Session deleted"); router.refresh(); } else if (res.status === 409) { toast.error("A saved recording still references this session"); } else { toast.error("Could not delete session"); } } if (sessions.length === 0) { return
No sessions yet.
; } return (