X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FItem.js;h=2c1b65688416c6639925ef375d5255e7782a9d20;hb=0f171dfffd9c0c2cc895c9f282c5f4550844cc5a;hp=993a3823fd2cfd5a1058b749d67ac1ec81fa4ba8;hpb=edd0e97bfdc544114f30bf4c13a929631c44a555;p=alttp.git diff --git a/resources/js/components/results/Item.js b/resources/js/components/results/Item.js index 993a382..2c1b656 100644 --- a/resources/js/components/results/Item.js +++ b/resources/js/components/results/Item.js @@ -2,29 +2,54 @@ import PropTypes from 'prop-types'; import React from 'react'; import { withTranslation } from 'react-i18next'; +import Icon from '../common/Icon'; import Box from '../users/Box'; import { formatTime } from '../../helpers/Result'; import { findResult } from '../../helpers/Participant'; -import i18n from '../../i18n'; +import { maySeeResults } from '../../helpers/permissions'; +import { withUser } from '../../helpers/UserContext'; + +const getIcon = (result, index) => { + if (!result || !result.has_finished) { + return ; + } + if (index === 0) { + return ; + } + if (index === 1) { + return ; + } + if (index === 2) { + return ; + } + return ; +}; const Item = ({ + index, participant, round, + tournament, + user, }) => { const result = findResult(participant, round); return (
- {result ? -
- {i18n.t('results.time', { time: formatTime(result) })} -
- : null} +
+ + {result && maySeeResults(user, tournament, round) ? + formatTime(result) + : null} + + {getIcon(result, index)} +
); }; Item.propTypes = { + index: PropTypes.number, participant: PropTypes.shape({ user: PropTypes.shape({ }), @@ -33,6 +58,8 @@ Item.propTypes = { }), tournament: PropTypes.shape({ }), + user: PropTypes.shape({ + }), }; -export default withTranslation()(Item); +export default withTranslation()(withUser(Item));