1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { withTranslation } from 'react-i18next';
5 import Icon from '../common/Icon';
6 import Box from '../users/Box';
7 import { formatTime } from '../../helpers/Result';
8 import { findResult } from '../../helpers/Participant';
9 import { maySeeResults } from '../../helpers/permissions';
10 import { withUser } from '../../helpers/UserContext';
12 const getIcon = (result, index) => {
13 if (!result || !result.has_finished) {
14 return <Icon.PENDING className="text-muted" size="lg" />;
17 return <Icon.FORFEIT className="text-danger" size="lg" />;
20 return <Icon.FIRST_PLACE className="text-gold" size="lg" />;
23 return <Icon.SECOND_PLACE className="text-silver" size="lg" />;
26 return <Icon.THIRD_PLACE className="text-bronze" size="lg" />;
28 return <Icon.FINISHED className="text-success" size="lg" />;
38 const result = findResult(participant, round);
40 <div className="result">
41 <Box user={participant.user} />
42 <div className="status">
43 <span className="time">
44 {result && maySeeResults(user, tournament, round) ?
48 {getIcon(result, index)}
55 index: PropTypes.number,
56 participant: PropTypes.shape({
57 user: PropTypes.shape({
60 round: PropTypes.shape({
62 tournament: PropTypes.shape({
64 user: PropTypes.shape({
68 export default withTranslation()(withUser(Item));