import React, { useState } from 'react'; import { motion } from 'framer-motion'; import { Upload, Image as ImageIcon, Loader } from 'lucide-react'; import axios from 'axios'; const InteriorStyleTransformer = () => { const [selectedImage, setSelectedImage] = useState(null); const [styleInput, setStyleInput] = useState(''); const [generatedImage, setGeneratedImage] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); // Handle image upload const handleImageUpload = (event) => { const file = event.target.files[0]; if (file) { setSelectedImage(URL.createObjectURL(file)); setGeneratedImage(null); setError(null); } }; // Handle style input change const handleStyleInput = (event) => { setStyleInput(event.target.value); }; // Handle form submission to process the image const handleSubmit = async () => { if (!selectedImage || !styleInput) { setError('Please upload an image and specify a design style.'); return; } setIsLoading(true); setError(null); try { // Prepare form data const formData = new FormData(); const fileInput = document.querySelector('input[type="file"]'); formData.append('image', fileInput.files[0]); formData.append('style', styleInput); // Hypothetical API call to an AI image processing service const response = await axios.post('https://api.example.com/transform-interior', formData, { headers: { 'Content-Type': 'multipart/form-data' }, }); // Assuming the API returns a URL to the generated image setGeneratedImage(response.data.imageUrl); } catch (err) { setError('Failed to process the image. Please try again.'); console.error(err); } finally { setIsLoading(false); } }; return (

Transform Your Interior Design

Upload a photo of your space and specify your desired interior design style.

{/* Image Upload Section */}

Upload Your Room Photo

{selectedImage && ( Uploaded room )}
{/* Style Input and Generated Image Section */}

Specify Design Style

{isLoading ? (
Processing...
) : ( 'Generate Design' )}
{error &&

{error}

} {generatedImage && (

Generated Design

Generated interior design
)}
); }; export default InteriorStyleTransformer;