import { useState } from 'react'; function SummaryBox({ summary, totalArticles, loading, onResummarize, resummarizeDisabled = false, onGenerateTts, ttsStatus = 'idle', ttsAudioUrl = '', ttsError = '', }) { const [copied, setCopied] = useState(false); const handleCopy = async () => { if (!summary) return; try { await navigator.clipboard.writeText(summary); setCopied(true); window.setTimeout(() => setCopied(false), 2000); } catch { setCopied(false); } }; const renderedSummary = summary ?.split('\n') .map((line) => line.trim()) .filter(Boolean); const hasSummary = renderedSummary?.length > 0; const isGeneratingAudio = ttsStatus === 'queued' || ttsStatus === 'processing'; return (

Bản tóm tắt AI

{loading ? ( Đang tóm tắt... ) : totalArticles ? ( {totalArticles} bài ) : null}
{onResummarize ? (
) : null} {loading ? (
progress_activity

Đang tạo bản tóm tắt thông minh...

) : !hasSummary ? (
auto_awesome

Chọn hoặc tìm kiếm tin tức để tạo bản tóm tắt.

) : (
{renderedSummary?.map((line, index) => (

{line}

))}
{ttsError ? (

{ttsError}

) : null} {ttsAudioUrl ? (
) : null}
)}
); } export default SummaryBox;