"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Play, Trash2 } from "lucide-react"; import { toast } from "sonner"; export interface RecordingRow { id: number; name: string; durationMs: number; playCount: number; lastPlayedAt: number | null; createdAt: number; } function formatDuration(ms: number): string { 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 RecordingsTable({ recordings }: { recordings: RecordingRow[] }) { const router = useRouter(); async function handleDelete(id: number) { const res = await fetch(`/api/recordings/${id}`, { method: "DELETE" }); if (res.ok) { toast.success("Recording deleted"); router.refresh(); } else { toast.error("Could not delete recording"); } } if (recordings.length === 0) { return (

No recordings yet - start a session on the Control page and save it when you're done.

); } return ( Name Duration Plays Last played Actions {recordings.map((r) => ( {r.name} {formatDuration(r.durationMs)} {r.playCount} {r.lastPlayedAt ? new Date(r.lastPlayedAt).toLocaleString() : "Never"} ))}
); }