import React, { useState } from 'react'; import * as Icons from 'react-icons/fi'; import { marked } from 'marked'; const RecapWorkflow = (props) => { const { currentStep = 1, uploading = false, uploadedFile = null, handleFileUpload = () => {}, startAiAnalysis = () => {}, aiPreview = null, scheduleDate = '', setScheduleDate = () => {}, handleApproveSummary = () => {}, handleScheduleSummary = () => {}, setCurrentStep = () => {}, setAiPreview = () => {}, selectedSpaces = [], setSelectedSpaces = () => {}, taSpaces = [], isHitlEnabled = true, handleRefineAi = () => {}, onGenerateQuiz = null, generatingQuiz = false } = props; const [isEditing, setIsEditing] = useState(false); const [refineQuery, setRefineQuery] = useState(''); const [selectedChips, setSelectedChips] = useState([]); const [quizQuestionCount, setQuizQuestionCount] = useState(10); // Use deadlines from aiPreview if available, otherwise fall back to empty array const deadlines = (aiPreview?.deadlines && Array.isArray(aiPreview.deadlines) && aiPreview.deadlines.length > 0) ? aiPreview.deadlines : []; const renderMarkdown = (content) => { return { __html: marked.parse(content || '') }; }; const refineOptions = [ { id: 'shorter', label: '✨ Ngắn gọn', prompt: 'Làm ngắn gọn lại, súc tích hơn.' }, { id: 'funny', label: '✨ Hài hước', prompt: 'Viết lại với giọng văn hài hước, năng lượng hơn.' }, { id: 'professional', label: '✨ Chuyên nghiệp', prompt: 'Viết lại chuyên nghiệp và trang trọng hơn.' }, { id: 'emoji', label: '✨ Thêm Emoji', prompt: 'Bổ sung thêm các emoji phù hợp để bài viết sinh động.' }, { id: 'structure', label: '✨ Chia mục rõ ràng', prompt: 'Sử dụng bullet points và tiêu đề để chia bố cục rõ ràng hơn.' }, ]; const toggleChip = (chipId) => { setSelectedChips(prev => prev.includes(chipId) ? prev.filter(id => id !== chipId) : [...prev, chipId] ); }; const handleApplyRefine = () => { const chipPrompts = selectedChips.map(id => refineOptions.find(opt => opt.id === id).prompt).join(' '); const finalInstruction = `${chipPrompts} ${refineQuery}`.trim(); if (finalInstruction) { handleRefineAi(finalInstruction); setRefineQuery(''); setSelectedChips([]); } }; const toggleSpace = (id) => { if (typeof setSelectedSpaces === 'function') { setSelectedSpaces(prev => { const current = Array.isArray(prev) ? prev : []; return current.includes(id) ? current.filter(item => item !== id) : [...current, id]; }); } }; return (
{/* Left Panel - Configuration */}

Cấu hình

{Array.isArray(taSpaces) && taSpaces.map(space => ( ))}
document.getElementById('slide-upload').click()} >
Tải Slide (PDF/Ảnh)
{uploadedFile && (
{uploadedFile.filename}
)}
setScheduleDate(e.target.value)} />
{/* Right Panel - Content Area */}
{/* Header */}

Bản thảo Recap

{aiPreview && !uploading && (
)}
{/* Processing Overlay */} {uploading && (

AI đang phân tích...

Đang đọc file và tạo tóm tắt bài giảng

)} {/* Empty State */} {!aiPreview && !uploading && (

Chọn lớp và nhấn tạo phác thảo để bắt đầu

)} {/* Scrollable Content Area */}
{/* AI Preview Content - 2 Columns */} {aiPreview && !uploading && (
{/* Column 1: Tóm tắt bài giảng */}

Tóm tắt bài giảng

{isEditing ? (