X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FItem.js;h=0d73105edd21ac13268223742196ca9bbdfe3daa;hb=855decfd62b51ed500c8a5903f4b263c4c9afb5c;hp=2c1b65688416c6639925ef375d5255e7782a9d20;hpb=0f171dfffd9c0c2cc895c9f282c5f4550844cc5a;p=alttp.git diff --git a/resources/js/components/results/Item.js b/resources/js/components/results/Item.js index 2c1b656..0d73105 100644 --- a/resources/js/components/results/Item.js +++ b/resources/js/components/results/Item.js @@ -9,47 +9,74 @@ import { findResult } from '../../helpers/Participant'; import { maySeeResults } from '../../helpers/permissions'; import { withUser } from '../../helpers/UserContext'; -const getIcon = (result, index) => { +const getIcon = (result, maySee) => { if (!result || !result.has_finished) { return ; } - if (index === 0) { + if (result.forfeit && maySee) { + return ; + } + if (result.placement === 1 && maySee) { return ; } - if (index === 1) { + if (result.placement === 2 && maySee) { return ; } - if (index === 2) { + if (result.placement === 3 && maySee) { return ; } return ; }; +const getTime = (result, maySee) => { + if (!result || !maySee) { + return null; + } + if (result.time) { + return formatTime(result); + } + if (result.forfeit) { + return 'DNF'; + } + return '?'; +}; + +const getClassName = result => { + const classNames = ['status']; + if (result && result.has_finished) { + classNames.push('finished'); + if (result.comment) { + classNames.push('has-comment'); + } + } else { + classNames.push('pending'); + } + return classNames.join(' '); +}; + const Item = ({ - index, participant, round, tournament, user, }) => { const result = findResult(participant, round); - return ( -
- -
- - {result && maySeeResults(user, tournament, round) ? - formatTime(result) - : null} - - {getIcon(result, index)} -
+ const maySee = maySeeResults(user, tournament, round); + return
+ +
+ + {getTime(result, maySee)} + + {getIcon(result, maySee)}
- ); +
; }; Item.propTypes = { - index: PropTypes.number, participant: PropTypes.shape({ user: PropTypes.shape({ }),