import React from "react"; import { Trash2 } from "lucide-react"; export const DraftsComparisonTable = ({ drafts, horizonGWs, activeDraftId, globalPlayers, setActiveDraftId, getValidLayout, availableGWs, baselineFt, ftAtStartOfGw, setDrafts }) => { if (!drafts || drafts.length === 0) return null; const handleDeleteDraft = (e, id) => { e.stopPropagation(); // Prevents the row click from triggering if (drafts.length <= 1) return; const nextDrafts = drafts.filter(d => d.id !== id); setDrafts(nextDrafts); if (activeDraftId === id) setActiveDraftId(nextDrafts[0].id); }; const getDraftGwState = (draft, gw) => { if (draft.cachedEvs && draft.cachedEvs[gw]) { return draft.cachedEvs[gw]; } const chip = draft.chipsByGw?.[gw]; const capMult = chip === "tc" ? 3 : 2; let squad = []; let capId = null; if (gw === draft.activeGW) { squad = draft.teamData; capId = draft.captainId; } else { const lock = draft.manualOverrides?.[gw]; if (lock && lock.ids && lock.ids.length === 15) { squad = lock.ids.map(id => draft.teamData?.find(p => String(p.ID) === String(id)) || globalPlayers.find(p => String(p.ID) === String(id))).filter(Boolean); capId = lock.cap; if (squad.length !== 15) { const opt = getValidLayout(draft.teamData, gw); if (opt) { squad = opt.optimalArray; capId = opt.cap; } } } else { const opt = getValidLayout(draft.teamData, gw); if (opt) { squad = opt.optimalArray; capId = opt.cap; } } } let gwPts = 0; if (squad && squad.length === 15) { squad.slice(0, 11).forEach(p => { if (!p.isBlank) gwPts += (Number(p[`${gw}_Pts`]) || 0) * (String(p.ID) === String(capId) ? capMult : 1); }); let ofIdx = 0; squad.slice(11, 15).forEach(p => { if (!p.isBlank) { if (chip === "bb") gwPts += (Number(p[`${gw}_Pts`]) || 0); else if (p.Pos === "G") gwPts += (Number(p[`${gw}_Pts`]) || 0) * 0.04; else { gwPts += (Number(p[`${gw}_Pts`]) || 0) * ([0.17, 0.05, 0.02][ofIdx] || 0.02); ofIdx++; } } }); } const ftStart = ftAtStartOfGw(gw, availableGWs, baselineFt, draft.transfersByGw || {}, draft.chipsByGw || {}); const moves = draft.transfersByGw?.[gw]?.count || 0; const isChipFree = chip === "wc" || chip === "fh"; const hits = isChipFree ? 0 : Math.max(0, moves - ftStart); return { ev: gwPts - (hits * 4), chip, hits, ftStart, moves, isChipFree }; }; return (
| Timeline | {horizonGWs.map(gw => (GW{gw} | ))}Total EV |
|---|---|---|
|
{draft.name}
{/* FIX: Native Flexbox Delete Button (always clickable, visually clean) */}
{drafts.length > 1 && (
)}
|
{rowData.map((d, i) => (
55 ? 'text-[#818cf8]' : 'text-indigo-200') : 'text-slate-500'}`}>
{d.ev.toFixed(1)}
{d.chip || ""}
{d.hits > 0 ? `-${d.hits*4}` : "-"}
{d.isChipFree ? `${d.moves}/∞` : `${d.moves}/${d.ftStart}`}
|
))}
{totalEv.toFixed(1)}
|