'use client'; import { useState, useEffect, useCallback } from 'react'; import { RetouchUpload } from '@/components/retouch/RetouchUpload'; import { BeforeAfterSlider } from '@/components/retouch/BeforeAfterSlider'; import { PriceComparison } from '@/components/retouch/PriceComparison'; import { getRetouchResult, type RetouchResultResponse } from '@/lib/retouch'; export default function RetouchPage() { const [retouchId, setRetouchId] = useState(null); const [result, setResult] = useState(null); const [polling, setPolling] = useState(false); const handleUploadComplete = useCallback((id: string) => { setRetouchId(id); setResult(null); setPolling(true); }, []); useEffect(() => { if (!retouchId || !polling) return; let cancelled = false; const poll = async () => { try { const res = await getRetouchResult(retouchId); if (cancelled) return; setResult(res); if (res.status === 'completed' || res.status === 'failed') { setPolling(false); } } catch { if (cancelled) return; // Keep polling on error } }; poll(); const interval = setInterval(poll, 3000); return () => { cancelled = true; clearInterval(interval); }; }, [retouchId, polling]); const buildImageUrl = (path: string | null | undefined): string => { if (!path) return ''; const filename = path.split('/').pop(); const base = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'; return `${base.replace('/api/v1', '')}/uploads/${filename}`; }; return (

Bildretusche & Preisvergleich

Image Upload

{result && (

Retouch Result

Status: {result.status}
{result.error_message && (
{result.error_message}
)} {result.status === 'completed' && result.retouched_file_path && ( )} {result.status === 'processing' && (
Retouching in progress... This may take a few moments.
)}
)}

Price Comparison

); }