diff --git a/apps/app/components/pipeline/create-pipeline.tsx b/apps/app/components/pipeline/create-pipeline.tsx index 651439dd..458e5334 100644 --- a/apps/app/components/pipeline/create-pipeline.tsx +++ b/apps/app/components/pipeline/create-pipeline.tsx @@ -14,11 +14,13 @@ import { createPipelineFromFormData } from "@/app/api/pipelines/create"; import { toast } from "sonner"; import { useRouter } from "next/navigation"; import { LoaderCircleIcon } from "lucide-react"; +import PipelineParamsSelector from "./pipeline-params-selector"; export default function CreatePipeline() { const { authenticated, user, ready: isAuthLoaded } = usePrivy(); const [formData, setFormData] = useState>({}); const [isSubmitting, setIsSubmitting] = useState(false); + const [currentStep, setCurrentStep] = useState(1); const router = useRouter(); const handleChange = ( @@ -26,10 +28,46 @@ export default function CreatePipeline() { id: string ) => { setFormData((prev) => ({ ...prev, [id]: e.target.value })); - console.log(formData); }; - const handleSubmit = async () => { + const handleNext = async () => { + + if (!formData.name) { + toast.error("Please enter a name"); + return; + } + if (!formData.description) { + toast.error("Please enter a description"); + return; + } + if (!formData.comfyJson) { + toast.error("Please upload a ComfyUI JSON file"); + return; + } + + try { + const jsonFile = formData.comfyJson as File; + const jsonContent = await jsonFile.text(); + const parsedJson = JSON.parse(jsonContent); + + setFormData(prev => ({ + ...prev, + comfyJson: parsedJson + })); + + setCurrentStep(2); + } catch (error) { + console.error("Error parsing JSON:", error); + toast.error("Invalid JSON file"); + return; + } + }; + + const handleBack = () => { + setCurrentStep(1); + }; + + const handleSubmit = async (updatedFormData: Record) => { if (!user?.id) { toast.error("User not found"); return; @@ -38,23 +76,29 @@ export default function CreatePipeline() { const toastId = toast.loading("Creating pipeline..."); try { const formDataToSend = new FormData(); - Object.entries(formData).forEach(([key, value]) => { - formDataToSend.append(decamelize(key), value as any); + Object.entries(updatedFormData).forEach(([key, value]) => { + if (key === 'comfyJson') { + // Create a new File object from the JSON string + const jsonBlob = new Blob([JSON.stringify(value)], { type: 'application/json' }); + formDataToSend.append(decamelize(key), jsonBlob, 'workflow.json'); + } else { + formDataToSend.append(decamelize(key), value as any); + } }); + const { pipeline, smokeTestStream } = await createPipelineFromFormData( formDataToSend, user.id ); - console.log("Pipeline created::Client::", pipeline); router.push( `/pipelines/${pipeline.id}?streamId=${smokeTestStream.id}&validation=true` ); toast.dismiss(toastId); toast.success("Pipeline created successfully"); } catch (error) { + console.error("Error details:", error); toast.dismiss(toastId); - const errorMessage = - error instanceof Error ? error.message : String(error); + const errorMessage = error instanceof Error ? error.message : String(error); toast.error(`Failed to create pipeline: ${errorMessage}`); } finally { setIsSubmitting(false); @@ -84,65 +128,75 @@ export default function CreatePipeline() {

Create pipeline

-
-
- - handleChange(e, "name")} - /> -
+ {currentStep === 1 ? ( +
+ {/* Step 1 - Pipeline creation form */} +
+ + handleChange(e, "name")} + /> +
-
- - handleChange(e, "version")} - /> -
+
+ + handleChange(e, "version")} + /> +
-
- -