import { X } from "lucide-react"; import { memo, useEffect } from "react"; import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts"; interface AssetPerformanceModalProps { assetName: string; performances: { year: number; percentage: number; price?: number }[]; onClose: () => void; } export const AssetPerformanceModal = memo(({ assetName, performances, onClose }: AssetPerformanceModalProps) => { const sortedPerformances = [...performances].sort((a, b) => a.year - b.year); // Prevent body scroll when modal is open useEffect(() => { document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = 'unset'; }; }, []); const CustomizedDot = (props: any) => { const { cx, cy, payload } = props; return ( = 0 ? '#22c55e' : '#ef4444'} /> ); }; return (
{/* Header - Fixed */}

{assetName} - Yearly Performance

{/* Content - Scrollable */}
{/* Chart */}
`${value.toFixed(2)}%`} /> `€${value.toFixed(2)}`} /> { if (name === 'Performance') return [`${value.toFixed(2)}%`, name]; return [`€${value.toFixed(2)}`, name]; }} labelFormatter={(year) => `Year ${year}`} /> } strokeWidth={2} yAxisId="left" />
{/* Performance Cards */}
{sortedPerformances.map(({ year, percentage, price }) => (
= 0 ? 'bg-green-100 dark:bg-green-900/30' : 'bg-red-100 dark:bg-red-900/30' }`} >
{year}
= 0 ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400' }`}> {percentage.toFixed(2)}%
{price && (
€{price.toFixed(2)}
)}
))}
); });