X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FItem.js;h=84395222407e1d50854e283a282a31002b73a328;hb=ce0c2752445b1d0960e331a335f56001f3c521c6;hp=cc61dd06b66c15169fd0ed8692acb7273e0b75b4;hpb=c59d0714d62f9028135cc9cff829d16b91e5fb4f;p=alttp.git diff --git a/resources/js/components/results/Item.js b/resources/js/components/results/Item.js index cc61dd0..8439522 100644 --- a/resources/js/components/results/Item.js +++ b/resources/js/components/results/Item.js @@ -9,6 +9,38 @@ import { findResult } from '../../helpers/Participant'; import { maySeeResults } from '../../helpers/permissions'; import { withUser } from '../../helpers/UserContext'; +const getIcon = (result, maySee) => { + if (!result || !result.has_finished) { + return ; + } + if (result.forfeit && maySee) { + return ; + } + if (result.placement === 1) { + return ; + } + if (result.placement === 2) { + return ; + } + if (result.placement === 3) { + return ; + } + return ; +}; + +const getTime = (result, maySee) => { + if (!result || !maySee) { + return null; + } + if (result.time) { + return formatTime(result); + } + if (result.forfeit) { + return 'DNF'; + } + return '?'; +}; + const Item = ({ participant, round, @@ -16,23 +48,16 @@ const Item = ({ user, }) => { const result = findResult(participant, round); - return ( -
- -
- - {result && maySeeResults(user, tournament, round) ? - formatTime(result) - : null} - - {result && result.has_finished ? - - : - - } -
+ const maySee = maySeeResults(user, tournament, round); + return
+ +
+ + {getTime(result, maySee)} + + {getIcon(result, maySee)}
- ); +
; }; Item.propTypes = {