import { Download, FileText, Copy, CheckCircle2 } from "lucide-react"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { useToast } from "@/hooks/use-toast"; import type { SrtSegment, Anomaly } from "@shared/schema"; interface ExportPanelProps { segments: SrtSegment[]; anomalies: Anomaly[]; fileName: string; onExport: () => void; isExporting?: boolean; } export function ExportPanel({ segments, anomalies, fileName, onExport, isExporting }: ExportPanelProps) { const { toast } = useToast(); const resolvedCount = anomalies.filter(a => a.resolved).length; const unresolvedCount = anomalies.filter(a => !a.resolved).length; const generateSrtContent = (): string => { return segments.map(segment => { return `${segment.id}\n${segment.startTime} --> ${segment.endTime}\n${segment.text}\n`; }).join("\n"); }; const handleCopyToClipboard = async () => { try { await navigator.clipboard.writeText(generateSrtContent()); toast({ title: "Copied to clipboard", description: "SRT content has been copied to your clipboard.", }); } catch { toast({ title: "Copy failed", description: "Unable to copy to clipboard. Please try downloading instead.", variant: "destructive", }); } }; const getSrtFileName = () => { const baseName = fileName.replace(/\.(mp3|mp4)$/i, ""); return `${baseName}.srt`; }; return ( Export SRT Download your corrected subtitles as an SRT file
{segments.length} segments
{resolvedCount > 0 && (
{resolvedCount} corrections applied
)} {unresolvedCount > 0 && (
{unresolvedCount} unreviewed issues
)}

Output file:

{getSrtFileName()}

{unresolvedCount > 0 && (

You can still export with unreviewed issues. They will be included as-is.

)}
); }