import { AlertCircle, ArrowLeft, CheckCircle2, Download, FileText } from "lucide-react"; import { useMemo } from "react"; import { Link } from "react-router-dom"; import { useTranslation } from "@/contexts/i18n-context"; import { formatFileSize, triggerDownload } from "@/lib/download"; import { format } from "@/lib/format"; /** Tools whose primary output is text/data, not a downloadable file. */ const DATA_OUTPUT_TOOLS = new Set([ "ocr", "barcode-read", "info", "histogram", "color-palette", "transcribe-audio", "extract-subtitles", "image-to-base64", "pdf-to-text", "pdf-metadata", "audio-metadata", "video-metadata", ]); /** Tools that produce multiple output files bundled as a ZIP. */ const MULTI_OUTPUT_TOOLS = new Set([ "split", "favicon", "pdf-to-image", "video-to-frames", "split-audio", "split-csv", ]); interface ReviewPanelProps { filename: string; fileSize: number; fileType: string; originalSize: number; downloadUrl: string; onUndo: () => void; onStartOver: () => void; currentToolId: string; totalCount?: number; successCount?: number; failedCount?: number; } export function ReviewPanel({ filename, fileSize, fileType, originalSize, downloadUrl, onUndo, onStartOver, currentToolId, totalCount, successCount, failedCount, }: ReviewPanelProps) { const { t } = useTranslation(); const isDataOutput = DATA_OUTPUT_TOOLS.has(currentToolId); const isMultiOutput = MULTI_OUTPUT_TOOLS.has(currentToolId); const sizeDelta = useMemo(() => { if (!originalSize || originalSize === 0) return 0; return Math.round((1 - fileSize / originalSize) * 100); }, [originalSize, fileSize]); const handleDownload = () => { triggerDownload(downloadUrl, filename); }; const hasBatchStats = totalCount != null && totalCount > 1 && successCount != null && failedCount != null; return (
{/* Success indicator */}
{t.toolPage.conversionComplete}
{/* Batch partial failure summary */} {hasBatchStats && failedCount > 0 && (
{format(t.toolPage.batchPartialSuccess, { success: successCount, total: totalCount, failed: failedCount, })}
)} {/* Size delta -- hidden for data-output tools */} {!isDataOutput && originalSize > 0 && (
{t.toolPage.original} {formatFileSize(originalSize)}
{t.toolPage.processed} {formatFileSize(fileSize)}
{t.toolPage.saved} 0 ? "text-emerald-600" : sizeDelta === 0 ? "text-muted-foreground" : "text-foreground" }`} > {sizeDelta === 0 ? t.toolPage.noChange : sizeDelta > 0 ? `-${sizeDelta}%` : `+${Math.abs(sizeDelta)}%`}
)} {/* Data-output tools: results hint + secondary download */} {isDataOutput && ( <>
{t.toolPage.dataResultsHint}
)} {/* Download button -- primary for non-data tools */} {!isDataOutput && ( )} {/* Adjust settings */} {/* Text links */}
{t.toolPage.backToTools}
); }