import { useState } from 'react'; import { Wand2, CheckCircle, Loader2 } from 'lucide-react'; import { Book, useBookStore } from '../../stores/bookStore'; import { booksApi } from '../../services/api'; interface BookOutlineGeneratorProps { book: Book; onComplete: (outline: any) => void; } export default function BookOutlineGenerator({ book, onComplete }: BookOutlineGeneratorProps) { const { activeBook } = useBookStore(); const [isGenerating, setIsGenerating] = useState(false); const [error, setError] = useState(''); const outline = activeBook?.outline; const handleGenerate = async () => { setIsGenerating(true); setError(''); try { const response = await booksApi.generateOutline(book.genre, book.idea, book.title); const generatedOutline = response.data.outline; onComplete(generatedOutline); } catch (err: any) { setError(err.response?.data?.error || 'Failed to generate outline'); } finally { setIsGenerating(false); } }; return (
{/* Book Info Summary */}

{book.title || 'Untitled Book'}

Genre: {book.genre}

{book.idea}

{!outline && ( )}
{/* Error Message */} {error && (

{error}

)} {/* Outline Display */} {outline && (

Generated Outline: {outline.title || book.title}

{outline.logline && (

Logline

{outline.logline}

)}

Chapter Outline

{outline.chapters?.map((chapter: any, index: number) => (
{chapter.number || index + 1}
{chapter.title || `Chapter ${chapter.number || index + 1}`}

{chapter.summary || 'No summary available'}

))}

Ready to start writing! Navigate to the Write tab to begin.

)} {/* Initial State */} {!outline && !isGenerating && (

Ready to Generate

Click "Generate Outline" to create a detailed chapter outline based on your genre and book idea. The AI will create a structure following genre-specific patterns.

)}
); }