import React, { useState, useEffect, useRef } from 'react'; import { X, Sparkles, Wand2, Loader2 } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; interface AIInstructionModalProps { isOpen: boolean; onClose: () => void; onGenerate: (instructions: string) => Promise; currentContent?: string; } export const AIInstructionModal: React.FC = ({ isOpen, onClose, onGenerate, currentContent }) => { const [instructions, setInstructions] = useState(''); const [isGenerating, setIsGenerating] = useState(false); const textareaRef = useRef(null); useEffect(() => { if (isOpen) { setInstructions(''); setIsGenerating(false); // Focus after animation setTimeout(() => textareaRef.current?.focus(), 100); } }, [isOpen]); const handleSubmit = async (e?: React.FormEvent) => { e?.preventDefault(); if (!instructions.trim() || isGenerating) return; setIsGenerating(true); try { await onGenerate(instructions); onClose(); } catch (error) { console.error("Analysis failed", error); } finally { setIsGenerating(false); } }; const isContentEmpty = !currentContent || currentContent.trim().length === 0; const title = isContentEmpty ? "¿Qué deseas crear?" : "¿Cómo deseas mejorarlo?"; const placeholder = isContentEmpty ? "Ej: Escribe un resumen sobre React Hooks..." : "Ej: Hazlo más conciso, añade emojis, tradúcelo al inglés..."; return ( {isOpen && ( <> {/* Backdrop */} {/* Modal */}
{/* Header */}

{title}

Dante AI Assistant

{/* Body */}