X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FItem.js;h=43ea91d09ca73157d299c9fa3a51075a17e145c9;hb=812a270c7a410461e931394496512d36b34ef7b5;hp=771c7b62a68ad825a9fe74288db70935c51bdcb5;hpb=d748feb96453d74aeffec648d6f5f68d9ef3b520;p=alttp.git diff --git a/resources/js/components/results/Item.js b/resources/js/components/results/Item.js index 771c7b6..43ea91d 100644 --- a/resources/js/components/results/Item.js +++ b/resources/js/components/results/Item.js @@ -2,29 +2,57 @@ 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 (result.forfeit) { + 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({ }), @@ -37,4 +65,4 @@ Item.propTypes = { }), }; -export default withTranslation()(Item); +export default withTranslation()(withUser(Item));