import React, { useEffect, useState } from 'react'; import axios from 'axios'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { Tooltip } from './components/Tooltip'; import { useAuth } from './AuthContext'; import { Shield, Users, BarChart3, Database, Sparkles, ScanEye, BrainCircuit, ArrowRight } from 'lucide-react'; interface ProjectSummary { id: string; niche: string; productType: string; createdAt: string; masterPath: string | null; seoTitle: string; } interface DashboardProps { onSelectProject: (id: string) => void; onNewProject: () => void; } const Dashboard: React.FC = ({ onSelectProject, onNewProject }) => { const { t } = useTranslation(); const { user } = useAuth(); const navigate = useNavigate(); const [projects, setProjects] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [remixTargetId, setRemixTargetId] = useState(null); const [targetProductType, setTargetProductType] = useState("Phone Wallpaper"); const [isRemixing, setIsRemixing] = useState(false); useEffect(() => { fetchProjects(); }, []); const fetchProjects = async () => { try { setLoading(true); const res = await axios.get('/api/projects'); setProjects(res.data.projects); } catch (err: any) { setError(err.message); } finally { setLoading(false); } }; const handleDeleteProject = async (e: React.MouseEvent, id: string) => { e.stopPropagation(); // Prevent card click if (!window.confirm("Are you sure you want to delete this project? This action cannot be undone.")) return; try { await axios.delete(`/api/projects/${id}`); // Optimistic update setProjects(prev => prev.filter(p => p.id !== id)); } catch (err: any) { alert(`Failed to delete project: ${err.message}`); } }; const handleRemixProject = async () => { if (!remixTargetId) return; setIsRemixing(true); try { await axios.post(`/api/projects/${remixTargetId}/remix`, { targetProductType }); alert(`Project Remixed for ${targetProductType}!`); setRemixTargetId(null); fetchProjects(); // Refresh list to see new project } catch (err: any) { alert(`Remix Failed: ${err.message}`); } finally { setIsRemixing(false); } }; return (
{/* The Analyst Suite Section */}

Mastermind Intelligence Suite

Phase 1: Analysis & Optimization Tools

{/* Competitor X-Ray Card */}
navigate('/xray')} className="group bg-white p-6 rounded-3xl border border-stone-100 shadow-lg hover:shadow-xl hover:-translate-y-1 transition-all cursor-pointer relative overflow-hidden" >

Competitor X-Ray

Deconstruct competitor listings to uncover their "Visual DNA" and generate superior prompts.

Launch Tool
{/* Neuro-Scorecard Card */}
navigate('/scorecard')} className="group bg-white p-6 rounded-3xl border border-stone-100 shadow-lg hover:shadow-xl hover:-translate-y-1 transition-all cursor-pointer relative overflow-hidden" >

Neuro-Scorecard

Predict "Click-Through Rate" with AI-powered neuro-marketing scoring (Dopamine, Serotonin).

Launch Tool

{t('dashboard.subtitle')}

{/* ETSY CONNECT BUTTON */}
{loading && (
{[1, 2, 3, 4].map(i => (
))}
)} {error && (
Error loading projects: {error}
)} {!loading && projects.length === 0 && (

{t('dashboard.no_projects')}

{t('dashboard.start_masterpiece')}

)}
{projects.map((p) => (
onSelectProject(p.id)} className="group relative bg-white rounded-3xl p-3 shadow-lg hover:shadow-2xl hover:-translate-y-2 transition-all duration-300 text-left cursor-pointer" >
{p.masterPath ? ( {p.niche} ) : (
Pending
)}
{/* DELETE BUTTON */} {/* REMIX BUTTON */} {/* DUPLICATE BUTTON */}
{p.productType} {new Date(p.createdAt).toLocaleDateString()}

{p.seoTitle}

{p.niche}

))}
{/* REMIX MODAL */} {remixTargetId && (

✨ Smart Remix

Transform this design into a new product format while keeping its Visual DNA.

{["Wall Art", "Phone Wallpaper", "Sticker", "Bookmark", "Planner", "Social Media Kit"].map(type => ( ))}
)}
); }; export default Dashboard;