import { Link } from 'react-router-dom'; import type { TradeSetup } from '../../lib/types'; import { formatPrice, formatDateTime } from '../../lib/format'; export type SortColumn = 'symbol' | 'direction' | 'entry_price' | 'stop_loss' | 'target' | 'rr_ratio' | 'composite_score' | 'detected_at'; export type SortDirection = 'asc' | 'desc'; interface TradeTableProps { trades: TradeSetup[]; sortColumn: SortColumn; sortDirection: SortDirection; onSort: (column: SortColumn) => void; } const columns: { key: SortColumn; label: string }[] = [ { key: 'symbol', label: 'Symbol' }, { key: 'direction', label: 'Direction' }, { key: 'entry_price', label: 'Entry' }, { key: 'stop_loss', label: 'Stop Loss' }, { key: 'target', label: 'Target' }, { key: 'rr_ratio', label: 'R:R' }, { key: 'composite_score', label: 'Score' }, { key: 'detected_at', label: 'Detected' }, ]; function sortIndicator(column: SortColumn, active: SortColumn, dir: SortDirection) { if (column !== active) return ''; return dir === 'asc' ? ' ▲' : ' ▼'; } export function TradeTable({ trades, sortColumn, sortDirection, onSort }: TradeTableProps) { if (trades.length === 0) { return
No trade setups match the current filters.
; } return (| onSort(col.key)} > {col.label}{sortIndicator(col.key, sortColumn, sortDirection)} | ))}|||||||
|---|---|---|---|---|---|---|---|
| {trade.symbol} | {trade.direction} | {formatPrice(trade.entry_price)} | {formatPrice(trade.stop_loss)} | {formatPrice(trade.target)} | {trade.rr_ratio.toFixed(2)} | 70 ? 'text-emerald-400' : trade.composite_score >= 40 ? 'text-amber-400' : 'text-red-400'}`}> {Math.round(trade.composite_score)} | {formatDateTime(trade.detected_at)} |