import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Sparkles, ArrowRight, Activity, Copy, CheckCircle, AlertTriangle, ScanEye } from 'lucide-react'; import axios from 'axios'; import { useNavigate } from 'react-router-dom'; const XRayPage: React.FC = () => { const { t } = useTranslation(); const navigate = useNavigate(); const [url, setUrl] = useState(''); const [loading, setLoading] = useState(false); const [result, setResult] = useState(null); const [error, setError] = useState(''); const [copied, setCopied] = useState(false); // Mock result for dev preview if needed, but we connect to real API const handleAnalyze = async () => { if (!url) return; setLoading(true); setError(''); setResult(null); try { const response = await axios.post('/api/xray', { url }, { headers: { Authorization: `Bearer ${localStorage.getItem('token')}` } }); setResult(response.data); } catch (err: any) { console.error(err); setError(err.response?.data?.error || 'Failed to analyze. Please check the URL and try again.'); } finally { setLoading(false); } }; const copyPrompt = () => { if (result?.analysis?.superiorPrompt) { navigator.clipboard.writeText(result.analysis.superiorPrompt); setCopied(true); setTimeout(() => setCopied(false), 2000); } }; return (
{/* Header Section */}

Competitor X-Ray

Paste any Etsy or Pinterest product URL. Our AI will deconstruct its success formula and generate a superior prompt for you.

{/* Input Section */}
setUrl(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && handleAnalyze()} />
{error && (
{error}
)} {/* Results Section */} {result && (
{/* Left: Competitor Analysis */}
Competitor
Competitor Asset

{result.metadata.title}

{result.metadata.description}

Visual DNA Detected

{result.analysis.visualDna?.map((tag: string, i: number) => ( {tag} ))}

Identified Weaknesses (Sentiment Gap)

"{result.analysis.sentimentGap}"
{/* Right: The Solution (Superior Prompt) */}
{/* Decorative background glow */}

Superior Formula

Optimized for high-conversion & aesthetics

{result.analysis.superiorPrompt}

Why This Wins

{result.analysis.gapAnalysis}

Ready to dominate?
{/* Pro Tip */}

Pro Tip

Use this prompt in the "Analyst" mode for best results. Consider generating 4 variations to test different lighting setups.

)}
); }; export default XRayPage;