import { useState } from 'react'; import { Upload, Mic, Type, Video, Download } from 'lucide-react'; export default function AdCreator() { const [mediaFile, setMediaFile] = useState(null); const [adText, setAdText] = useState(''); const [isGenerating, setIsGenerating] = useState(false); const [generatedVideo, setGeneratedVideo] = useState(null); const [previewUrl, setPreviewUrl] = useState(null); // Added state for preview URL const handleMediaUpload = (e) => { const file = e.target.files[0]; if (file) { // Revoke previous URL to prevent memory leaks if (previewUrl) { URL.revokeObjectURL(previewUrl); } const newPreviewUrl = URL.createObjectURL(file); setPreviewUrl(newPreviewUrl); setMediaFile(file); // Store the actual file instead of the URL } }; // Cleanup function to prevent memory leaks const cleanup = () => { if (previewUrl) { URL.revokeObjectURL(previewUrl); } }; const handleRemoveMedia = () => { cleanup(); setPreviewUrl(null); setMediaFile(null); }; const generateAd = () => { setIsGenerating(true); // Simulate AI processing setTimeout(() => { setIsGenerating(false); setGeneratedVideo(true); }, 2000); }; // Clean up URLs when component unmounts useEffect(() => { return () => cleanup(); }, []); return (
{/* Header */}

AI Ad Creator

Create professional ads in minutes with AI

{/* Main Content */}
{/* Left Column - Input */}
{/* Media Upload */}
{!previewUrl ? ( ) : (
Preview
)}
{/* Text Input */}

Ad Script