"use client"; import { useState, useCallback } from "react"; import { WorkflowFile } from "@/store/workflowStore"; import { QuickstartBackButton } from "./QuickstartBackButton"; interface PromptWorkflowViewProps { onBack: () => void; onWorkflowGenerated: (workflow: WorkflowFile) => void; } export function PromptWorkflowView({ onBack, onWorkflowGenerated, }: PromptWorkflowViewProps) { const [description, setDescription] = useState(""); const [isGenerating, setIsGenerating] = useState(false); const [error, setError] = useState(null); const handleGenerate = useCallback(async () => { if (!description || description.trim().length < 3) { setError("Please describe your workflow (at least 3 characters)"); return; } setError(null); setIsGenerating(true); try { const response = await fetch("/api/quickstart", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ description: description.trim(), contentLevel: "full", }), }); const result = await response.json(); if (!result.success) { throw new Error(result.error || "Failed to generate workflow"); } if (result.workflow) { onWorkflowGenerated(result.workflow); } } catch (err) { console.error("Prompt workflow error:", err); setError( err instanceof Error ? err.message : "Failed to generate workflow" ); } finally { setIsGenerating(false); } }, [description, onWorkflowGenerated]); const canGenerate = description.trim().length >= 3 && !isGenerating; return (
{/* Header */}

Prompt a Workflow

{/* Content */}
{/* Description Input */}