import React, { useRef, useState, useEffect } from 'react'; import { AreaChart, Area, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid } from 'recharts'; import Draggable from 'react-draggable'; import { FaPen, FaEraser, FaSave, FaTimes } from 'react-icons/fa'; import html2canvas from 'html2canvas'; const Dashboard = ({ report, onClose }) => { const [isDrawingMode, setIsDrawingMode] = useState(false); const canvasRef = useRef(null); const containerRef = useRef(null); const [context, setContext] = useState(null); // Prepare Data for Chart const chartData = report.deals.map((deal, index) => ({ name: index, // Simplified X axis (Trade #) balance: deal.balance, profit: deal.profit })); // Setup Canvas for drawing useEffect(() => { if (canvasRef.current) { const canvas = canvasRef.current; canvas.width = canvas.offsetWidth; canvas.height = canvas.offsetHeight; const ctx = canvas.getContext('2d'); ctx.strokeStyle = "yellow"; ctx.lineWidth = 3; setContext(ctx); } }, [isDrawingMode]); const startDrawing = (e) => { if (!isDrawingMode || !context) return; context.beginPath(); context.moveTo(e.nativeEvent.offsetX, e.nativeEvent.offsetY); }; const draw = (e) => { if (!isDrawingMode || !context || e.buttons !== 1) return; context.lineTo(e.nativeEvent.offsetX, e.nativeEvent.offsetY); context.stroke(); }; const saveReport = () => { if (containerRef.current) { html2canvas(containerRef.current).then(canvas => { const link = document.createElement('a'); link.download = `Remodeled_Report_${report.accountId}.png`; link.href = canvas.toDataURL(); link.click(); }); } }; return (
{/* Header / Drag Handle */}

Account: {report.accountId}

{/* Content */}
{/* Canvas Overlay */} {/* Grid Layout for Remodeled Report */}

Equity & Balance Curve

{/* Stat Cards */}

Total Deals

{report.deals.length}

Final Balance

${report.deals[report.deals.length - 1]?.balance.toFixed(2)}

Profit Factor

1.5

{/* Placeholder calculation */}
{/* Data Table */}
{report.deals.slice(0, 10).map((d, i) => ( ))}
Time Symbol Type Profit
{d.time} {d.symbol} {d.type} = 0 ? 'text-green-500' : 'text-red-500'}`}> {d.profit}
); }; export default Dashboard;