import { useState } from 'react' import { Sparkles, Loader2, AlertCircle } from 'lucide-react' interface AIPromptDialogProps { isOpen: boolean onClose: () => void onGenerate: (prompt: string) => Promise flowType: 'troubleshooting' | 'procedural' | 'maintenance' } const FLOW_TYPE_LABELS = { troubleshooting: 'Troubleshooting Flow', procedural: 'Project Flow', maintenance: 'Maintenance Flow', } export function AIPromptDialog({ isOpen, onClose, onGenerate, flowType, }: AIPromptDialogProps) { const [prompt, setPrompt] = useState('') const [isGenerating, setIsGenerating] = useState(false) const [error, setError] = useState(null) if (!isOpen) return null const handleGenerate = async () => { if (!prompt.trim()) return setIsGenerating(true) setError(null) try { await onGenerate(prompt) setPrompt('') onClose() } catch (e) { setError(e instanceof Error ? e.message : 'Generation failed. Please try again.') } finally { setIsGenerating(false) } } return (
{/* Backdrop */}
!isGenerating && onClose()} /> {/* Dialog */}

AI-Assisted {FLOW_TYPE_LABELS[flowType]}

Describe what you want to build and AI will generate a starting structure for you.