From 878ceac3fc16d0c611c5002ae5d0605f1a07a8b4 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 15 Mar 2022 19:20:06 +0100 Subject: [PATCH] display forfeits with no time as DNF --- resources/js/components/results/Item.js | 33 ++++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/resources/js/components/results/Item.js b/resources/js/components/results/Item.js index 43ea91d..0d0d34e 100644 --- a/resources/js/components/results/Item.js +++ b/resources/js/components/results/Item.js @@ -28,6 +28,19 @@ const getIcon = (result, index) => { return ; }; +const getTime = (user, tournament, round, result) => { + if (!result || !maySeeResults(user, tournament, round)) { + return null; + } + if (result.time) { + return formatTime(result); + } + if (result.forfeit) { + return 'DNF'; + } + return '?'; +}; + const Item = ({ index, participant, @@ -36,19 +49,15 @@ const Item = ({ user, }) => { const result = findResult(participant, round); - return ( -
- -
- - {result && maySeeResults(user, tournament, round) ? - formatTime(result) - : null} - - {getIcon(result, index)} -
+ return
+ +
+ + {getTime(user, tournament, round, result)} + + {getIcon(result, index)}
- ); +
; }; Item.propTypes = { -- 2.39.2