import React, { useState, FormEvent } from 'react'; interface InputData { prompt: string; width: number; height: number; steps: number; fps: number; seed?: number; } const IndexPage = () => { const [inputData, setInputData] = useState({ prompt: '', width: 1024, height: 576, steps: 40, fps: 15, seed: undefined, }); const [output, setOutput] = useState(null); const [isLoading, setIsLoading] = useState(false); const handleChange = (e: React.ChangeEvent) => { const { name, value } = e.target; setInputData((prevData) => ({ ...prevData, [name]: value })); }; const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setIsLoading(true); console.log("Making API call with payload:", inputData); try { const response = await fetch('/api/replicate', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(inputData), }); const result = await response.json(); console.log("API call response:", result); if (response.ok) { setIsLoading(false); setOutput(result.prediction); // Updated this line to set the prediction object } else { setIsLoading(false); console.error("API returned an error:", result); } } catch (error) { setIsLoading(false); console.error("An error occurred:", error); } }; return (
{isLoading &&
Processing...
} {output && output.output && (

Generated Video:

)}
); }; export default IndexPage;