myheats

Live heats, scoring and leaderboard for sport events
git clone https://git.in0rdr.ch/myheats.git
Log | Files | Refs | Pull requests | README | LICENSE

commit 80fdd5ff69ad856fefa6e7196edb947e62f00dd2
parent 7bafe598f3fa118c49a69607743487a801652827
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Sun, 18 Aug 2024 12:59:16 +0200

feat(leaderboard): style export form

Diffstat:
Msrc/App.css | 4++--
Msrc/Leaderboard.jsx | 18++++++++++--------
Msrc/utils.js | 8++++++--
3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/App.css b/src/App.css @@ -91,10 +91,10 @@ footer .login button { font-size: 25px; } -.loginForm { +.loginForm, .exportForm { margin: 30px; } -.loginForm button, .loginForm input { +.loginForm button, .loginForm input, .exportForm button { width: 250px; display: block; } diff --git a/src/Leaderboard.jsx b/src/Leaderboard.jsx @@ -108,16 +108,18 @@ async function newHeatFromLeaderboard(e, {leaderboard, rankingComp, selectHeatRe window.location.reload() } +// export leaderboard with current ranking function ExportForm({leaderboard, heatSelection, rankingComp}) { return ( - // export leaderboard with current ranking - <form method='post' onSubmit={e => exportCSV( - e, - leaderboard, - heatSelection, - rankingComp)}> - <button type='submit'>&#9663; export scores</button> - </form> + <div className='exportForm'> + <form method='post' onSubmit={e => exportCSV( + e, + leaderboard, + heatSelection, + rankingComp)}> + <button type='submit'>&#9663; export</button> + </form> + </div> ) } diff --git a/src/utils.js b/src/utils.js @@ -1,6 +1,11 @@ export const exportCSV = async function(e, leaderboard, heatSelection, rankingComp) { e.preventDefault() + if (leaderboard.length === 0) { + alert('Leaderboard is empty, nothing to export') + return + } + // concatenante heat labels const heatNames = heatSelection.map(h => h.label) @@ -78,4 +83,4 @@ export const rankByHeat = function(rankingComp) { export const getScores = function(i, h) { const scores = i.heats.find(heat => heat.heatId === h.value)?.scores?.map(s => s.score).join(" + ") return scores === "" ? 0 : scores -} -\ No newline at end of file +}