import type { Trade } from '../../lib/api' interface Props { trades: Trade[] } export default function PnLSummary({ trades }: Props) { const closed = trades.filter((t) => t.status === 'closed' && t.pnl !== null) const totalPnl = closed.reduce((acc, t) => acc + (t.pnl ?? 0), 0) const winners = closed.filter((t) => (t.pnl ?? 0) > 0) const winRate = closed.length > 0 ? (winners.length / closed.length) * 100 : 0 const stats = [ { label: 'PnL Total', value: `${totalPnl >= 0 ? '+' : ''}${totalPnl.toFixed(2)}`, color: totalPnl >= 0 ? 'text-[#26a69a]' : 'text-[#ef5350]', }, { label: 'Win Rate', value: `${winRate.toFixed(1)}%`, color: winRate >= 50 ? 'text-[#26a69a]' : 'text-[#ef5350]', }, { label: 'Trades', value: closed.length.toString(), color: 'text-white', }, { label: 'Ouverts', value: trades.filter((t) => t.status === 'open').length.toString(), color: 'text-[#6366f1]', }, ] return (