diff --git a/TODO b/TODO index 45a3dd5aa..319176491 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,6 @@ tables should be aware that rows are players who have pids. add bulk/all/select - extra places to add DataTable - SortableTable - especially for roster - remove Delete Players button on roster -- some better UI for league leaders when no players are in any table - test - interaction with hideAllControls and other options - hideAllControls should move to a string always? diff --git a/src/ui/views/Leaders.tsx b/src/ui/views/Leaders.tsx index ab6c519af..71f5b9b20 100644 --- a/src/ui/views/Leaders.tsx +++ b/src/ui/views/Leaders.tsx @@ -73,6 +73,8 @@ const Leaders = ({ const totals = statType === "totals" && isSport("basketball"); + const noQualifiedLeaders = categories.every(cat => cat.leaders.length === 0); + return ( <> -
- {categories.map(cat => { - const cols = getCols(["#", "Name", `stat:${cat.stat}`]); - const statCol = cols[2]; - if (cat.titleOverride === statCol.desc) { - throw new Error("Useless titleOverride"); - } + {noQualifiedLeaders ? ( +

No data yet.

+ ) : ( +
+ {categories.map(cat => { + const cols = getCols(["#", "Name", `stat:${cat.stat}`]); + const statCol = cols[2]; + if (cat.titleOverride === statCol.desc) { + throw new Error("Useless titleOverride"); + } - const title = cat.titleOverride ?? statCol.desc ?? "???"; - const desc = cat.titleOverride ? statCol.desc : undefined; + const title = cat.titleOverride ?? statCol.desc ?? "???"; + const desc = cat.titleOverride ? statCol.desc : undefined; - const rows: DataTableRow[] = cat.leaders.map((p, j) => { - const numericSeason = - season === "career" - ? undefined - : season === "all" - ? p.season - : season; + const rows: DataTableRow[] = cat.leaders.map((p, j) => { + const numericSeason = + season === "career" + ? undefined + : season === "all" + ? p.season + : season; - let teamUrlParts; - if (season === "career") { - teamUrlParts = ["team_history", `${p.abbrev}_${p.tid}`]; - } else { - teamUrlParts = ["roster", `${p.abbrev}_${p.tid}`, numericSeason]; - } + let teamUrlParts; + if (season === "career") { + teamUrlParts = ["team_history", `${p.abbrev}_${p.tid}`]; + } else { + teamUrlParts = [ + "roster", + `${p.abbrev}_${p.tid}`, + numericSeason, + ]; + } - const seasonText = p.season !== undefined ? ` ${p.season}` : ""; + const seasonText = p.season !== undefined ? ` ${p.season}` : ""; - return { - key: p.key, - metadata: { - type: "player", - pid: p.pid, - season: numericSeason ?? "career", - playoffs, - }, - data: [ - { - value: j + 1, - style: { - // Need this here rather than in cols becuase we're using hideHeader - width: 1, - }, + return { + key: p.key, + metadata: { + type: "player", + pid: p.pid, + season: numericSeason ?? "career", + playoffs, }, - <> - - - {p.abbrev} - {seasonText} - - {p.pos} - , - { - value: helpers.roundStat(p.stat, cat.stat, totals), - classNames: "text-end", + data: [ + { + value: j + 1, + style: { + // Need this here rather than in cols becuase we're using hideHeader + width: 1, + }, + }, + <> + + + {p.abbrev} + {seasonText} + + {p.pos} + , + { + value: helpers.roundStat(p.stat, cat.stat, totals), + classNames: "text-end", + }, + ], + classNames: { + "table-danger": highlightActiveAndHOF && p.hof, + "table-success": + highlightActiveAndHOF && p.retiredYear === Infinity, + "table-info": p.userTeam, }, - ], - classNames: { - "table-danger": highlightActiveAndHOF && p.hof, - "table-success": - highlightActiveAndHOF && p.retiredYear === Infinity, - "table-info": p.userTeam, - }, - }; - }); + }; + }); - return ( -
- - {title} ({statCol.title}) - - } - name={`LeagueLeaders_${cat.stat}`} - pagination - rows={rows} - /> -
- ); - })} -
+ return ( +
+ + {title} ({statCol.title}) + + } + name={`LeagueLeaders_${cat.stat}`} + pagination + rows={rows} + /> +
+ ); + })} +
+ )} ); };